aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2020-05-18 19:12:43 +0200
committerRobert Alessi <alessi@robertalessi.net>2020-05-18 19:12:43 +0200
commit5ffcc3045fb94a413bbe2d32e85fd993d23307f4 (patch)
treeb465a9e8e57e434d7ed1e3dc92ace089ac8c44a5
parent429ba52c5b17fa727ea7a5e79fc9cbbd0dfe2775 (diff)
downloadekdosis-5ffcc3045fb94a413bbe2d32e85fd993d23307f4.tar.gz
turn manually inserted xml:id into n attribute
-rw-r--r--ekdosis.dtx48
1 files 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 = {
1495 1495
1496local envtotags = { 1496local envtotags = {
1497 {a="ekdverse", b="lg", c=""}, 1497 {a="ekdverse", b="lg", c=""},
1498 {a="txarabtr", b="p", c=" xml:lang=\"arb-Latn\" type=\"transliterated\""}, 1498 {a="txarabtr", b="p", c=" xml:lang=\"ar-Latn\" type=\"transliterated\""},
1499 {a="txarab", b="p", c=" xml:lang=\"arb\""}, 1499 {a="txarab", b="p", c=" xml:lang=\"ar-arb\""},
1500 {a="center", b="p", c=" rend=\"centered\""}, 1500 {a="center", b="p", c=" rend=\"centered\""},
1501 {a="verse", b="lg", c=""}, 1501 {a="verse", b="lg", c=""},
1502 {a="arab", b="p", 1502 {a="arab", b="p",
1503 c=" xml:lang=\"arb-Latn\" type=\"transliterated\" subtype=\"arabtex\""} 1503 c=" xml:lang=\"ar-Latn\" type=\"transliterated\" subtype=\"arabtex\""}
1504} 1504}
1505 1505
1506local close_p = { 1506local close_p = {
@@ -1508,7 +1508,14 @@ local close_p = {
1508 "lg" 1508 "lg"
1509} 1509}
1510 1510
1511local forbid_xmlid = true
1512
1511function ekdosis.newcmdtotag(cmd, tag, attr) 1513function ekdosis.newcmdtotag(cmd, tag, attr)
1514 if forbid_xmlid
1515 then
1516 attr = string.gsub(attr, "xml:id", "n") -- xml:id is not allowed here
1517 else
1518 end
1512 if isintable(cmdtotags, cmd) 1519 if isintable(cmdtotags, cmd)
1513 then 1520 then
1514 local index = get_a_index(cmd, cmdtotags) 1521 local index = get_a_index(cmd, cmdtotags)
@@ -1531,6 +1538,11 @@ function ekdosis.newpatttotag(pat, repl)
1531end 1538end
1532 1539
1533function ekdosis.newenvtotag(env, tag, attr, closep) 1540function ekdosis.newenvtotag(env, tag, attr, closep)
1541 if forbid_xmlid
1542 then
1543 attr = string.gsub(attr, "xml:id", "n") -- xml:id is not allowed here
1544 else
1545 end
1534 if isintable(envtotags, env) 1546 if isintable(envtotags, env)
1535 then 1547 then
1536 local index = get_a_index(env, envtotags) 1548 local index = get_a_index(env, envtotags)
@@ -2359,6 +2371,11 @@ function ekdosis.mkenvdata(str, opt)
2359 local namediv = string.gsub(string.sub(str, fieldstart, nexti-1), "(%a+)%s-(%b[])", "%1") 2371 local namediv = string.gsub(string.sub(str, fieldstart, nexti-1), "(%a+)%s-(%b[])", "%1")
2360 local attr = string.gsub(string.sub(str, fieldstart, nexti-1), "(%a+)%s-(%b[])", "%2") 2372 local attr = string.gsub(string.sub(str, fieldstart, nexti-1), "(%a+)%s-(%b[])", "%2")
2361 attr = string.sub(attr, 2, -2) 2373 attr = string.sub(attr, 2, -2)
2374 if forbid_xmlid
2375 then
2376 attr = string.gsub(attr, "xml:id", "n") -- xml:id is not allowed here
2377 else
2378 end
2362 table.insert(aligned_texts, { text = namediv, 2379 table.insert(aligned_texts, { text = namediv,
2363 attribute = attr, 2380 attribute = attr,
2364 column = col }) 2381 column = col })
@@ -2500,24 +2517,21 @@ function ekdosis.mkenv()
2500 ..", \\luastringN{\\par#1\\par})}\\fi" 2517 ..", \\luastringN{\\par#1\\par})}\\fi"
2501 .."}") 2518 .."}")
2502 end 2519 end
2520 forbid_xmlid = false
2503 if aligned_texts[i].attribute ~= "" 2521 if aligned_texts[i].attribute ~= ""
2504 then 2522 then
2505 table.insert(environments, "\\EnvtoTEI{" 2523 ekdosis.newenvtotag(aligned_texts[i].text, "div",
2506 .. aligned_texts[i].text 2524 "xml:id=\""
2507 .."}{div}" 2525 ..build_envdiv(aligned_texts[i].text)
2508 .."[xml:id=\"" 2526 .."\" "
2509 .. build_envdiv(aligned_texts[i].text) 2527 ..aligned_texts[i].attribute)
2510 .. "\" "
2511 .. aligned_texts[i].attribute
2512 .. "]")
2513 else 2528 else
2514 table.insert(environments, "\\EnvtoTEI{" 2529 ekdosis.newenvtotag(aligned_texts[i].text, "div",
2515 .. aligned_texts[i].text 2530 "xml:id=\""
2516 .."}{div}" 2531 ..build_envdiv(aligned_texts[i].text)
2517 .."[xml:id=\"" 2532 .."\"")
2518 .. build_envdiv(aligned_texts[i].text)
2519 .. "\"]")
2520 end 2533 end
2534 forbid_xmlid = true
2521 end 2535 end
2522 str = table.concat(environments) 2536 str = table.concat(environments)
2523 return str 2537 return str