[luatex] lua transliterations on the fly

Luis Rivera jlrn77 at gmail.com
Mon Jan 10 19:58:44 CET 2011


On 07/01/2011, Philipp Stephani <st_philipp at yahoo.de> wrote:
>
> BTW, you should _not_ do something like replacing ^c by ĉ. If you want ĉ,
> type ĉ. Use a keyboard layout that contains that character, an input method,
> or some auto-correction function of your text editor, but don't transform
> text while processing. This is true no matter whether you write text files,
> HTML, TeX, or whatever. Babel-like shorthands are completely obsoleted by
> Unicode and cause more problems than they solve.
>

Well, a far more robust approach seems to be using the lpeg library;
I've recycled some code from a Lua script used for ConTeXt's
transliteration for Greek, and then fed the Lua code to an ad hoc
LaTeX command. The transliteration on the fly kinda works; but as
warned by Philip, I've run into trouble because of one active char,
namely, ~.

I'm attaching the source code, all comments included, to document some
attempts to process the conversion on the fly, to deal with the
problematic active char, and to allow readers to compare with Hans
Hagen's original mtx-babel.lua script.

Please, beware this code may be roughly 2/3 cargo cult; so I'm not
sure I can explain exactly how (or why) it works.

Any feedback to help me handle this traumatic tilde are welcome.

-- 
Luis Rivera
O< http://www.asciiribbon.org/ campaign
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lgr2utf.lua
Type: application/octet-stream
Size: 9323 bytes
Desc: not available
URL: <http://tug.org/pipermail/luatex/attachments/20110110/02fa079e/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lgrtrans.tex
Type: application/x-tex
Size: 1079 bytes
Desc: not available
URL: <http://tug.org/pipermail/luatex/attachments/20110110/02fa079e/attachment.tex>


More information about the luatex mailing list