Polyglot Documents in Org-mode

The University of Oxford Software Engineering Research group (OxRSE) has an interesting post on how they use Org-mode to publish tutorial material with the examples in different programming languages. The idea is to present the concepts, which are language agnostic, in a language familiar to the student. The language specific material includes both example and the accompanying narrative.

Of course, they don’t want to maintain separate documents for each language since most of the material is independent of the language and would be the same in each such file. Emacs and Org-mode to the rescue.

Org-mode, along with Babel, is already an ideal solution for writing technical material but there’s another Org feature that provides just what OxRSE needed: tags. They can mark code examples and the accompanying prose with a tag for that particular language. Then when they want to export the document for a particular language, they can add the tags for the other languages to a #+EXCLUDE_TAGS: directive.

It’s a nice technique for most situations where you’d like to maintain a single document for several slightly different versions of the same material. The post has a toy example for a tutorial on the Hello, World program but it’s so simple to implement that you hardly need the example.

If you have to the same document in slightly different flavors, be sure to take a look at this post.

This entry was posted in Blogging and tagged , . Bookmark the permalink.