From ebebb1a66fa7500ca1644a868d8378bccaf281ca Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 11 Jun 2011 16:54:04 +0200 Subject: external mtx script interface --- scripts/context/lua/mtx-transliterate.lua | 58 ++++++++++++++++++++++ .../third/transliterator/trans_tables_sr.lua | 2 + .../third/transliterator/transliterator.lua | 3 ++ 3 files changed, 63 insertions(+) create mode 100644 scripts/context/lua/mtx-transliterate.lua diff --git a/scripts/context/lua/mtx-transliterate.lua b/scripts/context/lua/mtx-transliterate.lua new file mode 100644 index 0000000..10e4ad8 --- /dev/null +++ b/scripts/context/lua/mtx-transliterate.lua @@ -0,0 +1,58 @@ +-- +-------------------------------------------------------------------------------- +-- FILE: mtx-transliterate.lua +-- USAGE: mtxrun --script transliterate [--mode=mode] --s="string" +-- DESCRIPTION: context script interface for the Transliterator module +-- REQUIREMENTS: latest ConTeXt MkIV +-- AUTHOR: Philipp Gesang (Phg), +-- CREATED: 2011-06-11T16:14:16+0200 +-------------------------------------------------------------------------------- +-- + +environment.loadluafile("transliterator") + +translit.__script = true +scripts = scripts or { } +scripts.transliterate = { } +local ea = environment.argument + +local helpinfo = [[ +=============================================================== + The Transliterator module, command line interface. + © 2010--2011 Philipp Gesang. License: 2-clause BSD. + Home: +=============================================================== + +USAGE: + + mtxrun --script transliterate [--mode=mode] --s="target" + + Where “target” is the target string to be transliterated. + Optionally, a transliteration mode can be specified (see + the respective descriptions in transliterator.pdf). The + “mode” defaults to “ru_old”. + +=============================================================== +]] + +local application = logs.application { + name = "mtx-transliterate", + banner = "The Transliterator for ConTeXt, hg-rev 38+", + helpinfo = helpinfo, +} + +scripts.transliterate.input = ea("s") +scripts.transliterate.out = function (sin, sout) + io.write(string.format("\n“%s” -> “%s”\n", sin, sout)) +end + +if scripts.transliterate.input then + local mode = ea("mode") or "ru_old" + scripts.transliterate.out( + scripts.transliterate.input, + translit.transliterate(mode, ea("s")) + ) +else + application.help() +end + diff --git a/tex/context/third/transliterator/trans_tables_sr.lua b/tex/context/third/transliterator/trans_tables_sr.lua index f3b9218..3f18be5 100644 --- a/tex/context/third/transliterator/trans_tables_sr.lua +++ b/tex/context/third/transliterator/trans_tables_sr.lua @@ -3,6 +3,8 @@ -- Serbian -- --===========================================================================-- +-- Special thanks to Mojca Miklavec and Arthur Reutenauer for their +-- assistance in creating these transliteration routines. if not translit.done_serbian then -------------------------------------------- diff --git a/tex/context/third/transliterator/transliterator.lua b/tex/context/third/transliterator/transliterator.lua index f1d34ae..b64f888 100644 --- a/tex/context/third/transliterator/transliterator.lua +++ b/tex/context/third/transliterator/transliterator.lua @@ -265,5 +265,8 @@ function translit.transliterate (method, text) end end + if translit.__script then + return methods[method](text) + end context ( methods[method](text) ) end -- cgit v1.2.3