aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2021-05-28 12:38:48 +0200
committerRobert Alessi <alessi@robertalessi.net>2021-05-28 12:38:48 +0200
commit8a3b5fe36fca8b7450a4b7a2545436201eba83be (patch)
treef8b953e7cac20317c518734d73521c1d3d40520b
parentcab7c761251e1ffd798ee6477950911248338f55 (diff)
downloadekdosis-8a3b5fe36fca8b7450a4b7a2545436201eba83be.tar.gz
use lpeg to relocate anchors. adapted frontier pattern to handle dots, hyphens and underscores in xml:ids
-rw-r--r--ekdosis.dtx14
1 files changed, 8 insertions, 6 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index b51cf53..7e24140 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -61,7 +61,7 @@ along with this program. If not, see
61%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] 61%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
62%<package>\ProvidesPackage{ekdosis} 62%<package>\ProvidesPackage{ekdosis}
63%<*package> 63%<*package>
64 [2021/05/27 v1.3-dev Typesetting TEI xml-compliant critical editions] 64 [2021/05/28 v1.3-dev Typesetting TEI xml-compliant critical editions]
65%</package> 65%</package>
66%<*driver> 66%<*driver>
67\begin{filecontents}[noheader,overwrite]{bibdata.xml} 67\begin{filecontents}[noheader,overwrite]{bibdata.xml}
@@ -7507,7 +7507,7 @@ Sample text with a \textcolor{red}{word} in red.
7507% \end{macrocode} 7507% \end{macrocode}
7508% \end{macro} 7508% \end{macro}
7509% \begin{macro}{\teidirect} 7509% \begin{macro}{\teidirect}
7510% \changes{v1.3}{2021/05/27}{direct insertion of elements in the 7510% \changes{v1.3}{2021/05/28}{direct insertion of elements in the
7511% \texttt{TEI xml} file} 7511% \texttt{TEI xml} file}
7512% \cs{teidirect}\oarg{xml attributes}\marg{xml element}\marg{code} 7512% \cs{teidirect}\oarg{xml attributes}\marg{xml element}\marg{code}
7513% does nothing in \LaTeX. Its only use is to insert elements in the 7513% does nothing in \LaTeX. Its only use is to insert elements in the
@@ -7866,7 +7866,7 @@ Sample text with a \textcolor{red}{word} in red.
7866% \end{macrocode} 7866% \end{macrocode}
7867% \end{macro} 7867% \end{macro}
7868% \begin{macro}{\SetApparatusNoteLanguage} 7868% \begin{macro}{\SetApparatusNoteLanguage}
7869% \changes{v1.3}{2021/05/27}{defines an alternate language to be 7869% \changes{v1.3}{2021/05/28}{defines an alternate language to be
7870% applied in note apparatus entries} 7870% applied in note apparatus entries}
7871% \cs{SetApparatusNoteLang}\marg{languagename} can be used when 7871% \cs{SetApparatusNoteLang}\marg{languagename} can be used when
7872% it is needed to apply in entries introduced by the \cs{note} command 7872% it is needed to apply in entries introduced by the \cs{note} command
@@ -9397,6 +9397,8 @@ local app = lpeg.Cs("app")
9397local lemrdg = lpeg.Cs(lpeg.Cs("lem") + lpeg.Cs("rdg")) 9397local lemrdg = lpeg.Cs(lpeg.Cs("lem") + lpeg.Cs("rdg"))
9398local note = lpeg.Cs("note") 9398local note = lpeg.Cs("note")
9399local inlem = lpeg.Cs{ "<lem" * ((1 - (lpeg.P"<lem" + lpeg.P"</lem>")) + lpeg.V(1))^0 * "</lem>" } 9399local inlem = lpeg.Cs{ "<lem" * ((1 - (lpeg.P"<lem" + lpeg.P"</lem>")) + lpeg.V(1))^0 * "</lem>" }
9400local inanchor = lpeg.Cs{ "<anchor" * ((1 - (lpeg.P"<" + lpeg.P">")) + lpeg.V(1))^0 * ">" }
9401local inopeningnote = lpeg.Cs{ "<note" * ((1 - (lpeg.P"<" + lpeg.P">")) + lpeg.V(1))^0 * ">" }
9400local lnbrk = lpeg.Cs("\\\\") 9402local lnbrk = lpeg.Cs("\\\\")
9401local poemline = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.S("*!")^-1 * bsqbrackets^-1 * spcenc^-1) 9403local poemline = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.S("*!")^-1 * bsqbrackets^-1 * spcenc^-1)
9402local poemlinebreak = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.P("&gt;") * bsqbrackets^-1 * spcenc^-1) 9404local poemlinebreak = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.P("&gt;") * bsqbrackets^-1 * spcenc^-1)
@@ -9708,7 +9710,7 @@ function ekdosis.getsiglum(str, opt)
9708 str = string.gsub(str, shorthands[i].a, shorthands[i].c) 9710 str = string.gsub(str, shorthands[i].a, shorthands[i].c)
9709 end 9711 end
9710 for i = 1,#idsRend do 9712 for i = 1,#idsRend do
9711 str = string.gsub(str, "(%f[%w])"..idsRend[i].xmlid.."(%,)", 9713 str = string.gsub(str, "(%f[%w%.%-%_])"..idsRend[i].xmlid.."(%,)",
9712 "%1#"..idsRend[i].xmlid.."%2") 9714 "%1#"..idsRend[i].xmlid.."%2")
9713 ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "") 9715 ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "")
9714 end 9716 end
@@ -9747,7 +9749,7 @@ local cmdtotags = {
9747 {a="textsf", b="hi", c=" rend=\"sf\""}, 9749 {a="textsf", b="hi", c=" rend=\"sf\""},
9748 {a="arbup", b="hi", c=" rend=\"sup\""}, 9750 {a="arbup", b="hi", c=" rend=\"sup\""},
9749 {a="txarb", b="s", c=" xml:lang=\"arb\""}, 9751 {a="txarb", b="s", c=" xml:lang=\"arb\""},
9750 {a="arb", b="foreign", 9752 {a="arb", b="span",
9751 c=" xml:lang=\"ar-Latn\" type=\"transliterated\" subtype=\"arabtex\""} 9753 c=" xml:lang=\"ar-Latn\" type=\"transliterated\" subtype=\"arabtex\""}
9752} 9754}
9753 9755
@@ -9920,7 +9922,7 @@ local function note_totei(str)
9920end 9922end
9921 9923
9922local function remove_extra_anchors(str) 9924local function remove_extra_anchors(str)
9923 str = string.gsub(str, "(</note>)(<anchor.->)(<note.->)", function(enote, anchor, bnote) 9925 str = gsub(str, lpeg.Cs("</note>") * inanchor * inopeningnote, function(enote, anchor, bnote)
9924 local id_one = string.gsub(anchor, "(%<anchor )(.-)(/%>)", "%2") 9926 local id_one = string.gsub(anchor, "(%<anchor )(.-)(/%>)", "%2")
9925 id_one = string.sub(get_attr_value(id_one, "xml:id"), 2, -2) 9927 id_one = string.sub(get_attr_value(id_one, "xml:id"), 2, -2)
9926 local id_two = string.match(bnote, "target%=.-right%((.-)%)") 9928 local id_two = string.match(bnote, "target%=.-right%((.-)%)")