aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2019-10-25 08:50:17 +0200
committerRobert Alessi <alessi@robertalessi.net>2019-10-25 08:50:17 +0200
commit0d6bc09305d8139778e9bbf95910e614ee66bb99 (patch)
treedb2385159b7bb6b912158826687b4101d1c084da
parentfaa46ac307d3af366858726d6e4357eb7d0e67af (diff)
downloadekdosis-0d6bc09305d8139778e9bbf95910e614ee66bb99.tar.gz
first implementation of ekdverse environment
-rw-r--r--ekdosis.dtx27
1 files changed, 26 insertions, 1 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 5ee1169..fd99891 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -1018,6 +1018,21 @@ idno={}, msName={}, origDate={}][3]{%
1018 \end{linenumbers}% 1018 \end{linenumbers}%
1019 \iftei@export\luadirect{ekdosis.exporttei(\luastringN{#1})}\else\fi} 1019 \iftei@export\luadirect{ekdosis.exporttei(\luastringN{#1})}\else\fi}
1020% \end{macrocode} 1020% \end{macrocode}
1021% Very basic implementation of poetry lines:---
1022% \begin{macrocode}
1023\newlength{\ekdverseindentlength}
1024\setlength{\ekdverseindentlength}{\parindent}
1025\newenvironment*{ekdverse}[1][\ekdverseindentlength]{
1026 \begin{list}{}{%
1027 \setlength{\leftmargin}{#1}
1028 \setlength{\itemsep}{0pt}
1029 \setlength{\topsep}{0pt}
1030 \setlength{\partopsep}{0pt}
1031 }
1032 \item[]
1033 }{\end{list}}
1034% \end{macrocode}
1035%
1021% \iffalse 1036% \iffalse
1022%</package> 1037%</package>
1023% \fi 1038% \fi
@@ -1267,6 +1282,7 @@ local cmdtotags = {
1267} 1282}
1268 1283
1269local envtotags = { 1284local envtotags = {
1285 {a="ekdverse", b="lg", c=""},
1270 {a="txarabtr", b="p", c=" xml:lang=\"arb-Latn\" type=\"transliterated\""}, 1286 {a="txarabtr", b="p", c=" xml:lang=\"arb-Latn\" type=\"transliterated\""},
1271 {a="txarab", b="p", c=" xml:lang=\"arb\""}, 1287 {a="txarab", b="p", c=" xml:lang=\"arb\""},
1272 {a="center", b="p", c=" rend=\"centered\""}, 1288 {a="center", b="p", c=" rend=\"centered\""},
@@ -1441,14 +1457,23 @@ end
1441 1457
1442local function linestotei(str) 1458local function linestotei(str)
1443 str = "\n<l>"..str 1459 str = "\n<l>"..str
1444 str = gsub(str, endpoem, "</l>\n") 1460-- str = gsub(str, endpoem, "</l>\n")
1445 str = gsub(str, poemline * lpeg.P("&gt;"), "\n<lb/>") 1461 str = gsub(str, poemline * lpeg.P("&gt;"), "\n<lb/>")
1446 str = gsub(str, poemline, "</l>\n<l>") 1462 str = gsub(str, poemline, "</l>\n<l>")
1463 str = str.."</l>\n"
1447 return str 1464 return str
1448end 1465end
1449 1466
1450-- better use lpeg: look into this later 1467-- better use lpeg: look into this later
1451local function versetotei(str) 1468local function versetotei(str)
1469 str = string.gsub(str, "(\\begin%s?%{ekdverse%})(%b[])(.-)(\\end%s?%{ekdverse%})", function(benv, opt, arg, eenv)
1470 arg = linestotei(arg)
1471 return string.format("%s%s%s%s", benv, opt, arg, eenv)
1472 end)
1473 str = string.gsub(str, "(\\begin%s?%{ekdverse%})(.-)(\\end%s?%{ekdverse%})", function(benv, arg, eenv)
1474 arg = linestotei(arg)
1475 return string.format("%s%s%s", benv, arg, eenv)
1476 end)
1452 str = string.gsub(str, "(\\begin%s?%{verse%})(%b[])(.-)(\\end%s?%{verse%})", function(benv, opt, arg, eenv) 1477 str = string.gsub(str, "(\\begin%s?%{verse%})(%b[])(.-)(\\end%s?%{verse%})", function(benv, opt, arg, eenv)
1453 arg = linestotei(arg) 1478 arg = linestotei(arg)
1454 return string.format("%s%s%s%s", benv, opt, arg, eenv) 1479 return string.format("%s%s%s%s", benv, opt, arg, eenv)