aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ekdosis.dtx69
1 files changed, 49 insertions, 20 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 6b9b15f..8181714 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -757,6 +757,9 @@ local lnbrk = lpeg.Cs("\\\\")
757local poemline = lpeg.Cs(lnbrk * bsqbrackets^-1) 757local poemline = lpeg.Cs(lnbrk * bsqbrackets^-1)
758local endpoem = lpeg.Cs(lnbrk * lpeg.S("*!") * bsqbrackets^-1) 758local endpoem = lpeg.Cs(lnbrk * lpeg.S("*!") * bsqbrackets^-1)
759 759
760-- Bind to local variables
761local next = next
762
760-- Booleans 763-- Booleans
761local tei_p_open = false 764local tei_p_open = false
762 765
@@ -1361,17 +1364,46 @@ ekdosis.getabspg = function(pg) --not used
1361 end 1364 end
1362end 1365end
1363 1366
1364local function mdvisintable(table, value) 1367-- handle multiple layers in apparatuses
1365 for _, v in pairs(table) do 1368--
1366 if v == value then return true end 1369local apparatuses = {}
1370function ekdosis.newapparatus(teitype, cmd)
1371 if cmd ~= "app" or "note"
1372 then
1373 -- tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]]
1374 -- .. [[The string `]] ..
1375 -- .. cmd ..
1376 -- [["' must be either `app' or `note'.}}]])
1377 else
1378 if isintable(apparatuses, teitype)
1379 then
1380 -- tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]]
1381 -- .. teitype ..
1382 -- [[" already exists as an apparatus. ]]
1383 -- ..
1384 -- [[Please pick another teitype.}}]])
1385 else
1386 table.insert(apparatuses, { a = teitype, b = cmd })
1387 end
1367 end 1388 end
1368 return false 1389 return true
1369end 1390end
1370 1391
1371 1392function ekdosis.appin(str, teitype)
1372function ekdosis.appin(str)
1373 local f = io.open(tex.jobname.."_tmp.ekd", "a+") 1393 local f = io.open(tex.jobname.."_tmp.ekd", "a+")
1374 f:write("<", cur_abs_pg, ">", str, "</", cur_abs_pg, ">\n") 1394 if next(apparatuses) == nil
1395 then
1396 f:write("<", cur_abs_pg, "-0>", str, "</", cur_abs_pg, "-0>\n")
1397 else
1398 for i = 1,#apparatuses
1399 do
1400 if apparatuses[i].a == teitype then
1401 local appno = i
1402 break
1403 end
1404 end
1405 f:write("<", cur_abs_pg, "-", appno, ">", str, "</", cur_abs_pg, "-", appno, ">\n")
1406 end
1375 f:close() 1407 f:close()
1376 return true 1408 return true
1377end 1409end
@@ -1396,24 +1428,14 @@ function ekdosis.appout()
1396 t = f:read("*a") 1428 t = f:read("*a")
1397 local output = {} 1429 local output = {}
1398 for i in string.gmatch(t, 1430 for i in string.gmatch(t,
1399 "<T"..cur_abs_pg..">.-</T"..cur_abs_pg..">") 1431 "<"..cur_abs_pg.."%-0>.-</"..cur_abs_pg.."%-0>")
1400 do
1401 table.insert(output, i)
1402 end
1403 if string.find(t, "<T"..cur_abs_pg..">")
1404 then
1405 table.insert(output, "<T"..cur_abs_pg..">\\par</T"..cur_abs_pg..">")
1406 else
1407 end
1408 for i in string.gmatch(t,
1409 "<"..cur_abs_pg..">.-</"..cur_abs_pg..">")
1410 do 1432 do
1411 table.insert(output, i) 1433 table.insert(output, i)
1412 end 1434 end
1413 f:close() 1435 f:close()
1414 str = table.concat(output) 1436 str = table.concat(output)
1415 str = string.gsub(str, "</[A-Z0-9]?"..cur_abs_pg..">", "") 1437 str = string.gsub(str, "</"..cur_abs_pg.."%-0>", "")
1416 str = string.gsub(str, "<[A-Z0-9]?"..cur_abs_pg..">", " ") 1438 str = string.gsub(str, "<"..cur_abs_pg.."%-0>", " ")
1417 return str 1439 return str
1418 else end 1440 else end
1419end 1441end
@@ -1438,6 +1460,13 @@ local prev_lnlab = nil
1438local current_lemma = nil 1460local current_lemma = nil
1439local salt = 0 1461local salt = 0
1440 1462
1463local function mdvisintable(table, value)
1464 for _, v in pairs(table) do
1465 if v == value then return true end
1466 end
1467 return false
1468end
1469
1441function ekdosis.dolnlab(str) 1470function ekdosis.dolnlab(str)
1442 prev_lnlab = current_lnlab 1471 prev_lnlab = current_lnlab
1443 current_lemma = str 1472 current_lemma = str