stevengharms.com

Sententiae viri ex temporibus duobus

[Ruby] a Tool to Convert LaTeX-style Macrons to Macron Characters, Html Entities, or UTF-8 Escape Codes

When I write my Latin homework in LaTeX, the source winds up looking like this:

\item[13.] Am\={\i}c\={o}s tr\={\i}st\={e}s exc\={e}pit, ad m\={e}nsam inv\={\i}t\={a}vit, et e\={\i}s perfugium ac s\={o}l\={a}cium h\={\i}c dedit.

{ Aside: You might be thinking that entering “\ = { \ i }” just to get a single character would be a drag, but thanks to Textmate I have created snippets such that Control + letter does all that typing for me }

Now if I want to post this to the web, I need to convert those characters from say “\={\i}” to “ī”. I would like it to go through the sentence and change each of those LaTeX-macron characters to HTML entities.

Similarly, I occasionally have need to convert LaTeX-macron sequences to UTF-8 codes.

And yet other times I want it to convert those codes to macron-ized characters.

So I wrote a script that takes input of the LaTeX form and will let you specify if you want the output in HTML entity (default), macron characters, or utf8 characters.

The best part is that I’ve written this function into Textmate as an extension so for me conversion is:

Default String

ss_tmlatinconv_1

Highlight the LaTeX string

tm_latinconv_2

Choose my command with this script in it

ss_tmlatinconv_3

Text is replaced, magically!

ss_tmlatinconv_4

And it looks like this in a browser…

\item[13.] Amīcōs trīstēs excēpit, ad mēnsam invītāvit, et eīs perfugium ac sōlācium hī

Comments