From 5ffcc3045fb94a413bbe2d32e85fd993d23307f4 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Mon, 18 May 2020 19:12:43 +0200 Subject: turn manually inserted xml:id into n attribute --- ekdosis.dtx | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/ekdosis.dtx b/ekdosis.dtx index 229c4c7..9c6a878 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -1495,12 +1495,12 @@ local texpatttotags = { local envtotags = { {a="ekdverse", b="lg", c=""}, - {a="txarabtr", b="p", c=" xml:lang=\"arb-Latn\" type=\"transliterated\""}, - {a="txarab", b="p", c=" xml:lang=\"arb\""}, + {a="txarabtr", b="p", c=" xml:lang=\"ar-Latn\" type=\"transliterated\""}, + {a="txarab", b="p", c=" xml:lang=\"ar-arb\""}, {a="center", b="p", c=" rend=\"centered\""}, {a="verse", b="lg", c=""}, {a="arab", b="p", - c=" xml:lang=\"arb-Latn\" type=\"transliterated\" subtype=\"arabtex\""} + c=" xml:lang=\"ar-Latn\" type=\"transliterated\" subtype=\"arabtex\""} } local close_p = { @@ -1508,7 +1508,14 @@ local close_p = { "lg" } +local forbid_xmlid = true + function ekdosis.newcmdtotag(cmd, tag, attr) + if forbid_xmlid + then + attr = string.gsub(attr, "xml:id", "n") -- xml:id is not allowed here + else + end if isintable(cmdtotags, cmd) then local index = get_a_index(cmd, cmdtotags) @@ -1531,6 +1538,11 @@ function ekdosis.newpatttotag(pat, repl) end function ekdosis.newenvtotag(env, tag, attr, closep) + if forbid_xmlid + then + attr = string.gsub(attr, "xml:id", "n") -- xml:id is not allowed here + else + end if isintable(envtotags, env) then local index = get_a_index(env, envtotags) @@ -2359,6 +2371,11 @@ function ekdosis.mkenvdata(str, opt) local namediv = string.gsub(string.sub(str, fieldstart, nexti-1), "(%a+)%s-(%b[])", "%1") local attr = string.gsub(string.sub(str, fieldstart, nexti-1), "(%a+)%s-(%b[])", "%2") attr = string.sub(attr, 2, -2) + if forbid_xmlid + then + attr = string.gsub(attr, "xml:id", "n") -- xml:id is not allowed here + else + end table.insert(aligned_texts, { text = namediv, attribute = attr, column = col }) @@ -2500,24 +2517,21 @@ function ekdosis.mkenv() ..", \\luastringN{\\par#1\\par})}\\fi" .."}") end + forbid_xmlid = false if aligned_texts[i].attribute ~= "" then - table.insert(environments, "\\EnvtoTEI{" - .. aligned_texts[i].text - .."}{div}" - .."[xml:id=\"" - .. build_envdiv(aligned_texts[i].text) - .. "\" " - .. aligned_texts[i].attribute - .. "]") + ekdosis.newenvtotag(aligned_texts[i].text, "div", + "xml:id=\"" + ..build_envdiv(aligned_texts[i].text) + .."\" " + ..aligned_texts[i].attribute) else - table.insert(environments, "\\EnvtoTEI{" - .. aligned_texts[i].text - .."}{div}" - .."[xml:id=\"" - .. build_envdiv(aligned_texts[i].text) - .. "\"]") + ekdosis.newenvtotag(aligned_texts[i].text, "div", + "xml:id=\"" + ..build_envdiv(aligned_texts[i].text) + .."\"") end + forbid_xmlid = true end str = table.concat(environments) return str -- cgit v1.2.3