aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2019-10-25 17:57:54 +0200
committerRobert Alessi <alessi@robertalessi.net>2019-10-25 17:57:54 +0200
commitdbe3fc48b63e793a72baa585ead8e1ad18fbb213 (patch)
tree9aefe090ce66877d937ce26d63ba6a2b3ef41fae
parent02429663d98f4dfb91d504a362fc480393c14f8b (diff)
downloadekdosis-dbe3fc48b63e793a72baa585ead8e1ad18fbb213.tar.gz
make 3rd argument of TeX|EnvtoTei optional; nullify nullify TEI tag if arg2 is void
-rw-r--r--ekdosis.dtx51
1 files changed, 31 insertions, 20 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 105dea3..d5c6bd5 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -355,7 +355,6 @@ Running "make install" installs the files in the local TeX tree.
355 \@namedef{opt@#2.sty}{#1}} 355 \@namedef{opt@#2.sty}{#1}}
356\dontusepackage{etex} 356\dontusepackage{etex}
357\RequirePackage{luacode} 357\RequirePackage{luacode}
358\RequirePackage{manyfoot}
359\RequirePackage{paracol} 358\RequirePackage{paracol}
360\RequirePackage{keycommand} 359\RequirePackage{keycommand}
361\RequirePackage{xparse} 360\RequirePackage{xparse}
@@ -425,12 +424,12 @@ idno={}, msName={}, origDate={}][3]{%
425% \end{macrocode} 424% \end{macrocode}
426% Add a \hologo{(La)TeX} command to be processed as a |TEI xml| tag: 425% Add a \hologo{(La)TeX} command to be processed as a |TEI xml| tag:
427% \begin{macrocode} 426% \begin{macrocode}
428\NewDocumentCommand{\TeXtoTEI}{m m m}{% 427\NewDocumentCommand{\TeXtoTEI}{m m O{}}{%
429 \luadirect{ekdosis.newcmdtotag(\luastringN{#1}, 428 \luadirect{ekdosis.newcmdtotag(\luastringN{#1},
430 \luastringN{#2}, 429 \luastringN{#2},
431 \luastringN{#3})} 430 \luastringN{#3})}
432} 431}
433\NewDocumentCommand{\EnvtoTEI}{s m m m}{% 432\NewDocumentCommand{\EnvtoTEI}{s m m O{}}{%
434 \IfBooleanTF{#1}{% 433 \IfBooleanTF{#1}{%
435 \luadirect{ekdosis.newenvtotag(\luastringN{#2}, 434 \luadirect{ekdosis.newenvtotag(\luastringN{#2},
436 \luastringN{#3}, 435 \luastringN{#3},
@@ -562,16 +561,12 @@ idno={}, msName={}, origDate={}][3]{%
562 \fi} 561 \fi}
563\newif\ifsubsq@unit 562\newif\ifsubsq@unit
564\subsq@unittrue 563\subsq@unittrue
565\SetFootnoteHook{\hskip -1.8em}
566\newfootnote{@ekd}
567\def\add@@apparatus{% 564\def\add@@apparatus{%
568 \if@pkg@parnotes\parnotes\else\fi% 565 \if@pkg@parnotes\parnotes\else\fi%
569 \if@pkg@footins% 566 \if@pkg@footins%
570 \bgroup% 567 \bgroup%
571 \ifrtl@app\setRL\fi% 568 \ifrtl@app\setRL\fi%
572 \blfootnote{% 569 \blfootnote{%
573 % \Footnotetext@ekd{\relax}{%
574 % \ifrtl@app\setRL\else\setLR\fi%
575 \if@pkg@parnotes% 570 \if@pkg@parnotes%
576 \if@parnotesroman% 571 \if@parnotesroman%
577 \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi% 572 \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi%
@@ -582,7 +577,7 @@ idno={}, msName={}, origDate={}][3]{%
582 \egroup% 577 \egroup%
583 \fi% 578 \fi%
584 \if@pkg@float% 579 \if@pkg@float%
585 \keyparbox[b!]{}{\ifrtl@app\setRL\else\setLR\fi% 580 \keyparbox[b!]{}{\ifrtl@app\setRL\fi%
586 \if@pkg@parnotes% 581 \if@pkg@parnotes%
587 \if@parnotesroman% 582 \if@parnotesroman%
588 \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi% 583 \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi%
@@ -1501,24 +1496,35 @@ end
1501local function envtotei(str) 1496local function envtotei(str)
1502 for i = 1,#envtotags 1497 for i = 1,#envtotags
1503 do 1498 do
1504 -- if tei_p_open and envtotags[i].b == "p" or envtotags[i].b == "lg" 1499 if envtotags[i].b ~= ""
1505 if tei_p_open and isfound(close_p, envtotags[i].b)
1506 then 1500 then
1507 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") 1501 -- if tei_p_open and envtotags[i].b == "p" or envtotags[i].b == "lg"
1508 * lpeg.Cs(envtotags[i].a) * lpeg.P("}") 1502 if tei_p_open and isfound(close_p, envtotags[i].b)
1509 * bsqbracketsii * bcbracesii * spcenc^-1, 1503 then
1510 "</p>\n<"..envtotags[i].b..envtotags[i].c..">") 1504 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
1511 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") 1505 * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
1512 * lpeg.Cs(envtotags[i].a) * lpeg.P("}"), 1506 * bsqbracketsii * bcbracesii * spcenc^-1,
1513 "</"..envtotags[i].b..">\n<p>") 1507 "</p>\n<"..envtotags[i].b..envtotags[i].c..">")
1508 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
1509 * lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
1510 "</"..envtotags[i].b..">\n<p>")
1511 else
1512 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
1513 * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
1514 * bsqbracketsii * bcbracesii * spcenc^-1,
1515 "<"..envtotags[i].b..envtotags[i].c..">")
1516 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
1517 * lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
1518 "</"..envtotags[i].b..">")
1519 end
1514 else 1520 else
1515 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") 1521 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
1516 * lpeg.Cs(envtotags[i].a) * lpeg.P("}") 1522 * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
1517 * bsqbracketsii * bcbracesii * spcenc^-1, 1523 * bsqbracketsii * bcbracesii * spcenc^-1,
1518 "<"..envtotags[i].b..envtotags[i].c..">") 1524 "")
1519 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") 1525 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
1520 * lpeg.Cs(envtotags[i].a) * lpeg.P("}"), 1526 * lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
1521 "</"..envtotags[i].b..">") 1527 "")
1522 end 1528 end
1523 end 1529 end
1524 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") 1530 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
@@ -1546,8 +1552,13 @@ local function cmdtotei(str)
1546 end) 1552 end)
1547 body = cmdtotei(body) 1553 body = cmdtotei(body)
1548 -- return string.format("<"..cmdtotags[i].b..cmdtotags[i].c.." %s>%s</"..cmdtotags[i].b..">", arg, body) 1554 -- return string.format("<"..cmdtotags[i].b..cmdtotags[i].c.." %s>%s</"..cmdtotags[i].b..">", arg, body)
1549 return string.format("<"..cmdtotags[i].b..cmdtotags[i].c..">%s</" .. 1555 if cmdtotags[i].b ~= ""
1556 then
1557 return string.format("<"..cmdtotags[i].b..cmdtotags[i].c..">%s</" ..
1550 cmdtotags[i].b..">", body) 1558 cmdtotags[i].b..">", body)
1559 else
1560 return ""
1561 end
1551 end) 1562 end)
1552 end 1563 end
1553 -- temporarily: 1564 -- temporarily: