I created two extremely tiny software projects on githup: org-to-xml and org-letter. One of which is a rip-off, and that is the first: the code of org-to-xml, specifically the code in the org-to-xml.el file, was initially posted on stackexchange, in an answer by user harpo to the question "emacs-org mode and html publishing: how to change structure of generated HTML" by user David Belohrad. I grabbed it from there and changed one or two things so that it works with my Emacs 24.

The second is what I actually wanted to do: generate letters from an org-mode file, using HTML as style or template. To this end i export the content of the org-mode buffer to XML and then process it and the HTML template with XSLT to produce the HTML result. This lets me design my template as is, by editing the plain HTML, with some demo texts and style it with CSS. I give certain elements special meanings, basically the will be replaced by some content from the org-mode file. Obvious candidates are keywords

#+keyword: value 1 2 3

and drawers

text a
text b

In my setup, and in the example i use a drawer for the address and otherwise keywords. By expending even two stylesheets, i can specify the name of the template to use in the org buffer with a keyword. The first stylesheet simply spits out the value of the keyword and the second then run the actual stylesheet against the HTML template thus selected and the org-to-xml result. Thus i can easily switch between official and personal templates, which are the two i mainly need.

The "main" XSLT stylesheet then treats the "main" content of the buffer and converts it to HTML, using simple rules, though basically only paragraphs, sections and lists are handled currently. Many other features are still lacking. That will be a work in progress.

blog comments powered by Disqus