aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2019-10-27 18:21:50 +0100
committerRobert Alessi <alessi@robertalessi.net>2019-10-27 18:21:50 +0100
commit959b7789787a6848434f2c4fe61ca932571b569d (patch)
tree2ad47e34dd3bbf54007343c529be587d943503f7
parent29b9b2909973d24b37836a2339ec435db3c0846c (diff)
downloadekdosis-959b7789787a6848434f2c4fe61ca932571b569d.tar.gz
added flexible \TeXtoTEIPatt command
-rw-r--r--ekdosis.dtx20
1 files changed, 20 insertions, 0 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index a7a6dac..5e9dedd 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -441,6 +441,9 @@ idno={}, msName={}, origDate={}][3]{%
441 \luastringN{#4})} 441 \luastringN{#4})}
442 } 442 }
443} 443}
444\NewDocumentCommand{\TeXtoTEIPatt}{m m}{%
445 \luadirect{ekdosis.newpatttotag(\luastringN{#1}, \luastringN{#2})}
446}
444% \end{macrocode} 447% \end{macrocode}
445% Set |TEI| file name 448% Set |TEI| file name
446% \begin{macrocode} 449% \begin{macrocode}
@@ -1289,6 +1292,8 @@ local cmdtotags = {
1289 c=" xml:lang=\"arb-Latn\" type=\"transliterated\" subtype=\"arabtex\""} 1292 c=" xml:lang=\"arb-Latn\" type=\"transliterated\" subtype=\"arabtex\""}
1290} 1293}
1291 1294
1295local texpatttotags = {}
1296
1292local envtotags = { 1297local envtotags = {
1293 {a="ekdverse", b="lg", c=""}, 1298 {a="ekdverse", b="lg", c=""},
1294 {a="txarabtr", b="p", c=" xml:lang=\"arb-Latn\" type=\"transliterated\""}, 1299 {a="txarabtr", b="p", c=" xml:lang=\"arb-Latn\" type=\"transliterated\""},
@@ -1319,6 +1324,13 @@ function ekdosis.newcmdtotag(cmd, tag, attr)
1319 return true 1324 return true
1320end 1325end
1321 1326
1327function ekdosis.newpatttotag(pat, repl)
1328 pat = string.gsub(pat, "%#[1-9]", "(.-)")
1329 repl = string.gsub(repl, "%#", "%%")
1330 table.insert(texpatttotags, { a = pat, b = repl })
1331 return true
1332end
1333
1322function ekdosis.newenvtotag(env, tag, attr, closep) 1334function ekdosis.newenvtotag(env, tag, attr, closep)
1323 if isintable(envtotags, env) 1335 if isintable(envtotags, env)
1324 then 1336 then
@@ -1538,6 +1550,13 @@ local function envtotei(str)
1538 return str 1550 return str
1539end 1551end
1540 1552
1553local function texpatttotei(str)
1554 for i = 1,#texpatttotags do
1555 str = string.gsub(str, texpatttotags[i].a, texpatttotags[i].b)
1556 end
1557 return str
1558end
1559
1541local function cmdtotei(str) 1560local function cmdtotei(str)
1542 for i = 1,#cmdtotags 1561 for i = 1,#cmdtotags
1543 do 1562 do
@@ -1588,6 +1607,7 @@ end
1588 1607
1589local function textotei(str) 1608local function textotei(str)
1590 str = xml_entities(str) 1609 str = xml_entities(str)
1610 str = texpatttotei(str)
1591 if tei_p_open 1611 if tei_p_open
1592 then 1612 then
1593 str = string.gsub(str, "%s?\\par%s?", "</p>\n<p>") 1613 str = string.gsub(str, "%s?\\par%s?", "</p>\n<p>")