aboutsummaryrefslogtreecommitdiff
path: root/ekdosis.dtx
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2019-10-01 20:23:50 +0200
committerRobert Alessi <alessi@robertalessi.net>2019-10-01 20:23:50 +0200
commit28d29e5bd799ebc2e3dc7fad1eee9b26b4a4ab65 (patch)
treee9f00f7bfdc0628fa2108578c10fe4036c95f2e0 /ekdosis.dtx
parentde54b3d6eb2f5560ec82bb431478b38defe1146a (diff)
downloadekdosis-28d29e5bd799ebc2e3dc7fad1eee9b26b4a4ab65.tar.gz
added note_totei()
Diffstat (limited to 'ekdosis.dtx')
-rw-r--r--ekdosis.dtx60
1 files changed, 60 insertions, 0 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 9518bf0..fd1768e 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -938,6 +938,7 @@ idno={}, msName={}, origDate={}][3]{%
938% \fi 938% \fi
939% \begin{ekdlua} 939% \begin{ekdlua}
940 940
941-- This table will hold the functions:
941ekdosis = {} 942ekdosis = {}
942 943
943-- lpeg equivalent for string.gsub() 944-- lpeg equivalent for string.gsub()
@@ -963,6 +964,7 @@ local aftercmd = lpeg.Cs(lpeg.S("*[{,.?;:'`\"") + dblbkslash)
963local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1) 964local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1)
964local app = lpeg.Cs("app") 965local app = lpeg.Cs("app")
965local lemrdg = lpeg.Cs(lpeg.Cs("lem") + lpeg.Cs("rdg")) 966local lemrdg = lpeg.Cs(lpeg.Cs("lem") + lpeg.Cs("rdg"))
967local note = lpeg.Cs("note")
966local lnbrk = lpeg.Cs("\\\\") 968local lnbrk = lpeg.Cs("\\\\")
967local poemline = lpeg.Cs(lnbrk * bsqbrackets^-1) 969local poemline = lpeg.Cs(lnbrk * bsqbrackets^-1)
968local endpoem = lpeg.Cs(lnbrk * lpeg.S("*!") * bsqbrackets^-1) 970local endpoem = lpeg.Cs(lnbrk * lpeg.S("*!") * bsqbrackets^-1)
@@ -1227,6 +1229,62 @@ local function xml_entities(str)
1227 return str 1229 return str
1228end 1230end
1229 1231
1232local function note_totei(str)
1233 str = gsub(str,
1234 dblbkslash *
1235 note *
1236 spcenc^-1 *
1237 bsqbrackets *
1238 bcbraces *
1239 spcenc^-1,
1240 function(bkslash, cmd, opt, arg)
1241 opt = string.sub(opt, 2, -2)
1242 arg = string.sub(arg, 2, -2)
1243 teitype = string.match(opt, "%f[%w]type%s?%=%s?%b{}")
1244 or string.match(opt, "%f[%w]type%s?%=%s?%w+%f[%W]")
1245 or ""
1246 teitype = string.gsub(teitype, "type%s?%=%s?(%b{})", function(bbraces)
1247 bbraces = string.sub(bbraces, 2, -2)
1248 return string.format("%s", bbraces)
1249 end)
1250 teitype = string.gsub(teitype, "(type%s?%=%s?)(%w+%f[%W])", "%2")
1251 right = string.match(opt, "%f[%w]labelb%s?%=%s?%b{}")
1252 or string.match(opt, "%f[%w]labelb%s?%=%s?%w+%f[%W]")
1253 or ""
1254 right = string.gsub(right, "labelb%s?%=%s?(%b{})", function(bbraces)
1255 bbraces = string.sub(bbraces, 2, -2)
1256 return string.format("%s", bbraces)
1257 end)
1258 right = string.gsub(right, "(labelb%s?%=%s?)(%w+%f[%W])", "%2")
1259 left = string.match(opt, "%f[%w]labele%s?%=%s?%b{}")
1260 or string.match(opt, "%f[%w]labele%s?%=%s?%w+%f[%W]")
1261 or ""
1262 left = string.gsub(left, "labele%s?%=%s?(%b{})", function(bbraces)
1263 bbraces = string.sub(bbraces, 2, -2)
1264 return string.format("%s", bbraces)
1265 end)
1266 left = string.gsub(left, "(labele%s?%=%s?)(%w+%f[%W])", "%2")
1267
1268 if left ~= "" and teitype ~= ""
1269 then
1270 return string.format("<%s type=\"%s\" target=\"#range(right(%s),left(%s))\">%s</%s>",
1271 cmd, teitype, right, left, arg, cmd)
1272 elseif left ~= "" and teitype == ""
1273 then
1274 return string.format("<%s target=\"#range(right(%s),left(%s))\">%s</%s>",
1275 cmd, right, left, arg, cmd)
1276 elseif left == "" and teitype ~= ""
1277 then
1278 return string.format("<%s type=\"%s\" target=\"#right(%s)\">%s</%s>",
1279 cmd, teitype, right, arg, cmd)
1280 else
1281 return string.format("<%s target=\"#right(%s)\">%s</%s>",
1282 cmd, right, arg, cmd)
1283 end
1284 end)
1285 return str
1286end
1287
1230local function app_totei(str) 1288local function app_totei(str)
1231 str = gsub(str, 1289 str = gsub(str,
1232 dblbkslash * 1290 dblbkslash *
@@ -1284,6 +1342,7 @@ local function lem_rdg_totei(str)
1284 arg = string.sub(arg, 2, -2) 1342 arg = string.sub(arg, 2, -2)
1285 return lem_rdg_totei(string.format("<%s>%s</%s>", cmd, arg, cmd)) 1343 return lem_rdg_totei(string.format("<%s>%s</%s>", cmd, arg, cmd))
1286 end) 1344 end)
1345 str = string.gsub(str, "(%<lem.-%>.-)(%<note.-%<%/note%>)(.-%<%/lem%>)", "%1%3%2")
1287 return str 1346 return str
1288end 1347end
1289 1348
@@ -1385,6 +1444,7 @@ local function textotei(str)
1385 str = string.gsub(str, "%s?\\par%s?", "\n<p>") 1444 str = string.gsub(str, "%s?\\par%s?", "\n<p>")
1386 tei_p_open = true 1445 tei_p_open = true
1387 end 1446 end
1447 str = note_totei(str)
1388 str = app_totei(str) 1448 str = app_totei(str)
1389 str = lem_rdg_totei(str) 1449 str = lem_rdg_totei(str)
1390 str = versetotei(str) 1450 str = versetotei(str)