blob: 17150f3a1b430dc3dbe49f6aae26d5cba5e3215e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
--
--------------------------------------------------------------------------------
-- 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), <gesang@stud.uni-heidelberg.de>
-- CREATED: 2011-06-11T16:14:16+0200
--------------------------------------------------------------------------------
--
environment.loadluafile("transliterator")
local translit = thirddata.translit
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: <https://bitbucket.org/phg/transliterator/>
===============================================================
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
|