From 742bf06a770c21faff9ee1e61459d97f4b0a758d Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 18 Aug 2021 20:47:26 +0000 Subject: ekdosis (18aug21) git-svn-id: svn://tug.org/texlive/trunk@60271 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.lua | 241 +++++++++++-- Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.sty | 394 ++++++++++++++++----- 2 files changed, 517 insertions(+), 118 deletions(-) (limited to 'Master/texmf-dist/tex/lualatex') diff --git a/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.lua b/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.lua index 4916d9c586b..f5f9bd22c41 100644 --- a/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.lua +++ b/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.lua @@ -51,6 +51,9 @@ local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1) local app = lpeg.Cs("app") local lemrdg = lpeg.Cs(lpeg.Cs("lem") + lpeg.Cs("rdg")) local note = lpeg.Cs("note") +local inlem = lpeg.Cs{ "")) + lpeg.V(1))^0 * "" } +local inanchor = lpeg.Cs{ "")) + lpeg.V(1))^0 * ">" } +local inopeningnote = lpeg.Cs{ "")) + lpeg.V(1))^0 * ">" } local lnbrk = lpeg.Cs("\\\\") local poemline = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.S("*!")^-1 * bsqbrackets^-1 * spcenc^-1) local poemlinebreak = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.P(">") * bsqbrackets^-1 * spcenc^-1) @@ -107,7 +110,7 @@ end local function checkxmlid(str) if string.find(str, "^[0-9]") - or string.find(str, "[:; ]") + or string.find(str, "[%{%}%[%]%(%):; ]") then return false else @@ -174,7 +177,8 @@ function ekdosis.newwitness(id, Collection, Idno, MsName, - OrigDate) + OrigDate, + Locus) if xmlidfound(id) then tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" @@ -210,6 +214,10 @@ function ekdosis.newwitness(id, listWit[indexwit].history = {} listWit[indexwit].history.origin = {origDate = OrigDate} end + if Locus ~= "" then + listWit[indexwit].msContents = {} + listWit[indexwit].msContents.msItemStruct = {locus = Locus} + end end return true end @@ -354,19 +362,22 @@ function ekdosis.getsiglum(str, opt) ctrl = str if opt == "tei" then for i = 1,#shorthands do - str = string.gsub(str, shorthands[i].a, shorthands[i].c) + local tempa = string.gsub(shorthands[i].a, "([%-%.%_])", "%%%1") + str = string.gsub(str, tempa, shorthands[i].c) end for i = 1,#idsRend do - str = string.gsub(str, "(%f[%w])"..idsRend[i].xmlid.."(%,)", + local tempb = string.gsub(idsRend[i].xmlid, "([%-%.%_])", "%%%1") + str = string.gsub(str, "(%f[%w%-%.%_])"..tempb.."(%,)", "%1#"..idsRend[i].xmlid.."%2") - ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "") + ctrl = string.gsub(ctrl, tempb.."%,", "") end str = string.gsub(str, "%,(%s-)([%#])", " %2") str = string.gsub(str, "%,$", "") else for i = 1,#idsRend do - str = string.gsub(str, idsRend[i].xmlid.."%,", idsRend[i].abbr) - ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "") + local tempc = string.gsub(idsRend[i].xmlid, "([%-%.%_])", "%%%1") + str = string.gsub(str, tempc.."%,", idsRend[i].abbr) + ctrl = string.gsub(ctrl, tempc.."%,", "") end end -- if string.find(ctrl, "[A-Za-z0-9]") @@ -389,14 +400,18 @@ local cmdtotags = { {a="marginpar", b="note", c=" place=\"margin\""}, {a="footnote", b="note", c=" place=\"bottom\""}, {a="enquote", b="quote", c=""}, + {a="prname *", b="span", + c=" xml:lang=\"ar-Latn\" type=\"transliterated\""}, + {a="prname", b="span", + c=" xml:lang=\"ar-Latn\" type=\"transliterated\" subtype=\"arabtex\""}, {a="txtrans", b="s", c=" xml:lang=\"ar-Latn\" type=\"transliterated\""}, {a="textbf", b="hi", c=" rend=\"bold\""}, {a="textit", b="hi", c=" rend=\"italic\""}, {a="textsc", b="hi", c=" rend=\"smallcaps\""}, {a="textsf", b="hi", c=" rend=\"sf\""}, {a="arbup", b="hi", c=" rend=\"sup\""}, - {a="txarb", b="s", c=" xml:lang=\"arb\""}, - {a="arb", b="foreign", + {a="txarb", b="foreign", c=" xml:lang=\"arb\""}, + {a="arb", b="span", c=" xml:lang=\"ar-Latn\" type=\"transliterated\" subtype=\"arabtex\""} } @@ -408,22 +423,31 @@ local texpatttotags = { {a="\\resetvlinenumber%s+", b=""}, {a="\\resetlinenumber%s+%[(.-)%]", b=""}, {a="\\resetlinenumber%s+", b=""}, + {a="\\ekdresethfmarks%s+", b=""}, {a="\\indentpattern%s+{(.-)}", b=""}, + {a="\\ekdnohfmark%s+", b=""}, {a="\\settowidth%s+{(.-)}{(.-)}", b=""}, {a="\\poemlines%s+{(.-)}", b=""}, {a="\\pagebreak%s+%[[1-4]%]", b=""}, {a="\\pagebreak%s+", b=""}, + {a="\\teidirect%s+(%b[]){(.-)}(%b{})", b="<%2 ekd@os%1ekd@cs>ekd@ob%3ekd@cb"}, + {a="\\teidirect%s+{(.-)}(%b{})", b="<%1>ekd@ob%2ekd@cb"}, {a="\\altrfont%s+", b=""}, - {a="\\mbox%s+{(.-)}", b="%1"}, - {a="\\LR%s+{(.-)}", b="%1"}, - {a="\\RL%s+{(.-)}", b="%1"}, + {a="\\endmark%s+", b=""}, + {a="\\ekdpb%s+%*?%[(.-)%]{(.-)}", b=""}, + {a="\\ekdpb%s+%*?{(.-)}", b=""}, + {a="\\ekdpb%s+%*\\?", b=""}, + {a="\\mbox%s+(%b{})", b="ekd@ob%1ekd@cb"}, + {a="\\LR%s+(%b{})", b="ekd@ob%1ekd@cb"}, + {a="\\RL%s+(%b{})", b="ekd@ob%1ekd@cb"}, {a="\\%=%=%=%s?", b="—"}, {a="\\%-%-%-%s?", b="—"}, {a="\\%=%=%s?", b="–"}, {a="\\%-%-%s?", b="–"}, {a="\\%=%/%s?", b="‐"}, {a="\\%-%/%s?", b="‐"}, - {a="\\vin%s+", b=""} + {a="\\vin%s+", b=""}, + {a="\\uc%s+(%b{})", b="ekd@ob%1ekd@cb"} } local envtotags = { @@ -467,8 +491,12 @@ end function ekdosis.newpatttotag(pat, repl) pat = string.gsub(pat, "([%[%]])", "%%%1") + pat = string.gsub(pat, "%@b[1-9]", "(%%b{})") + pat = string.gsub(pat, "%@s[1-9]", "(%%b[])") pat = string.gsub(pat, "%#[1-9]", "(.-)") repl = string.gsub(repl, "%#([1-9])", "%%%1") + repl = string.gsub(repl, "%@b([1-9])", "ekd@ob%%%1ekd@cb") + repl = string.gsub(repl, "%@s([1-9])", "ekd@os%%%1ekd@cs") if isintable(texpatttotags, pat) then local index = get_a_index(pat, texpatttotags) @@ -561,6 +589,22 @@ local function note_totei(str) return str end +local function remove_extra_anchors(str) + str = gsub(str, lpeg.Cs("") * inanchor * inopeningnote, function(enote, anchor, bnote) + local id_one = string.gsub(anchor, "(%)", "%2") + id_one = string.sub(get_attr_value(id_one, "xml:id"), 2, -2) + local id_two = string.match(bnote, "target%=.-right%((.-)%)") + id_two = string.gsub(id_two, ".-right%((.-)%)", "%1") + if id_one == id_two + then + return string.format("%s%s", enote, bnote) + else + return string.format("%s%s%s", enote, anchor, bnote) + end + end) + return str +end + local function app_totei(str) str = gsub(str, dblbkslash * @@ -647,7 +691,16 @@ local function lem_rdg_totei(str) end local function relocate_notes(str) - str = string.gsub(str, "(%.-)(%.-%<%/note%>)(.-%<%/lem%>)", "%1%3%2") + str = gsub(str, inlem, function(arg) + local notes = {} + for i in string.gmatch(arg, "%.-%<%/note%>") + do + table.insert(notes, i) + end + allnotes = table.concat(notes) + arg = string.gsub(arg, "%.-%<%/note%>", "") + return string.format("%s%s", arg, allnotes) + end) return str end @@ -766,6 +819,10 @@ end local function texpatttotei(str) for i = 1,#texpatttotags do str = string.gsub(str, texpatttotags[i].a, texpatttotags[i].b) + str = string.gsub(str, "ekd@ob%{", "") + str = string.gsub(str, "%}ekd@cb", "") + str = string.gsub(str, "ekd@os%[", "") + str = string.gsub(str, "%]ekd@cs", "") end return str end @@ -791,7 +848,8 @@ local function icitetotei(str) "Please pick another id.}}") else end - return string.format("%s %s", pre, body, post) + return string.format("%s %s", + pre, body, post) end) str = gsub(str, lpeg.P("\\") * citecmds @@ -811,7 +869,7 @@ local function icitetotei(str) "Please pick another id.}}") else end - return string.format("%s", body, post) + return string.format("%s", body, post) end) str = gsub(str, lpeg.P("\\") * citecmds @@ -967,6 +1025,86 @@ local function self_close_tags(str) return str end +--headers and footers +local hfmarks = {} + +function ekdosis.storehfmark(page, mk, opt) + if opt == "endmk" + then + local emark = hfmarks[#hfmarks].mark + table.insert(hfmarks, {a = page, mark = emark}) + else + table.insert(hfmarks, {a = page, mark = mk}) + end + return true +end + +local printhfmarks = { + HEL = true, + HEC = true, + HER = true, + HOL = true, + HOC = true, + HOR = true, + FOL = true, + FOC = true, + FOR = true, + FEL = true, + FEC = true, + FER = true, +} + +function ekdosis.nohfmark() + printhfmarks.HEL = false + printhfmarks.HEC = false + printhfmarks.HER = false + printhfmarks.HOL = false + printhfmarks.HOC = false + printhfmarks.HOR = false + printhfmarks.FOL = false + printhfmarks.FOC = false + printhfmarks.FOR = false + printhfmarks.FEL = false + printhfmarks.FEC = false + printhfmarks.FER = false +end + +function ekdosis.resethfmark() + printhfmarks.HEL = true + printhfmarks.HEC = true + printhfmarks.HER = true + printhfmarks.HOL = true + printhfmarks.HOC = true + printhfmarks.HOR = true + printhfmarks.FOL = true + printhfmarks.FOC = true + printhfmarks.FOR = true + printhfmarks.FEL = true + printhfmarks.FEC = true + printhfmarks.FER = true +end + +function ekdosis.printmark(str, mk) + if printhfmarks[mk] + then + return str + else + printhfmarks[mk] = true + return "" + end +end + +function ekdosis.gethfmark(page) + local indexpage = get_a_index(page, hfmarks) + if hfmarks[indexpage] ~= nil + then + return hfmarks[indexpage].mark + else + return hfmarks[#hfmarks-1].mark or "" + end +end + +-- divisions of the body text local divdepth = { book = 1, part = 2, @@ -1175,7 +1313,7 @@ end local function close_ekddivs_in_between(str) local maxdepth = 1 - for i in string.gmatch(str, "", "%1") + for i in string.gmatch(str, "", "%1") do if tonumber(i) > tonumber(maxdepth) then @@ -1200,9 +1338,9 @@ local function close_ekddivs_in_between(str) do closedivs = closedivs.."" firstdivindex = firstdivindex - 1 + bdivii = string.gsub(bdivii, "depth", "Depth") end end - bdivii = string.gsub(bdivii, "depth", "Depth") return string.format("%s%s%s%s%s%s%s%s", bdivi, ndivi, edivi, between, closedivs, bdivii, ndivii, edivii) @@ -1235,9 +1373,9 @@ local function close_ndivs_in_between(str) do closedivs = closedivs.."" firstdivindex = firstdivindex - 1 + bdivii = string.gsub(bdivii, "div", "Div") end end - bdivii = string.gsub(bdivii, "div", "Div") return string.format("%s%s%s%s%s%s%s%s", bdivi, ndivi, edivi, between, closedivs, bdivii, ndivii, edivii) @@ -1256,6 +1394,7 @@ local function textotei(str) str = xml_entities(str) str = texpatttotei(str) str = note_totei(str) + str = remove_extra_anchors(str) str = app_totei(str) str = rdgGrp_totei(str) str = lem_rdg_totei(str) @@ -1364,7 +1503,14 @@ function ekdosis.openteistream() end f:write("", "\n") f:write("", "\n") - else end + else end + if listWit[i].msContents ~= nil then + f:write("", "\n") + f:write("", "\n") + f:write("", textotei(listWit[i].msContents.msItemStruct.locus), "", "\n") + f:write("", "\n") + f:write("", "\n") + end if listWit[i].history ~= nil then f:write("", "\n") f:write("", "\n") @@ -1505,7 +1651,15 @@ function ekdosis.basic_cs(msid) else date = "" end - return siglum.."&"..name.."&"..date + if listWit[indexwit].msContents ~= nil + and + listWit[indexwit].msContents.msItemStruct ~= nil + then + locus = listWit[indexwit].msContents.msItemStruct.locus + else + locus = "" + end + return siglum.."&"..name.." "..locus.."&"..date end -- end basic TeX Conspectus siglorum @@ -1784,7 +1938,8 @@ function ekdosis.newapparatus(teitype, appbhook, appehook, applimit, - applang) + applang, + appnotelang) if isintable(apparatuses, teitype) then tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" @@ -1799,7 +1954,8 @@ function ekdosis.newapparatus(teitype, bhook = appbhook, ehook = appehook, limit = applimit, - lang = applang}) + lang = applang, + notelang = appnotelang}) end bagunits[teitype] = 1 return true @@ -1815,6 +1971,16 @@ function ekdosis.getapplang(teitype) end end +function ekdosis.getappnotelang(teitype) + i = get_a_index(teitype, apparatuses) + if apparatuses[i].notelang ~= "" + then + return apparatuses[i].notelang + else + return "\\languagename" + end +end + function ekdosis.getappdelim(str) for i = 1,#apparatuses do @@ -1853,7 +2019,7 @@ end function ekdosis.limit_bagunits(teitype) local limit = tonumber(getapplimit(teitype)) - if limit >= 10 and bagunits[teitype] > limit + if limit >= 10 and bagunits[teitype] >= limit then bagunits[teitype] = 2 return "\\pagebreak" @@ -2109,6 +2275,8 @@ local lnlabs = {} local lnlab_salt = 0 local current_lnlab = nil local prev_lnlab = nil +local prev_prev_lnlab = nil +local notelabs = {} local current_notelab = nil local prev_notelab = nil local current_lemma = nil @@ -2122,6 +2290,7 @@ local function mdvisintable(table, value) end function ekdosis.dolnlab(str) + if prev_lnlab ~= nil then prev_prev_lnlab = prev_lnlab end prev_lnlab = current_lnlab current_lemma = str i = md5.sumhexa(str) @@ -2144,9 +2313,19 @@ function ekdosis.getprevlnlab() return prev_lnlab end +function ekdosis.getprevprevlnlab() + return prev_prev_lnlab +end + function ekdosis.setnotelab(str) current_notelab = str - return "\\linelabel{" .. current_notelab .. "}" + if isfound(notelabs, current_notelab) + then + return "" + else + table.insert(notelabs, current_notelab) + return "\\linelabel{" .. current_notelab .. "}" + end end function ekdosis.getnotelab() @@ -2162,8 +2341,12 @@ function ekdosis.getprevnotelab() return prev_notelab end -local function remove_note(str) - str = gsub(str, dblbkslash * lpeg.P("note") * cmdargs, "") +local cmdstorm = lpeg.P(lpeg.P("note") + + lpeg.P("linelabel") + + lpeg.P("index")) + +local function remove_from_app(str) + str = gsub(str, dblbkslash * cmdstorm * cmdargs, "") return str end @@ -2177,7 +2360,7 @@ function ekdosis.mdvappend(str, teitype) "\\linelabel{" .. current_lnlab .. "-e}" .. "\\csname append@app\\endcsname{" - .. remove_note(str) .. "}" + .. remove_from_app(str) .. "}" else return "\\linelabel{" .. current_lnlab .. "-b}\\wordboundary{}" .. @@ -2186,7 +2369,7 @@ function ekdosis.mdvappend(str, teitype) "\\linelabel{" .. current_lnlab .. "-e}" .. "\\csname append@app\\endcsname" .. "[" .. teitype .. "]{" - .. remove_note(str) .. "}" + .. remove_from_app(str) .. "}" end end diff --git a/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.sty b/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.sty index c313fe5d29c..2bacb9f9159 100644 --- a/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.sty +++ b/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.sty @@ -41,13 +41,15 @@ %% Running "make inst" installs the files in the user's TeX tree. \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{ekdosis} - [2021/04/02 v1.2 Typesetting TEI xml-compliant critical editions] + [2021/08/18 v1.3 Typesetting TEI xml-compliant critical editions] \RequirePackage{iftex} \RequireLuaTeX \RequirePackage{expkv-opt} \RequirePackage{expkv-def} \newif\if@pkg@float \newif\if@pkg@footins +\newif\if@pkg@keyfloat +\newif\if@pkg@fitfloat \newif\if@pkg@ekddivs \newif\if@parnotesroman \newif\if@pkg@parnotes @@ -55,7 +57,9 @@ \newif\if@pkg@poetry@verse \ekvdefinekeys{ekdosis}{ choice layout = {float = {\@pkg@floattrue}, - footins = {\@pkg@floatfalse\@pkg@footinstrue}}, + footins = {\@pkg@floatfalse\@pkg@footinstrue}, + keyfloat = {\@pkg@floatfalse\@pkg@keyfloattrue}, + fitfloat = {\@pkg@floatfalse\@pkg@fitfloattrue}}, initial layout = float, unknown-choice layout = \PackageError{ekdosis}{unknown layout=#1}{`layout' must be either `float' or `footins'.}, @@ -95,7 +99,21 @@ \RequirePackage{paracol} \RequirePackage{etoolbox} \RequirePackage{lineno} -\RequirePackage{keyfloat} +\if@pkg@float + \RequirePackage{trivfloat} + \trivfloat{ekdapparatus} +\fi +\if@pkg@keyfloat + \RequirePackage{keyfloat} + \def\ekd@keyparopts#1{% + \def\ekd@insert@keyparapp{% + \keyparbox[!b]{#1}{\ekd@insert@apparatus}}} + \ekd@keyparopts{} +\fi +\if@pkg@fitfloat + \RequirePackage{tcolorbox} + \tcbuselibrary{fitting,skins} +\fi \RequirePackage{refcount} \RequirePackage{zref-user} \RequirePackage{zref-abspage} @@ -112,12 +130,32 @@ \AtEndDocument{ \luadirect{ekdosis.closestream()} } +\ekvdefinekeys{ekd@setup}{ + bool showpagebreaks = \ifekd@showpb, + store spbmk = \ekd@spbmk, + initial spbmk = spb, + store hpbmk = \ekd@hpbmk, + initial hpbmk = hpb, +} +\NewDocumentCommand{\ekdsetup}{m}{\ekvset{ekd@setup}{#1}} +\@onlypreamble\ekdsetup \ekvdefinekeys{ekd@hooks}{ store appfontsize = \ekd@appfontsize, store refnumstyle = \ekd@refnumstyle, store postrefnum = \ekd@postrefnum, store lemmastyle = \ekd@lemmastyle, store readingstyle = \ekd@readingstyle, + code keyparopts = \if@pkg@keyfloat\ekd@keyparopts{#1}\fi, + dimen appheight = \ekd@app@height, + initial appheight = .5\textheight, + choice fitalgorithm = {fontsize = \def\ekd@fit@algorithm{fontsize}, + hybrid = \def\ekd@fit@algorithm{hybrid}, + areasize = \def\ekd@fit@algorithm{areasize}, + squeeze = \def\ekd@fit@algorithm{squeeze}}, + initial fitalgorithm = fontsize, + unknown-choice fitalgorithm = \PackageError{ekdosis}{unknown + fitalgorithm=#1}{`fitalgorithm' must be either `fontsize', + `hybrid', `areasize' or `squeeze'.}, code initialrule = \def\ekd@initial@rule{#1\NLS}, default initialrule = \rule{0.4\columnwidth}{0.4pt}, noval noinitialrule = \undef\ekd@initial@rule, @@ -135,7 +173,8 @@ store collection = \collection@value, store idno = \idno@value, store msName = \msName@value, - store origDate = \origDate@value + store origDate = \origDate@value, + store locus = \locus@value } \NewDocumentCommand{\DeclareWitness}{m m m O{}}{% \bgroup @@ -150,7 +189,8 @@ \luastringO{\collection@value}, \luastringO{\idno@value}, \luastringO{\msName@value}, - \luastringO{\origDate@value})} + \luastringO{\origDate@value}, + \luastringO{\locus@value})} \egroup } \@onlypreamble\DeclareWitness @@ -214,6 +254,7 @@ \luastringN{#2}, \luastringN{#3})} } +\NewDocumentCommand{\teidirect}{O{}mm}{\ignorespaces} \NewDocumentCommand{\EnvtoTEI}{s m m O{}}{% \IfBooleanTF{#1}{% \luadirect{ekdosis.newenvtotag(\luastringN{#2}, @@ -237,6 +278,11 @@ \luadirect{ekdosis.addxmlbibresource(\luastringN{#1})} } \@onlypreamble\AddxmlBibResource +\newif\ifekd@lang@pkg +\NewDocumentCommand{\ekd@test@lang}{}{% + \ltx@ifpackageloaded{babel}{\ekd@lang@pkgtrue}{}% + \ltx@ifpackageloaded{polyglossia}{\ekd@lang@pkgtrue}{}% +} \newif\ifekd@mapps \ekvdefinekeys{ekd@newapp}{ choice direction = {LR = \def\direction@val{LR}, @@ -251,6 +297,7 @@ store ehook = \ehook@val, store maxentries = \limit@val, store lang = \lang@val, + store notelang = \notelang@val, initial direction = LR, initial delim = {}, initial ehook = {\csname ekd@end@apparatus\endcsname} @@ -270,7 +317,8 @@ \luastringO{\bhook@val}, \luastringO{\ehook@val}, \luastringO{\limit@val}, - \luastringO{\lang@val} + \luastringO{\lang@val}, + \luastringO{\notelang@val} )} \egroup } @@ -279,33 +327,47 @@ \luadirect{ekdosis.addto_bagunits(\luastringO{#1}, \luastringN{#2})}% \ignorespaces } -\NewDocumentCommand{\ekdpb}{o m}{% - \def\@tmpoarg{#1}% - \def\@tmpmarg{#2}% - \luadirect{ekdosis.dolnlab(\luastringN{#2})}% - \linelabel{\luadirect{tex.sprint(ekdosis.getlnlab())}}% - \def\tmp@ln{% - \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}}}% - \def\tmp@pg{% - \getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}}}% - \IfNoValueTF{#1} - {\ifnum - \pdf@strcmp{\@tmpmarg}{\tmp@ln} = 0 - \pagebreak - \fi} - {\ifnum - \pdf@strcmp{\@tmpoarg}{\tmp@pg} = 0 - \ifnum - \pdf@strcmp{\@tmpmarg}{\tmp@ln} = 0 - \pagebreak - \fi - \fi +\newcounter{ekd@pb} +\globalcounter{ekd@pb} +\NewDocumentCommand{\ekdpb}{s o m}{% + \IfBooleanTF{#1} + {\ifekd@showpb\marginpar{\ekd@hpbmk}\fi + \pagebreak} + {% + \def\@tmpoarg{#2}% + \def\@tmpmarg{#3}% + \stepcounter{ekd@pb}% + \linelabel{ekdpb:\theekd@pb}% + \def\tmp@ln{% + \getrefnumber{ekdpb:\theekd@pb}}% + \def\tmp@pg{% + \getpagerefnumber{ekdpb:\theekd@pb}}% + \IfNoValueTF{#2} + {\ifnum + \pdf@strcmp{\@tmpmarg}{\tmp@ln} = 0 + \ifekd@showpb\marginpar{\ekd@spbmk}\fi + \pagebreak + \else + \ifekd@showpb\marginpar{[\ekd@spbmk]}\fi + \fi} + {\ifnum + \pdf@strcmp{\@tmpoarg}{\tmp@pg} = 0 + \ifnum + \pdf@strcmp{\@tmpmarg}{\tmp@ln} = 0 + \ifekd@showpb\marginpar{\ekd@spbmk}\fi + \pagebreak + \else + \ifekd@showpb\marginpar{[\ekd@spbmk]}\fi + \fi + \fi + }% }\ignorespaces } \newbool{do@app} \newif\ifekd@state \newif\ifekd@isinapp \newif\ifekd@isinlem +\newif\ifekd@appinapp \providebool{al@rlmode} \@ifpackageloaded{arabluatex}{}{% \def\setRL{\booltrue{al@rlmode}\pardir TRT\textdir TRT} @@ -356,7 +418,11 @@ initial rule = \rule{0.4\columnwidth}{0.4pt}, noval norule = \def\ekd@default@rule{\mbox{}}, store lang = \ekd@singleapp@lang, - initial lang = \ltx@ifpackageloaded{babel}{\languagename}{} + initial lang = \ltx@ifpackageloaded{babel}{\languagename}{% + \ltx@ifpackageloaded{polyglossia}{\languagename}{}}, + store notelang = \ekd@singleapp@note@lang, + initial notelang = \ltx@ifpackageloaded{babel}{\languagename}{% + \ltx@ifpackageloaded{polyglossia}{\languagename}{}} } \NewDocumentCommand{\SetApparatus}{m}{ \ekvset{default@app}{#1} @@ -369,6 +435,8 @@ \NewDocumentCommand{\SetUnitDelimiter}{m}{\def\ekd@unit@delim{#1}} \NewDocumentCommand{\SetApparatusLanguage}{m}{% \def\ekd@singleapp@lang{#1}} +\NewDocumentCommand{\SetApparatusNoteLanguage}{m}{% + \def\ekd@singleapp@note@lang{#1}} \newif\iffootnoterule \footnoteruletrue \let\dflt@footnoterule\footnoterule @@ -401,6 +469,35 @@ \newif\ifsubsq@unit \subsq@unittrue \newif\ifekd@inside@app +\if@pkg@fitfloat + \newtcboxfit{\ekd@fitapp}{% + blankest, + fit basedim = \f@size pt, + fit fontsize macros, + fit height from=0pt to \ekd@app@height, + fit algorithm = \ekd@fit@algorithm, + float=!b} +\fi +\long\def\ekd@insert@apparatus{% + \unless\ifekd@mapps + \ifrtl@app\pardir TRT\leavevmode\textdir TRT\else + \pardir TLT\leavevmode\textdir TLT\fi + \fi + \if@pkg@parnotes + \if@parnotesroman + \renewcommand*{\theparnotemark}{\roman{parnotemark}}\fi + \parnoteclear\fi + \ekd@inside@apptrue + \ekd@appfontsize + \ifekd@mapps + \ifdefined\ekd@initial@rule + \ekd@initial@rule + \fi + \fi + \apparatus\unless\ifekd@mapps\ekd@end@apparatus\fi + \ekd@inside@appfalse + \if@pkg@parnotes\parnotes\parnotereset\fi +}% \def\add@@apparatus{% \if@pkg@parnotes\parnotes\else\fi \if@pkg@footins @@ -428,26 +525,15 @@ \egroup \fi \if@pkg@float - \keyparbox[!b]{}{% - \unless\ifekd@mapps - \ifrtl@app\pardir TRT\leavevmode\textdir TRT\else - \pardir TLT\leavevmode\textdir TLT\fi - \fi - \if@pkg@parnotes - \if@parnotesroman - \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi - \parnoteclear\else\fi - \ekd@inside@apptrue - \ekd@appfontsize - \ifekd@mapps - \ifdefined\ekd@initial@rule - \ekd@initial@rule - \fi - \fi - \apparatus\unless\ifekd@mapps\ekd@end@apparatus\fi - \ekd@inside@appfalse - \if@pkg@parnotes\parnotes\parnotereset\else\fi - }% + \begin{ekdapparatus}[!b]% + \ekd@insert@apparatus + \end{ekdapparatus}% + \fi + \if@pkg@keyfloat + \ekd@insert@keyparapp + \fi + \if@pkg@fitfloat + \ekd@fitapp{\ekd@insert@apparatus}% \fi } \def\add@apparatus{% @@ -498,7 +584,9 @@ \newif\ifekd@elidednumbers \ekvdefinekeys{ekd@lineation}{ choice lineation = {page = \ekd@pagelineationtrue, - document = \ekd@pagelineationfalse}, + document = \ekd@pagelineationfalse, + none = \ekd@pagelineationtrue + \renewcommand\thelinenumber{}}, unknown-choice lineation = \PackageError{ekdosis}{unknown lineation=#1}{`lineation' must be either `page' or `document'.}, choice vlineation = {page = \ekd@pagevlineationtrue, @@ -544,14 +632,16 @@ \leavevmode \begingroup \ekvset{appnote}{#1}% - \ekd@isinapptrue% + \ifekd@isinapp\ekd@appinapptrue\fi + \ekd@isinapptrue \stepcounter{ekd@lab}% \zlabel{ekd:\theekd@lab}% \luadirect{ekdosis.storeabspg( \luastring{\zref@extract{ekd:\theekd@lab}{abspage}})}% - \ifekd@state\add@apparatus\fi% + \ifekd@state\add@apparatus\fi \luadirect{tex.sprint(ekdosis.removesp(\luastringN{#2}))}% - \ekd@isinappfalse% + \ekd@isinappfalse + \ekd@appinappfalse \endgroup} \def\current@ref@arg#1#2{{%\textdir TLT% \unexpanded\expandafter{\ekd@refnumstyle}% @@ -604,10 +694,16 @@ \fi \fi% \else - \LRnum{\getrefnumber{#1}}--% - \LRnum{\getpagerefnumber{#2}}.% - \LRnum{\getrefnumber{#2}}\unexpanded\expandafter{\ekd@postrefnum}% issue pg and ln nos + \ifboolexpr{bool {ekd@pagelineation} or bool {ekd@pagevlineation}} + {\LRnum{\getrefnumber{#1}}--% + \LRnum{\getpagerefnumber{#2}}.% + \LRnum{\getrefnumber{#2}}\unexpanded\expandafter{\ekd@postrefnum}}% issue pg and ln nos + {\LRnum{\getrefnumber{#1}}--% + \LRnum{\getrefnumber{#2}}\unexpanded\expandafter{\ekd@postrefnum}}% issue the nos \fi% + \ifekdn@forcenum + \LRnum{\getrefnumber{#1}}\unexpanded\expandafter{\ekd@postrefnum}% force the no + \fi }% } \def\current@ref{{%\textdir TLT% @@ -632,6 +728,28 @@ {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-b}} = 0 + %%%begin + \ifnum% + \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}% + {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-e}} + = + 0 + \ifekd@appinapp + \ifnum% + \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% + {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevprevlnlab())}-b}} + = + 0 + \else + \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% + \unexpanded\expandafter{\ekd@postrefnum}% issue the no + \fi + \fi + \else + \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% + \unexpanded\expandafter{\ekd@postrefnum}% issue the no + \fi + %%% end \else \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% \unexpanded\expandafter{\ekd@postrefnum}% issue the no @@ -646,6 +764,28 @@ {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-b}} = 0 + %%%begin + \ifnum% + \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}% + {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-e}} + = + 0 + \ifekd@appinapp + \ifnum% + \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% + {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevprevlnlab())}-b}} + = + 0 + \else + \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% + \unexpanded\expandafter{\ekd@postrefnum}% issue the no + \fi + \fi + \else + \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% + \unexpanded\expandafter{\ekd@postrefnum}% issue the no + \fi + %%% end \else \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% \unexpanded\expandafter{\ekd@postrefnum}% issue the no @@ -670,13 +810,23 @@ \fi \fi% \else - \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--% - \LRnum{\getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}.% - \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}% - \unexpanded\expandafter{\ekd@postrefnum}% issue pg and ln nos + \ifboolexpr{bool {ekd@pagelineation} or bool {ekd@pagevlineation}} + {\LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--% + \LRnum{\getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}.% + \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}% + \unexpanded\expandafter{\ekd@postrefnum}}% issue pg and ln nos + {\LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--% + \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}% + \unexpanded\expandafter{\ekd@postrefnum}}% issue the nos \fi% + \ifekdl@forcenum + \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% + \unexpanded\expandafter{\ekd@postrefnum}% force the no + \fi }% } +\newif\ifekdl@forcenum +\newif\ifekdl@nonum \ekvdefinekeys{lem}{ code wit = \def\ekdlr@wit{#1}, code source = \def\ekdlr@source{#1}, @@ -688,6 +838,8 @@ code postwit = \def\ekdlr@postwit{#1}, store type = \ekdlr@type, store sep = \ekdl@sep, + noval nonum = \ekdl@nonumtrue, + noval num = \ekdl@forcenumtrue, bool nolem = \ifekdl@nolem, bool nosep = \ifekdl@nosep, initial sep = \ekdsep @@ -714,12 +866,22 @@ \ekd@singleapp@lang \fi } +\def\app@note@lang{% + \ifekd@mapps + \luadirect{tex.sprint(ekdosis.getappnotelang(\luastring{\ekdan@type}))}% + \else + \ekd@singleapp@note@lang + \fi +} \NewDocumentCommand{\lem}{O{} m}{% \ekd@isinlemtrue% \luadirect{ekdosis.dolnlab(\luastringN{#2})}% \null \bgroup% + \ekdl@forcenumfalse + \ekdl@nonumfalse \ekvset{lem}{#1}% + \ekd@test@lang \ifekd@mapps% \ifnum% \luadirect{tex.sprint(ekdosis.get_bagunits(\luastringO{\ekdan@type}))} @@ -739,7 +901,7 @@ \else% \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi% \fi% - \current@ref}%\hskip .25em}% + \unless\ifekdl@nonum\current@ref\fi}%\hskip .25em}% \else% \ifbool{al@rlmode}{% \edef\lem@app{% @@ -750,7 +912,7 @@ \else% \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi% \fi% - \current@ref%\hskip .25em + \unless\ifekdl@nonum\current@ref\fi%\hskip .25em \ifdefined\ekdlr@alt% \ifdefined\ekdlr@post% \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi @@ -785,11 +947,11 @@ \else% \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi% \fi% - \current@ref%\hskip .25em + \unless\ifekdl@nonum\current@ref\fi%\hskip .25em \ifdefined\ekdlr@alt% \ifdefined\ekdlr@pre% \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi - \ltx@ifpackageloaded{babel}% + \ifbool{ekd@lang@pkg}% {{\unexpanded\expandafter{\ekd@lemmastyle}% \noexpand\selectlanguage{\app@lang}% \unexpanded\expandafter{\ekdlr@alt}}}% @@ -800,7 +962,7 @@ \else \ifdefined\ekdlr@pre% \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi - \ltx@ifpackageloaded{babel}% + \ifbool{ekd@lang@pkg}% {{\unexpanded\expandafter{\ekd@lemmastyle}% \noexpand\selectlanguage{\app@lang}% \unexpanded{#2}}}{% @@ -831,6 +993,7 @@ \NewDocumentCommand{\rdg}{O{} m}{% \bgroup% \ekvset{rdg}{#1}% + \ekd@test@lang % \ifekdr@nordg\append@app{}\else% do we need \append@app{} here? If % % so, keep in mind \ifekd@mapps, % like so: @@ -872,7 +1035,7 @@ \ifdefined\ekdlr@alt% \ifdefined\ekdlr@pre% \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi - \ltx@ifpackageloaded{babel}% + \ifbool{ekd@lang@pkg}% {{\unexpanded\expandafter{\ekd@readingstyle}% \noexpand\selectlanguage{\app@lang}% \unexpanded\expandafter{\ekdlr@alt}}}% @@ -883,7 +1046,7 @@ \else \ifdefined\ekdlr@pre% \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi - \ltx@ifpackageloaded{babel}% + \ifbool{ekd@lang@pkg}% {{\unexpanded\expandafter{\ekd@readingstyle}% \noexpand\selectlanguage{\app@lang}\unexpanded{#2}}}{% {\unexpanded\expandafter{\ekd@readingstyle}\unexpanded{#2}}}% @@ -907,6 +1070,7 @@ \fi% \egroup% } +\newif\ifekdn@forcenum \ekvdefinekeys{note}{ store type = \ekdan@type, store lem = \ekdn@lem, @@ -915,12 +1079,15 @@ store sep = \ekdn@sep, bool nosep = \ifekdn@nosep, initial type = default, - initial sep = \ekdsep + initial sep = \ekdsep, + bool nonum = \ifekdn@nonum, + noval num = \ekdn@forcenumtrue } \NewDocumentCommand{\note@noapp}{O{} +m}{% \leavevmode \bgroup% \ekvset{note}{#1}% + \ekd@test@lang \stepcounter{ekd@lab}% \zlabel{ekd:\theekd@lab}% \luadirect{ekdosis.storeabspg( @@ -951,7 +1118,7 @@ \else% \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi% \fi% - \current@ref@arg{\ekdn@labelb}{\ekdn@labele}%\hskip .25em + \unless\ifekdn@nonum\current@ref@arg{\ekdn@labelb}{\ekdn@labele}\fi%\hskip .25em \ifdefined\ekdn@lem% {\textdir TRT\unexpanded\expandafter{\ekd@lemmastyle}% \unexpanded\expandafter{\ekdn@lem}}% @@ -967,9 +1134,9 @@ \else% \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi% \fi% - \current@ref@arg{\ekdn@labelb}{\ekdn@labele}%\hskip .25em + \unless\ifekdn@nonum\current@ref@arg{\ekdn@labelb}{\ekdn@labele}\fi%\hskip .25em \ifdefined\ekdn@lem - \ltx@ifpackageloaded{babel}% + \ifbool{ekd@lang@pkg}% {{\unexpanded\expandafter{\ekd@lemmastyle}% \noexpand\selectlanguage{\app@lang}% \unexpanded\expandafter{\ekdn@lem}}}% @@ -978,8 +1145,8 @@ \unless\ifekdn@nosep \unexpanded\expandafter{\ekdn@sep}\fi \else\fi% - \ltx@ifpackageloaded{babel}% - {{\noexpand\selectlanguage{\app@lang}\unexpanded{#2}}}{% + \ifbool{ekd@lang@pkg}% + {{\noexpand\selectlanguage{\app@note@lang}\unexpanded{#2}}}{% {\unexpanded{#2}}}}}% \ifekd@mapps% \unconditional@appin[\ekdan@type]{\note@contents}% @@ -1013,25 +1180,25 @@ \egroup% } \NewDocumentCommand{\ekd@note@star}{O{} m}{% - \if@pkg@parnotes - \bgroup% - \ekvset{ekd@note}{#1}% - \edef\note@contents{% - \ekvifdefinedNoVal{ekd@note}{pre}{}{% - \unexpanded\expandafter{\pre@value}}% - \unskip\noexpand\parnote{\unexpanded{#2}}% - \ekvifdefinedNoVal{ekd@note}{post}{}{% - \unexpanded\expandafter{\post@value}}% - }% - \append@app{\note@contents}% - \egroup% - \else - \ifekd@mapps% + \bgroup + \ekvset{ekd@note}{#1}% + \edef\note@contents{% + \ekvifdefinedNoVal{ekd@note}{pre}{}{% + \unexpanded\expandafter{\pre@value}}% + \if@pkg@parnotes + \unskip\noexpand\parnote{\unexpanded{#2}}% + \else + \unskip\noexpand\footnote{\unexpanded{#2}}% + \fi + \ekvifdefinedNoVal{ekd@note}{post}{}{% + \unexpanded\expandafter{\post@value}}% + }% + \ifekd@mapps \append@app[\ekdan@type]{\note@contents}% - \else% + \else \append@app{\note@contents}% - \fi% - \fi% + \fi + \egroup } \NewDocumentCommand{\note@app}{s O{} +m}{% \ifbool{al@rlmode}{% @@ -1207,6 +1374,54 @@ \luadirect{ekdosis.flushenvdata()} \luadirect{ekdosis.flushcolnums()} } +\NewDocumentCommand{\ekd@storemark}{m}{% + \stepcounter{ekd@lab}% + \label{ekd:\theekd@lab}% + \luadirect{ekdosis.storehfmark( + \luastring{\getpagerefnumber{ekd:\theekd@lab}}, + \luastringN{#1})}% +} +\NewDocumentCommand{\endmark}{}{% + \stepcounter{ekd@lab}% + \label{ekd:\theekd@lab}% + \luadirect{ekdosis.storehfmark( + \luastring{\getpagerefnumber{ekd:\theekd@lab}}, + "", "endmk")}% + \ifdefined\xspace\xspace\fi +} +\NewDocumentCommand{\ekdmark}{}{% + \luadirect{tex.sprint(ekdosis.gethfmark(\luastring{\thepage}))}% +} +\ekvdefinekeys{ekd@marks}{ + choice mark = {HEL = \def\ekd@mk{HEL}, + HEC = \def\ekd@mk{HEC}, + HER = \def\ekd@mk{HER}, + HOL = \def\ekd@mk{HOL}, + HOC = \def\ekd@mk{HOC}, + HOR = \def\ekd@mk{HOR}, + FEL = \def\ekd@mk{FEL}, + FEC = \def\ekd@mk{FEC}, + FEL = \def\ekd@mk{FER}, + FOL = \def\ekd@mk{FOL}, + FOC = \def\ekd@mk{FOC}, + FOL = \def\ekd@mk{FOR}}, + unknown-choice mark = \PackageError{ekdosis}{unknown mark=#1}{`mark' + must be either `HEL', `HEC', `HER', `HOL', `HOC', `HOR', `FEL', + \MessageBreak `FEC', `FER', `FOL', `FOC' or `FOR'.} +} +\NewDocumentCommand{\ekdprintmark}{m m}{% + \bgroup + \ekvset{ekd@marks}{mark = #1}% + \luadirect{tex.sprint(ekdosis.printmark(\luastringN{#2}, + \luastringO{\ekd@mk}))}% + \egroup +} +\NewDocumentCommand{\ekdnohfmark}{}{% + \luadirect{ekdosis.nohfmark()}% +} +\NewDocumentCommand{\ekdresethfmarks}{}{% + \luadirect{ekdosis.resethfmark()}% +} \NewDocumentCommand{\MkBodyDivs}{mmmmmm}{ \luadirect{ekdosis.mkdivdepths( \luastringN{#1}, @@ -1224,6 +1439,7 @@ code head = \def\head@value{#1}, code barehead = \def\barehead@value{#1}, store depth = \depth@value, + code mark = \ekd@storemark{#1}, choice toc = {book = \def\toc@value{book}, part = \def\toc@value{part}, chapter = \def\toc@value{chapter}, -- cgit v1.2.3