summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/greek-fontenc/lgr2licr.lua.html
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/greek-fontenc/lgr2licr.lua.html')
-rw-r--r--Master/texmf-dist/doc/latex/greek-fontenc/lgr2licr.lua.html79
1 files changed, 57 insertions, 22 deletions
diff --git a/Master/texmf-dist/doc/latex/greek-fontenc/lgr2licr.lua.html b/Master/texmf-dist/doc/latex/greek-fontenc/lgr2licr.lua.html
index 7762506cab8..33e6d586acb 100644
--- a/Master/texmf-dist/doc/latex/greek-fontenc/lgr2licr.lua.html
+++ b/Master/texmf-dist/doc/latex/greek-fontenc/lgr2licr.lua.html
@@ -22,17 +22,18 @@ conditions of the <a class="reference external" href="http://www.latex-project.o
version&nbsp;1.3 of this license or any later version.</p>
</dd>
</dl>
-<!-- #!/usr/bin/env lua
-- - -*- coding: utf-8 -*- -->
+<!-- #!/usr/bin/env lua -->
<p>The LGR font encoding is the de-facto standard for Greek typesetting with
LaTeX. This file provides a translation from the Latin transcription defined
by LGR into the LaTeX Internal Character Representation (LICR) macros.</p>
<pre class="literal-block">usage = [[
Usage: lua lgr2licr.lua [OPTIONS] [STRING]
Convert STRING from Latin transcription to LICR macros for Greek symbols.
- Without argument, the script reads from standard input, e.g., a
- redirected file or interactive input ended with Ctrl-D.
+ (This dumb conversion fails if the string contains TeX macros.)
+ Without argument, the script reads from standard input like a
+ redirected file. End interactive input with Ctrl-D.
Options: -h, --help show this help
+ -f, --file read input from file STRING
]]
if arg[1] == &quot;-h&quot; or arg[1] == &quot;--help&quot; then
@@ -41,9 +42,17 @@ if arg[1] == &quot;-h&quot; or arg[1] == &quot;--help&quot; then
end
</pre>
<p>Get input string:</p>
-<pre class="literal-block">if ... then
- s = string.gsub(..., &quot;\t&quot;, &quot; &quot;)
+<pre class="literal-block">local s
+
+if arg[1] == &quot;-f&quot; then
+ local f = assert(io.open(arg[2], &quot;r&quot;))
+ s = f:read(&quot;*all&quot;)
+ f:close()
+elseif arg[1] then
+ s = table.concat(arg, &quot; &quot;) .. &quot;\n&quot;
else
+ -- test:
+ -- s = &quot;\\emph{x\\'us}&quot;
s = io.read(&quot;*all&quot;)
end
</pre>
@@ -62,7 +71,7 @@ end
L = &quot;\\textLambda{}&quot;,
M = &quot;\\textMu{}&quot;,
N = &quot;\\textNu{}&quot;,
- K = &quot;\\textXi{}&quot;,
+ X = &quot;\\textXi{}&quot;,
O = &quot;\\textOmicron{}&quot;,
P = &quot;\\textPi{}&quot;,
R = &quot;\\textRho{}&quot;,
@@ -112,24 +121,50 @@ end
[&quot;?&quot;] = &quot;\\texterotimatiko{}&quot;,
}
</pre>
-<p>Replace the “autosigma” (s) with “sigma” (sv) if followed by another
-character and with “finalsigma” (c) if followed by space or punctuation:</p>
-<pre class="literal-block">s = string.gsub(s, &quot;s([a-z'`~&lt;&gt;])&quot;, &quot;sv%1&quot;)
-s = string.gsub(s, &quot;s([ ,.:;?!])&quot;, &quot;c%1&quot;)
-s = string.gsub(s, 's&quot;(%s)', 'c&quot;%1') -- &quot; before whitespace is quote/apostrophe
-</pre>
-<p>Use the mapping to replace every ASCII-character with
-non-standard meaning to the corresponding LICR macro:</p>
-<pre class="literal-block">s = string.gsub(s, &quot;([a-zA-Z'`~&lt;&gt;|\&quot;;?])&quot;, LGR_map)
+<p>Return substitution string for 3 captures:</p>
+<p><cite>c1</cite> backslash
+<cite>c2</cite> a-zA-Z
+<cite>c3</cite> any other char</p>
+<pre class="literal-block">function lgr_replace(c1, c2, c3)
+ -- print (c1, c2, c3)
+ if c1 == &quot;\\&quot; then
+ if c2 and (c2 ~= &quot;&quot;) then
+ return c1 .. c2 .. (LGR_map[c3] or c3 or &quot;&quot;)
+ end
+ return c1 .. c3
+ end
+ c2 = string.gsub(c2, &quot;s(.)&quot;, &quot;sv%1&quot;)
+ return (string.gsub(c2, &quot;.&quot;, LGR_map) or &quot;&quot;) .. (LGR_map[c3] or c3 or &quot;&quot;)
+end
+
+-- Use the mapping to replace every ASCII-character with
+-- non-standard meaning to the corresponding LICR macro
+-- (skip macros)::
+ -- *([a-zA-Z'`~&lt;&gt;|\&quot;;?]
+s = string.gsub(s, &quot;(\\?)([a-zA-Z]*)([^\\]?)&quot;, lgr_replace)
</pre>
-<p>Some cleanup operations:</p>
-<pre class="literal-block">s = string.gsub(s, &quot;\\'\\'&quot;, &quot;\\textquoteright{}&quot;) -- ''
+<p>Ligatures:</p>
+<pre class="literal-block">s = string.gsub(s, &quot;%(%(&quot;, &quot;\\guillemotleft{}&quot;)
+s = string.gsub(s, &quot;%)%)&quot;, &quot;\\guillemotright{}&quot;)
+s = string.gsub(s, &quot;\\'\\'&quot;, &quot;\\textquoteright{}&quot;) -- ''
s = string.gsub(s, &quot;\\`\\`&quot;, &quot;\\textquoteleft{}&quot;) -- ``
-s = string.gsub(s, &quot;\\textautosigma{}\\noboundary{}&quot;, &quot;\\textsigma{}&quot;) -- sv
-s = string.gsub(s, &quot;{}\\&quot;, &quot;\\&quot;)
+s = string.gsub(s, '\&quot;(%s)', &quot;\\textquoteright{}%1&quot;)
</pre>
-<p>The quotation mark (“) denotes a quote/apostrophe if followed by a space:</p>
-<pre class="literal-block">s = string.gsub(s, '\&quot;(%s)', &quot;\\textquoteright{}%1&quot;)
+<p>Separating empty group “{}” only required if followed by space or ASCII:</p>
+<pre class="literal-block">s = string.gsub(s, &quot;{}([^ a-zA-Z])&quot;, &quot;%1&quot;)
+</pre>
+<p>Autosigma replacements:</p>
+<pre class="literal-block">s = string.gsub(s, &quot;\\textautosigma\\noboundary&quot;, &quot;\\textsigma&quot;) -- sv
+s = string.gsub(s, &quot;\\textautosigma(\\['`~&lt;&gt;|\&quot;])&quot;, &quot;\\textsigma%1&quot;) -- accents
+
+s = string.gsub(s, &quot;\\textautosigma([-%s!#$%%&amp;%(%)*+,./0-9:=%[%]{|}])&quot;,
+ &quot;\\textfinalsigma%1&quot;)
+
+s = string.gsub(s, &quot;\\textautosigma(\\textquote)&quot;, &quot;\\textfinalsigma%1&quot;)
+s = string.gsub(s, &quot;\\textautosigma(\\texterotimatiko)&quot;, &quot;\\textfinalsigma%1&quot;)
+s = string.gsub(s, &quot;\\textautosigma(\\textanoteleia)&quot;, &quot;\\textfinalsigma%1&quot;)
+
+s = string.gsub(s, &quot;\\textautosigma$&quot;, &quot;\\textfinalsigma&quot;)
</pre>
<p>Write the result to stdout:</p>
<pre class="literal-block">io.write(s)