I have files that I want to make available in an variety of formats:
- HTML
- EPUB
- Plain Text (maybe)
Most of the files will be sourced in doc, docx, or rtf format, so that needs to be considered.
So I need some kind of format that converts well from docx, doc, and rtf and has plenty of libraries for converting into PDF, EPUB, HTML etc. Ideally libraries in Python, but Java is also okay.
3
“doc” and “rtf” can be easily converted to “docx” using MS Word. “docx” can be can be converted to PDF, EPUB, HTML or plain text either by Word’s buildin converters, or by third party tools.
Here is a link telling you more about a clean Word->HTML conversion: http://webdesign.about.com/od/beginningtutorials/qt/doc-to-html.htm
For Word->EPUB a simple google search will reveal you some free online converters and some commercial tools.
If, for what reasons ever, you don’t like that solution and want a more “vendor neutral” intermediate format, then use docbook. But don’t expect that this will increase the overall quality of the results, since every additional step in the conversion chain will most probably add some additional data loss.
When searching for the intermediate format, there is always a problem with presentational vs. structural markup problem.
Typically, DocBook or LaTeX sources use the clear structural markup with usually few exceptions (misuses) caused by the author.
On the other hand, Word users tend to use mainly the presentational markup (explicitly telling the block of text the font size, font family, weight, …). Word allows the structural markup, but it is not forced too much.
Plain HTML is clearly structural, but the span
and the like element allow to attach a lot of attributes to the block of text in the non-structural manner. You can clearly see the difference between the manually created HTML, technically generated HTML, and the documents converted from Word docs. Therefore, it may be difficult to find a common denominator even for HTML documents. The XML adds even more possibilities that can be misused.
But if you want to have one format that covers everything, then it probably should be XML. However, it may be one with document type designed by you for the purpose. The good thing is that there are tools for verification of your intermediate XML document. This way, you can be later sure that there is a way to the final form.
My guess is that it is almost impossible to convert various sources to the intermediate format with the good quality. It depends a lot on who created the souces. It is likely you will have to write a lot of parser for special subsets of the documents.
Python is probably a good choice. It depends on your knowledge. If you are better in Java or Perl, they can be better. I would prefer Python. (I do not have a good working knowlege of Java, and my Perl knowledge is rusty because I have found Python much better for me.)