aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ekdosis.dtx112
1 files changed, 82 insertions, 30 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 0badedd..3e8181a 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -401,7 +401,7 @@ along with this program. If not, see
401\def\sg#1{\textancientgreek{#1}} 401\def\sg#1{\textancientgreek{#1}}
402\usepackage[Old Standard]{mathfont} 402\usepackage[Old Standard]{mathfont}
403\usepackage{arabluatex} 403\usepackage{arabluatex}
404\usepackage[parnotes=roman,teiexport=tidy,verse]{ekdosis} 404\usepackage[parnotes=roman, teiexport=tidy, poetry=verse]{ekdosis}
405\input{ekdosis-cfg} 405\input{ekdosis-cfg}
406\AddxmlBibResource{bibdata.xml} 406\AddxmlBibResource{bibdata.xml}
407\usepackage{booktabs} 407\usepackage{booktabs}
@@ -6151,6 +6151,7 @@ Sample text with a \textcolor{red}{word} in red.
6151\newif\if@parnotesroman 6151\newif\if@parnotesroman
6152\newif\if@pkg@parnotes 6152\newif\if@pkg@parnotes
6153\newif\iftei@export 6153\newif\iftei@export
6154\newif\if@pkg@poetry@verse
6154\ekvdefinekeys{ekdosis}{ 6155\ekvdefinekeys{ekdosis}{
6155 choice layout = {float = {\@pkg@floattrue}, 6156 choice layout = {float = {\@pkg@floattrue},
6156 footins = {\@pkg@floatfalse\@pkg@footinstrue}}, 6157 footins = {\@pkg@floatfalse\@pkg@footinstrue}},
@@ -6163,7 +6164,9 @@ Sample text with a \textcolor{red}{word} in red.
6163 initial divs = ekdosis, 6164 initial divs = ekdosis,
6164 unknown-choice divs = \PackageError{ekdosis}{unknown divs=#1}{`divs' 6165 unknown-choice divs = \PackageError{ekdosis}{unknown divs=#1}{`divs'
6165 must be either `ekdosis' or `latex'.}, 6166 must be either `ekdosis' or `latex'.},
6166 bool verse = \if@pkg@verse, 6167 choice poetry = {verse = {\@pkg@poetry@versetrue}},
6168 unknown-choice poetry = \PackageError{ekdosis}{unknown
6169 poetry=#1}{`poetry' must be `verse' for now.},
6167 choice parnotes = {false = {}, 6170 choice parnotes = {false = {},
6168 true = {\@pkg@parnotestrue}, 6171 true = {\@pkg@parnotestrue},
6169 roman = {\@pkg@parnotestrue\@parnotesromantrue}}, 6172 roman = {\@pkg@parnotestrue\@parnotesromantrue}},
@@ -6203,7 +6206,7 @@ Sample text with a \textcolor{red}{word} in red.
6203\RequirePackage{ltxcmds} 6206\RequirePackage{ltxcmds}
6204\RequirePackage{pdftexcmds} 6207\RequirePackage{pdftexcmds}
6205\RequirePackage{ifoddpage} 6208\RequirePackage{ifoddpage}
6206\if@pkg@verse 6209\if@pkg@poetry@verse
6207 \RequirePackage{verse} 6210 \RequirePackage{verse}
6208\fi 6211\fi
6209\if@pkg@parnotes 6212\if@pkg@parnotes
@@ -6930,7 +6933,7 @@ Sample text with a \textcolor{red}{word} in red.
6930 lineation=#1}{`lineation' must be either `page' or `document'.}, 6933 lineation=#1}{`lineation' must be either `page' or `document'.},
6931 code modulonum = \chardef\c@linenumbermodulo#1\relax, 6934 code modulonum = \chardef\c@linenumbermodulo#1\relax,
6932 noval modulo = \modulolinenumbers, 6935 noval modulo = \modulolinenumbers,
6933 code vmodulo = \if@pkg@verse\poemlines{#1}\fi, 6936 code vmodulo = \if@pkg@poetry@verse\poemlines{#1}\fi,
6934 initial vmodulo = 1, 6937 initial vmodulo = 1,
6935 default vmodulo = 5, 6938 default vmodulo = 5,
6936 bool continuousvnum = \if@continuous@vnum, 6939 bool continuousvnum = \if@continuous@vnum,
@@ -7943,10 +7946,16 @@ Sample text with a \textcolor{red}{word} in red.
7943% depending on the value that is passed to the global option 7946% depending on the value that is passed to the global option
7944% |verse|:--- 7947% |verse|:---
7945% \begin{macrocode} 7948% \begin{macrocode}
7946\if@pkg@verse 7949\if@pkg@poetry@verse
7950\ekvdefinekeys{ekd@verse}{
7951 dimen width = \vwidth@val,
7952 initial width = \linewidth,
7953 code type = \def\type@value{#1},
7954}
7947\verselinenumfont{\normalfont\footnotesize} 7955\verselinenumfont{\normalfont\footnotesize}
7948\setcounter{poemline}{1} 7956\setcounter{poemline}{1}
7949\NewDocumentEnvironment{ekdverse}{O{\linewidth}}{% 7957\NewDocumentEnvironment{ekdverse}{O{}}{%
7958 \ekvset{ekd@verse}{#1}%
7950 \if@continuous@vnum\setverselinenums{\thelinenumber}{0}\fi 7959 \if@continuous@vnum\setverselinenums{\thelinenumber}{0}\fi
7951 \nolinenumbers 7960 \nolinenumbers
7952 \let\linelabel\label 7961 \let\linelabel\label
@@ -7961,10 +7970,10 @@ Sample text with a \textcolor{red}{word} in red.
7961 \setlength{\itemsep}{0pt}% 7970 \setlength{\itemsep}{0pt}%
7962 \setlength{\topsep}{0pt}% 7971 \setlength{\topsep}{0pt}%
7963 \setlength{\partopsep}{0pt}% 7972 \setlength{\partopsep}{0pt}%
7964 \ifdim #1 < \linewidth 7973 \ifdim\vwidth@val < \linewidth
7965 \rightmargin \z@ 7974 \rightmargin \z@
7966 \setlength{\leftmargin}{\linewidth}% 7975 \setlength{\leftmargin}{\linewidth}%
7967 \addtolength{\leftmargin}{-#1}% 7976 \addtolength{\leftmargin}{-\vwidth@val}%
7968 \addtolength{\leftmargin}{-0.5\leftmargin}% 7977 \addtolength{\leftmargin}{-0.5\leftmargin}%
7969 \else 7978 \else
7970 \rightmargin \leftmargin 7979 \rightmargin \leftmargin
@@ -7996,10 +8005,23 @@ Sample text with a \textcolor{red}{word} in red.
7996% argument. 8005% argument.
7997% \begin{macrocode} 8006% \begin{macrocode}
7998\NewDocumentCommand{\resetvlinenumber}{O{1}}{% 8007\NewDocumentCommand{\resetvlinenumber}{O{1}}{%
8008 \if@pkg@poetry@verse
7999 \setverselinenums{#1}{0}% 8009 \setverselinenums{#1}{0}%
8010 \fi
8000} 8011}
8001% \end{macrocode} 8012% \end{macrocode}
8002% \end{macro} 8013% \end{macro}
8014% \begin{environment}{ekdstanza}
8015% \changes{v1.2}{2021/03/08}{new environment for stanzas}
8016% \begin{macrocode}
8017\ekvdefinekeys{ekd@stanza}{
8018 code type = \def\type@value{#1}
8019}
8020\NewDocumentEnvironment{ekdstanza}{O{}}{%
8021 \ekvset{ekd@stanza}{#1}%
8022}{}
8023% \end{macrocode}
8024% \end{environment}
8003% \begin{environment}{ekdpar} 8025% \begin{environment}{ekdpar}
8004% When |autopar| is set to |false| by means of \cs{SetTEIxmlExport}, 8026% When |autopar| is set to |false| by means of \cs{SetTEIxmlExport},
8005% \env{ekdpar}\---or any other environment set to be inserted within 8027% \env{ekdpar}\---or any other environment set to be inserted within
@@ -8051,8 +8073,10 @@ local lemrdg = lpeg.Cs(lpeg.Cs("lem") + lpeg.Cs("rdg"))
8051local note = lpeg.Cs("note") 8073local note = lpeg.Cs("note")
8052local lnbrk = lpeg.Cs("\\\\") 8074local lnbrk = lpeg.Cs("\\\\")
8053local poemline = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.S("*!")^-1 * bsqbrackets^-1 * spcenc^-1) 8075local poemline = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.S("*!")^-1 * bsqbrackets^-1 * spcenc^-1)
8054local poemlineb = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.P("&gt;") * bsqbrackets^-1 * spcenc^-1) 8076local poemlinebreak = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.P("&gt;") * bsqbrackets^-1 * spcenc^-1)
8055local endpoem = lpeg.Cs(lnbrk * lpeg.S("*!") * bsqbrackets^-1) 8077local linegroup = lpeg.Cs{ "<lg" * ((1 - lpeg.S"<>") + lpeg.V(1))^0 * ">" }
8078local bclinegroup = lpeg.Cs(linegroup + lpeg.P("</lg>"))
8079local endpoem = lpeg.Cs(lnbrk * lpeg.S("*!") * bsqbrackets^-1) -- not used
8056local sections = lpeg.Cs(lpeg.P("book") + lpeg.P("part") + lpeg.P("chapter") 8080local sections = lpeg.Cs(lpeg.P("book") + lpeg.P("part") + lpeg.P("chapter")
8057 + lpeg.P("section") + lpeg.P("subsection") 8081 + lpeg.P("section") + lpeg.P("subsection")
8058 + lpeg.P("subsubsection")) 8082 + lpeg.P("subsubsection"))
@@ -8423,13 +8447,11 @@ local envtotags = {
8423 {a="flushright", b="p", c=" rend=\"align(right)\""}, 8447 {a="flushright", b="p", c=" rend=\"align(right)\""},
8424 {a="flushleft", b="p", c=" rend=\"align(left)\""}, 8448 {a="flushleft", b="p", c=" rend=\"align(left)\""},
8425 {a="quotation", b="quote", c=""}, 8449 {a="quotation", b="quote", c=""},
8426 {a="ekdverse", b="lg", c=""},
8427 {a="txarabtr", b="p", c=" xml:lang=\"ar-Latn\" type=\"transliterated\""}, 8450 {a="txarabtr", b="p", c=" xml:lang=\"ar-Latn\" type=\"transliterated\""},
8428 {a="quoting", b="quote", c=""}, 8451 {a="quoting", b="quote", c=""},
8429 {a="ekdpar", b="p", c=""}, 8452 {a="ekdpar", b="p", c=""},
8430 {a="txarab", b="p", c=" xml:lang=\"arb\""}, 8453 {a="txarab", b="p", c=" xml:lang=\"arb\""},
8431 {a="center", b="p", c=" rend=\"align(center)\""}, 8454 {a="center", b="p", c=" rend=\"align(center)\""},
8432 {a="verse", b="lg", c=""},
8433 {a="arab", b="p", 8455 {a="arab", b="p",
8434 c=" xml:lang=\"ar-Latn\" type=\"transliterated\" subtype=\"arabtex\""} 8456 c=" xml:lang=\"ar-Latn\" type=\"transliterated\" subtype=\"arabtex\""}
8435} 8457}
@@ -8647,37 +8669,66 @@ local function relocate_notes(str)
8647end 8669end
8648 8670
8649local function linestotei(str) 8671local function linestotei(str)
8650 str = "\n<l>"..str 8672 if not string.find(str, "^%s?<lg")
8651-- str = string.gsub(str, "^%s?(.-)\\\\[%!%*]?%s?$", "\n<l>%1</l>\n") 8673 then
8652 str = gsub(str, poemline * spcenc^-1 * -1, "</l>\n") 8674 str = "\n<l>"..str
8653-- str = gsub(str, endpoem, "</l>\n") 8675 end
8654 str = gsub(str, poemlineb, "<lb/> ") 8676 str = gsub(str, poemline * spcenc^-1 * bclinegroup, "</l>\n%2")
8677 str = gsub(str, linegroup * -(spcenc^-1 * bclinegroup), "%1\n<l>")
8678 str = gsub(str, lpeg.Cs("</lg>") * -(spcenc^-1 * (bclinegroup + -1)), "%1\n<l>")
8679 -- str = gsub(str, poemline * spcenc^-1 * -1, "</l>\n")
8680 str = gsub(str, poemlinebreak, "<lb/> ")
8681 -- str = gsub(str, poemline * spcenc^-1 * lpeg.Cs("<lg"), "</l>%2")
8682 -- str = gsub(str, lpeg.Cs("</lg>") * spcenc^1 * -lpeg.P("<l"), "%1\n<l>")
8655 str = gsub(str, poemline, "</l>\n<l>") 8683 str = gsub(str, poemline, "</l>\n<l>")
8656-- str = str.."</l>\n" 8684 return str
8685end
8686
8687local function stanzatotei(str)
8688 str = string.gsub(str, "\\begin%s?%{ekdstanza%}(%b[])(.-)\\end%s?%{ekdstanza%}", function(opt, arg)
8689 arg = string.gsub(arg, "\\par%s?", "")
8690 opt = string.sub(opt, 2, -2)
8691 teitype = get_attr_value(opt, "type")
8692 if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end
8693 if opt == ""
8694 then
8695 return string.format("<lg>%s</lg>", arg)
8696 else
8697 return string.format("<lg%s>%s</lg>", teitype, arg)
8698 end
8699 end)
8700 str = string.gsub(str, "\\begin%s?%{ekdstanza%}(.-)\\end%s?%{ekdstanza%}", function(arg)
8701 arg = string.gsub(arg, "\\par%s?", "")
8702 return string.format("<lg>%s</lg>", arg)
8703 end)
8657 return str 8704 return str
8658end 8705end
8659 8706
8660-- better use lpeg: look into this later 8707-- better use lpeg: look into this later
8661local function versetotei(str) 8708local function versetotei(str)
8662 str = string.gsub(str, "(\\begin%s?%{ekdverse%})(%b[])(.-)(\\end%s?%{ekdverse%})", function(benv, opt, arg, eenv) 8709 str = string.gsub(str, "\\begin%s?%{ekdverse%}(%b[])(.-)\\end%s?%{ekdverse%}", function(opt, arg)
8663 arg = string.gsub(arg, "\\par%s?", "") 8710 arg = string.gsub(arg, "\\par%s?", "")
8664 arg = linestotei(arg) 8711 opt = string.sub(opt, 2, -2)
8665 return string.format("%s%s%s%s", benv, opt, arg, eenv) 8712 teitype = get_attr_value(opt, "type")
8713 if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end
8714 if opt == ""
8715 then
8716 return "\\p@rb "..linestotei(string.format("<lg>%s</lg>", arg)).."\\p@ra "
8717 else
8718 return "\\p@rb "..linestotei(string.format("<lg%s>%s</lg>", teitype, arg)).."\\p@ra "
8719 end
8666 end) 8720 end)
8667 str = string.gsub(str, "(\\begin%s?%{ekdverse%})(.-)(\\end%s?%{ekdverse%})", function(benv, arg, eenv) 8721 str = string.gsub(str, "\\begin%s?%{ekdverse%}(.-)\\end%s?%{ekdverse%}", function(arg)
8668 arg = string.gsub(arg, "\\par%s?", "") 8722 arg = string.gsub(arg, "\\par%s?", "")
8669 arg = linestotei(arg) 8723 return "\\p@rb "..linestotei(string.format("<lg>%s</lg>", arg)).."\\p@ra "
8670 return string.format("%s%s%s", benv, arg, eenv)
8671 end) 8724 end)
8672 str = string.gsub(str, "(\\begin%s?%{verse%})(%b[])(.-)(\\end%s?%{verse%})", function(benv, opt, arg, eenv) 8725 str = string.gsub(str, "\\begin%s?%{verse%}%b[](.-)\\end%s?%{verse%}", function(arg)
8673 arg = string.gsub(arg, "\\par%s?", "") 8726 arg = string.gsub(arg, "\\par%s?", "")
8674 arg = linestotei(arg) 8727 return "\\p@rb "..linestotei(string.format("<lg>%s</lg>", arg)).."\\p@ra "
8675 return string.format("%s%s%s%s", benv, opt, arg, eenv)
8676 end) 8728 end)
8677 str = string.gsub(str, "(\\begin%s?%{verse%})(.-)(\\end%s?%{verse%})", function(benv, arg, eenv) 8729 str = string.gsub(str, "\\begin%s?%{verse%}(.-)\\end%s?%{verse%}", function(arg)
8678 arg = string.gsub(arg, "\\par%s?", "") 8730 arg = string.gsub(arg, "\\par%s?", "")
8679 arg = linestotei(arg) 8731 return "\\p@rb "..linestotei(string.format("<lg>%s</lg>", arg)).."\\p@ra "
8680 return string.format("%s%s%s", benv, arg, eenv)
8681 end) 8732 end)
8682 return str 8733 return str
8683end 8734end
@@ -9223,6 +9274,7 @@ local function textotei(str)
9223 str = rdgGrp_totei(str) 9274 str = rdgGrp_totei(str)
9224 str = lem_rdg_totei(str) 9275 str = lem_rdg_totei(str)
9225 str = relocate_notes(str) 9276 str = relocate_notes(str)
9277 str = stanzatotei(str)
9226 str = versetotei(str) 9278 str = versetotei(str)
9227 str = envtotei(str) 9279 str = envtotei(str)
9228 str = ekddivs_totei(str) 9280 str = ekddivs_totei(str)