diff options
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.html | 79 |
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 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] == "-h" or arg[1] == "--help" then @@ -41,9 +42,17 @@ if arg[1] == "-h" or arg[1] == "--help" then end </pre> <p>Get input string:</p> -<pre class="literal-block">if ... then - s = string.gsub(..., "\t", " ") +<pre class="literal-block">local s + +if arg[1] == "-f" then + local f = assert(io.open(arg[2], "r")) + s = f:read("*all") + f:close() +elseif arg[1] then + s = table.concat(arg, " ") .. "\n" else + -- test: + -- s = "\\emph{x\\'us}" s = io.read("*all") end </pre> @@ -62,7 +71,7 @@ end L = "\\textLambda{}", M = "\\textMu{}", N = "\\textNu{}", - K = "\\textXi{}", + X = "\\textXi{}", O = "\\textOmicron{}", P = "\\textPi{}", R = "\\textRho{}", @@ -112,24 +121,50 @@ end ["?"] = "\\texterotimatiko{}", } </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, "s([a-z'`~<>])", "sv%1") -s = string.gsub(s, "s([ ,.:;?!])", "c%1") -s = string.gsub(s, 's"(%s)', 'c"%1') -- " 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, "([a-zA-Z'`~<>|\";?])", 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 == "\\" then + if c2 and (c2 ~= "") then + return c1 .. c2 .. (LGR_map[c3] or c3 or "") + end + return c1 .. c3 + end + c2 = string.gsub(c2, "s(.)", "sv%1") + return (string.gsub(c2, ".", LGR_map) or "") .. (LGR_map[c3] or c3 or "") +end + +-- Use the mapping to replace every ASCII-character with +-- non-standard meaning to the corresponding LICR macro +-- (skip macros):: + -- *([a-zA-Z'`~<>|\";?] +s = string.gsub(s, "(\\?)([a-zA-Z]*)([^\\]?)", lgr_replace) </pre> -<p>Some cleanup operations:</p> -<pre class="literal-block">s = string.gsub(s, "\\'\\'", "\\textquoteright{}") -- '' +<p>Ligatures:</p> +<pre class="literal-block">s = string.gsub(s, "%(%(", "\\guillemotleft{}") +s = string.gsub(s, "%)%)", "\\guillemotright{}") +s = string.gsub(s, "\\'\\'", "\\textquoteright{}") -- '' s = string.gsub(s, "\\`\\`", "\\textquoteleft{}") -- `` -s = string.gsub(s, "\\textautosigma{}\\noboundary{}", "\\textsigma{}") -- sv -s = string.gsub(s, "{}\\", "\\") +s = string.gsub(s, '\"(%s)', "\\textquoteright{}%1") </pre> -<p>The quotation mark (“) denotes a quote/apostrophe if followed by a space:</p> -<pre class="literal-block">s = string.gsub(s, '\"(%s)', "\\textquoteright{}%1") +<p>Separating empty group “{}” only required if followed by space or ASCII:</p> +<pre class="literal-block">s = string.gsub(s, "{}([^ a-zA-Z])", "%1") +</pre> +<p>Autosigma replacements:</p> +<pre class="literal-block">s = string.gsub(s, "\\textautosigma\\noboundary", "\\textsigma") -- sv +s = string.gsub(s, "\\textautosigma(\\['`~<>|\"])", "\\textsigma%1") -- accents + +s = string.gsub(s, "\\textautosigma([-%s!#$%%&%(%)*+,./0-9:=%[%]{|}])", + "\\textfinalsigma%1") + +s = string.gsub(s, "\\textautosigma(\\textquote)", "\\textfinalsigma%1") +s = string.gsub(s, "\\textautosigma(\\texterotimatiko)", "\\textfinalsigma%1") +s = string.gsub(s, "\\textautosigma(\\textanoteleia)", "\\textfinalsigma%1") + +s = string.gsub(s, "\\textautosigma$", "\\textfinalsigma") </pre> <p>Write the result to stdout:</p> <pre class="literal-block">io.write(s) |