π

Using pandoc to Convert Org-mode to HTML for lazyblorg

Show Sidebar

Arne did post a great comment about the issue of only supporting a sub-set of Org-mode syntax within lazyblorg. Although I explained my reasons to write my own Org-mode parser, he made me think.

I already knew pandoc which is a universal document converter. However, I was not aware that I could use pandoc within Python via pypandoc.

A short test did light up my mind: import pypandoc; pypandoc.convert('- foo bar', 'html', format='org') resulted in u'<ul>\n<li><strong>foo</strong> bar</li>\n</ul>\n'.

Well, this is a game changer.

Not only I could have made my Org-mode parser and HTML-izer much simpler in the first place. I now can easily add Org-mode elements which are not yet supported by my own parser.

As a first step, I integrated support for tables via pypandoc. So far, I am pleased by the result although I still have to test it in real life. Next will be support for lists.

Further more, I am thinking of using pypandoc as a fall-back converter for all not yet supported Org-mode syntax elements (via my own converter, of course).

Next steps Time range Comment
Basic support for tables done This is my first lazyblorg-table!
Basic support for itemized lists days to weeks
Pypandoc as a fall-back weeks Let me think about this

Stay tuned, stay curious.


Related articles that link to this one:

Comment via email (persistent) or via Disqus (ephemeral) comments below: