Added RTF driver

27 views
Skip to first unread message

The Beez

unread,
Mar 5, 2016, 8:07:20 AM3/5/16
to 4tH-compiler

Hi 4tH-ers!

You haven't heard from me for some time, but given the holidays, some illness and the fact that I preferred to do some writing, I tend to think you can forgive me. We're slowly going towards a new release, so I thought it was time to add a nice extra.

I'm not a great fan of Microsoft or its word processor Word, I have to admit that RTF is a format which is pretty useful. Not that it has technical brilliance, but it is supported by virtually every single word processor in the world, from KWord, through LibreOffice and Abiword to Wordpad and Word. So some time I decided to make a driver in the style of HTML.4tH and LATEX.4tH.

Now that was quite a puzzle. Yes, there is some documentation on the RTF format, but since it is not a markup language, you need an extraordinary amount of formatting to get the look I wanted. Finally, I decided to take a look at LaTeX2RTF for inspiration. That worked.

The resulting driver is not small (10K, a monster by 4tH's standards) but it does a nice job. I added the %PRINTLN word though, because I can't handle newline as transparent as one does LaTeX, but that's about it. All other things, like section, enumeration and table numbering is handled transparently by the driver, so you don't need to pay attention to that one. And everything else is there as well, bold, italic, tables, left-aligned, right-aligned, lines, verse style, etc. so porting anything from the LaTeX driver to the RTF driver is a matter of minutes.

Here is a screenshot, left the unedited document, right the source. Code in SVN.

Hans Bezemer


Reply all
Reply to author
Forward
0 new messages