diff options
author | Karl Berry <karl@freefriends.org> | 2021-11-21 21:13:16 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-11-21 21:13:16 +0000 |
commit | 123ac3a99df880d5da88ee46d6dcec3eeba6b97a (patch) | |
tree | ce3d546f11d563736c217845afc30cadd29f87eb /Master/texmf-dist/tex/lualatex | |
parent | a0e07de1bcda54a76946aec1c05fd3358b0b1052 (diff) |
ekdosis (21nov21)
git-svn-id: svn://tug.org/texlive/trunk@61113 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/lualatex')
-rw-r--r-- | Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.lua | 71 | ||||
-rw-r--r-- | Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.sty | 113 |
2 files changed, 146 insertions, 38 deletions
diff --git a/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.lua b/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.lua index f5f9bd22c41..b5ddfb38c56 100644 --- a/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.lua +++ b/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.lua @@ -56,7 +56,7 @@ local inanchor = lpeg.Cs{ "<anchor" * ((1 - (lpeg.P"<" + lpeg.P">")) + lpeg.V(1) local inopeningnote = lpeg.Cs{ "<note" * ((1 - (lpeg.P"<" + lpeg.P">")) + 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) +local poemlinebreak = lpeg.Cs(lnbrk * spcenc^-1 * (lpeg.P(">") + lpeg.P("+")) * bsqbrackets^-1 * spcenc^-1) local linegroup = lpeg.Cs{ "<lg" * ((1 - lpeg.S"<>") + lpeg.V(1))^0 * ">" } local bclinegroup = lpeg.Cs(linegroup + lpeg.P("</lg>")) local endpoem = lpeg.Cs(lnbrk * lpeg.S("*!") * bsqbrackets^-1) -- not used @@ -356,6 +356,18 @@ function ekdosis.newsource(id, siglum) return true end +local familysep = nil + +function ekdosis.setfamilysep(str) + if str == "reset" + then + familysep = nil + else + familysep = str + end + return true +end + function ekdosis.getsiglum(str, opt) str = str.."," str = string.gsub(str, "%s-(%,)", "%1") @@ -379,6 +391,10 @@ function ekdosis.getsiglum(str, opt) str = string.gsub(str, tempc.."%,", idsRend[i].abbr) ctrl = string.gsub(ctrl, tempc.."%,", "") end + if familysep ~= nil + then + str = string.gsub(str, "%s+", familysep) + end end -- if string.find(ctrl, "[A-Za-z0-9]") if string.find(ctrl, "%S") @@ -418,6 +434,10 @@ local cmdtotags = { local texpatttotags = { {a="\\addentries%s+%[(.-)%]{(.-)}", b=""}, {a="\\addentries%s+{(.-)}", b=""}, + {a="\\vmodulolinenumbers%s+%[(.-)%]", b=""}, + {a="\\vmodulolinenumbers%s+", b=""}, + {a="\\modulolinenumbers%s+%[(.-)%]", b=""}, + {a="\\modulolinenumbers%s+", b=""}, {a="\\setverselinenums%s+{(.-)}{(.-)}", b=""}, {a="\\resetvlinenumber%s+%[(.-)%]", b=""}, {a="\\resetvlinenumber%s+", b=""}, @@ -759,6 +779,9 @@ local function versetotei(str) end) str = string.gsub(str, "\\begin%s?%{ekdverse%}(.-)\\end%s?%{ekdverse%}", function(arg) arg = string.gsub(arg, "\\par%s?", "") + arg = string.gsub(arg, "\\begin%s?%{patverse%*?%}", "") + arg = string.gsub(arg, "\\end%s?%{patverse%*?%}", "") + arg = string.gsub(arg, "\\indentpattern%s?%b{}", "") return "\\p@rb "..linestotei(string.format("<lg>%s</lg>", arg)).."\\p@ra " end) str = string.gsub(str, "\\begin%s?%{verse%}%b[](.-)\\end%s?%{verse%}", function(arg) @@ -1675,6 +1698,7 @@ function ekdosis.closestream() end local cur_abs_pg = 0 +local ekd_abs_pg = 0 local pg_i = nil local pg_ii = nil local prevcol = nil @@ -1688,16 +1712,25 @@ function ekdosis.update_abspg(n) -- not used end function ekdosis.storeabspg(n, pg) + if tonumber(n) > tonumber(cur_abs_pg) + then + ekd_abs_pg = ekd_abs_pg + 1 + end + cur_abs_pg = n + n = ekd_abs_pg if pg == "pg_i" then pg_i = n elseif pg == "pg_ii" then pg_ii = n table.insert(check_resetlineno, curcol.."-"..pg_ii) end - cur_abs_pg = n return true end +function ekdosis.getekdabspg() + return ekd_abs_pg +end + function ekdosis.checkresetlineno() if isfound(check_resetlineno, curcol.."-"..pg_i) then @@ -1935,6 +1968,7 @@ function ekdosis.newapparatus(teitype, apprule, appdelim, appsep, + appsubsep, appbhook, appehook, applimit, @@ -1951,6 +1985,7 @@ function ekdosis.newapparatus(teitype, rule = apprule, delim = appdelim, sep = appsep, + subsep = appsubsep, bhook = appbhook, ehook = appehook, limit = applimit, @@ -2051,8 +2086,8 @@ function ekdosis.appin(str, teitype) local f = io.open(tex.jobname.."_tmp.ekd", "a+") if next(apparatuses) == nil then - f:write("<", cur_abs_pg, cur_alignment, curcol, "-0>", str, "</", - cur_abs_pg, cur_alignment, curcol, "-0>\n") + f:write("<", ekd_abs_pg, cur_alignment, curcol, "-0>", str, "</", + ekd_abs_pg, cur_alignment, curcol, "-0>\n") else for i = 1,#apparatuses do @@ -2061,8 +2096,8 @@ function ekdosis.appin(str, teitype) break end end - f:write("<", cur_abs_pg, cur_alignment, curcol, "-", - appno, ">", str, "</", cur_abs_pg, cur_alignment, curcol, "-", appno, ">\n") + f:write("<", ekd_abs_pg, cur_alignment, curcol, "-", + appno, ">", str, "</", ekd_abs_pg, cur_alignment, curcol, "-", appno, ">\n") end f:close() return true @@ -2080,10 +2115,10 @@ function ekdosis.appout() table.insert(output, "\\csname ekd@begin@apparatus\\endcsname\\ignorespaces") -- table.insert(output, "\\noindent ") for i in string.gmatch(t, - "<"..cur_abs_pg + "<"..ekd_abs_pg ..cur_alignment_patt ..curcol.."%-0>.-</" - ..cur_abs_pg + ..ekd_abs_pg ..cur_alignment_patt ..curcol.."%-0>") do @@ -2095,10 +2130,10 @@ function ekdosis.appout() local n = 1 while apparatuses[n] do - if string.match(t, "<"..cur_abs_pg + if string.match(t, "<"..ekd_abs_pg ..cur_alignment_patt ..curcol.."%-"..n..">.-</" - ..cur_abs_pg + ..ekd_abs_pg ..cur_alignment_patt ..curcol.."%-"..n..">") then @@ -2155,6 +2190,10 @@ function ekdosis.appout() table.insert(output, "\\edef\\ekdsep{" .. apparatuses[n].sep .. "}") else end + if apparatuses[n].subsep ~= "" + then + table.insert(output, "\\edef\\ekdsubsep{" .. apparatuses[n].subsep .. "}") + end if apparatuses[n].bhook ~= "" then table.insert(output, apparatuses[n].bhook) @@ -2162,10 +2201,10 @@ function ekdosis.appout() table.insert(output, "\\relax") end for i in string.gmatch(t, - "<"..cur_abs_pg + "<"..ekd_abs_pg ..cur_alignment_patt ..curcol.."%-"..n..">.-</" - ..cur_abs_pg + ..ekd_abs_pg ..cur_alignment_patt ..curcol.."%-"..n..">") do @@ -2185,8 +2224,8 @@ function ekdosis.appout() end f:close() str = table.concat(output) - str = string.gsub(str, "</"..cur_abs_pg..cur_alignment_patt..curcol.."%-[0-9]>", "") - str = string.gsub(str, "<"..cur_abs_pg..cur_alignment_patt..curcol.."%-[0-9]>", " ") + str = string.gsub(str, "</"..ekd_abs_pg..cur_alignment_patt..curcol.."%-[0-9]>", "") + str = string.gsub(str, "<"..ekd_abs_pg..cur_alignment_patt..curcol.."%-[0-9]>", " ") return str else end @@ -2206,7 +2245,7 @@ end local curcol_curabspg = {} function ekdosis.testapparatus() - if isfound(curcol_curabspg, curcol.."-"..cur_abs_pg) + if isfound(curcol_curabspg, curcol.."-"..ekd_abs_pg) then if newalignment then @@ -2219,7 +2258,7 @@ function ekdosis.testapparatus() return "\\boolfalse{do@app}" end else - table.insert(curcol_curabspg, curcol.."-"..cur_abs_pg) + table.insert(curcol_curabspg, curcol.."-"..ekd_abs_pg) if next(apparatuses) ~= nil then reset_bagunits() end diff --git a/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.sty b/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.sty index 2bacb9f9159..0e3058955d5 100644 --- a/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.sty +++ b/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.sty @@ -41,7 +41,7 @@ %% Running "make inst" installs the files in the user's TeX tree. \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{ekdosis} - [2021/08/18 v1.3 Typesetting TEI xml-compliant critical editions] + [2021/11/21 v1.4 Typesetting TEI xml-compliant critical editions] \RequirePackage{iftex} \RequireLuaTeX \RequirePackage{expkv-opt} @@ -49,7 +49,7 @@ \newif\if@pkg@float \newif\if@pkg@footins \newif\if@pkg@keyfloat -\newif\if@pkg@fitfloat +\newif\if@pkg@fitapp \newif\if@pkg@ekddivs \newif\if@parnotesroman \newif\if@pkg@parnotes @@ -59,7 +59,7 @@ choice layout = {float = {\@pkg@floattrue}, footins = {\@pkg@floatfalse\@pkg@footinstrue}, keyfloat = {\@pkg@floatfalse\@pkg@keyfloattrue}, - fitfloat = {\@pkg@floatfalse\@pkg@fitfloattrue}}, + fitapp = {\@pkg@floatfalse\@pkg@fitapptrue}}, initial layout = float, unknown-choice layout = \PackageError{ekdosis}{unknown layout=#1}{`layout' must be either `float' or `footins'.}, @@ -110,7 +110,7 @@ \keyparbox[!b]{#1}{\ekd@insert@apparatus}}} \ekd@keyparopts{} \fi -\if@pkg@fitfloat +\if@pkg@fitapp \RequirePackage{tcolorbox} \tcbuselibrary{fitting,skins} \fi @@ -143,6 +143,7 @@ store appfontsize = \ekd@appfontsize, store refnumstyle = \ekd@refnumstyle, store postrefnum = \ekd@postrefnum, + code familysep = \luadirect{ekdosis.setfamilysep(\luastringN{#1})}, store lemmastyle = \ekd@lemmastyle, store readingstyle = \ekd@readingstyle, code keyparopts = \if@pkg@keyfloat\ekd@keyparopts{#1}\fi, @@ -293,6 +294,7 @@ nmeta norule = {rule=none}, code delim = \def\delim@val{\unexpanded{#1}}, store sep = \sep@val, + store subsep = \subsep@val, store bhook = \bhook@val, store ehook = \ehook@val, store maxentries = \limit@val, @@ -314,6 +316,7 @@ \luastringO{\rule@val}, \luastringO{\delim@val}, \luastringO{\sep@val}, + \luastringO{\subsep@val}, \luastringO{\bhook@val}, \luastringO{\ehook@val}, \luastringO{\limit@val}, @@ -402,12 +405,14 @@ \hb@xt@0em{\hss\@makefnmark}#1} \newif\ifrtl@app \edef\ekdsep{] } +\edef\ekdsubsep{} \ekvdefinekeys{default@app}{ choice direction = {LR = \rtl@appfalse, RL = \rtl@apptrue}, unknown-choice direction = \PackageError{ekdosis}{unknown direction=#1}{`direction' must be either `LR' or `RL'.}, code sep = \edef\ekdsep{#1}, + code subsep = \edef\ekdsubsep{#1}, store bhook = \ekd@begin@apparatus, initial bhook = {}, store ehook = \ekd@end@apparatus, @@ -430,6 +435,7 @@ \NewDocumentCommand{\SetRTLapp}{}{\rtl@apptrue} \NewDocumentCommand{\SetLTRapp}{}{\rtl@appfalse} \NewDocumentCommand{\SetSeparator}{m}{\edef\ekdsep{#1}} +\NewDocumentCommand{\SetSubseparator}{m}{\edef\ekdsubsep{#1}} \NewDocumentCommand{\SetBeginApparatus}{m}{\edef\ekd@begin@apparatus{#1}} \NewDocumentCommand{\SetEndApparatus}{m}{\edef\ekd@end@apparatus{#1}} \NewDocumentCommand{\SetUnitDelimiter}{m}{\def\ekd@unit@delim{#1}} @@ -469,7 +475,8 @@ \newif\ifsubsq@unit \subsq@unittrue \newif\ifekd@inside@app -\if@pkg@fitfloat +\newif\ifekd@keepinapp +\if@pkg@fitapp \newtcboxfit{\ekd@fitapp}{% blankest, fit basedim = \f@size pt, @@ -532,7 +539,7 @@ \if@pkg@keyfloat \ekd@insert@keyparapp \fi - \if@pkg@fitfloat + \if@pkg@fitapp \ekd@fitapp{\ekd@insert@apparatus}% \fi } @@ -599,6 +606,7 @@ \else\if@pkg@poetry@verse\poemlines{#1}\fi\fi, initial vmodulo = 1, default vmodulo = 5, + bool vnumbrokenlines = \ifnum@brokenline, bool continuousvnum = \if@continuous@vnum, choice numbers = {elided = \ekd@elidednumberstrue, full = \ekd@elidednumbersfalse}, @@ -621,6 +629,16 @@ \NewDocumentCommand{\SetLineation}{m}{ \ekvset{ekd@lineation}{#1} } +\NewDocumentCommand{\vmodulolinenumbers}{O{5}}{% + \ifekd@memoir@loaded + \linenumberfrequency{#1}% + \else + \if@pkg@poetry@verse + \poemlines{#1}% + \fi + \fi + \ignorespaces +} \renewcommand\linenumberfont{\normalfont\footnotesize} \ekvdefinekeys{appnote}{ store type = \ekdan@type, @@ -643,6 +661,9 @@ \ekd@isinappfalse \ekd@appinappfalse \endgroup} +\NewDocumentCommand{\ekdpage}{}{% + \luadirect{tex.sprint(ekdosis.getekdabspg())}% +} \def\current@ref@arg#1#2{{%\textdir TLT% \unexpanded\expandafter{\ekd@refnumstyle}% \ifnum% @@ -853,6 +874,9 @@ code post = \def\ekdlr@post{#1}, code prewit = \def\ekdlr@prewit{#1}, code postwit = \def\ekdlr@postwit{#1}, + store subsep = \ekdr@subsep, + initial subsep = \ekdsubsep, + bool nosubsep = \ifekdr@nosubsep, store type = \ekdlr@type, bool nordg = \ifekdr@nordg } @@ -990,6 +1014,7 @@ \ekd@isinlemfalse% \subsq@unittrue% } +\newif\ifekd@subsq@rdg \NewDocumentCommand{\rdg}{O{} m}{% \bgroup% \ekvset{rdg}{#1}% @@ -1006,6 +1031,9 @@ \else% \ifbool{al@rlmode}{% \edef\rdg@app{% + \ifekd@subsq@rdg + \unless\ifekdr@nosubsep\unexpanded\expandafter{\ekdr@subsep}\fi + \fi \ifdefined\ekdlr@alt% \ifdefined\ekdlr@post% \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi @@ -1032,6 +1060,9 @@ }% {% \edef\rdg@app{% + \ifekd@subsq@rdg + \unless\ifekdr@nosubsep\unexpanded\expandafter{\ekdr@subsep}\fi + \fi \ifdefined\ekdlr@alt% \ifdefined\ekdlr@pre% \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi @@ -1062,13 +1093,14 @@ \space\unexpanded\expandafter{\ekdlr@postwit}\else\fi }% }% - \ifekd@mapps% + \ifekd@mapps \append@app[\ekdan@type]{\rdg@app}% - \else% + \else \append@app{\rdg@app}% - \fi% - \fi% - \egroup% + \fi + \fi + \egroup + \ekd@subsq@rdgtrue } \newif\ifekdn@forcenum \ekvdefinekeys{note}{ @@ -1160,7 +1192,9 @@ } \ekvdefinekeys{ekd@note}{ store pre = \pre@value, - store post = \post@value + store post = \post@value, + nmeta sep = {post=\ekdsep}, + nmeta subsep = {pre=\ekdsubsep} } \NewDocumentCommand{\ekd@note}{O{} m}{% \bgroup% @@ -1237,29 +1271,44 @@ initial delend = \ifbool{al@rlmode}{\{}{\}}, initial sicbegin = \dag, initial sicend = \dag, - initial gapmark = *** + initial gapmark = ***, + bool keepinapp = \ifekd@keepinapp } \NewDocumentCommand{\supplied}{m}{% \ifekd@inside@app - #1% + \ifekd@keepinapp + \suppb@value #1\suppe@value + \else + #1% + \fi \else - \suppb@value #1\suppe@value + \suppb@value #1\suppe@value \fi } \NewDocumentCommand{\surplus}{m}{% \ifekd@inside@app - #1% + \ifekd@keepinapp + \delb@value #1\dele@value + \else + #1% + \fi \else - \delb@value #1\dele@value + \delb@value #1\dele@value \fi } \NewDocumentCommand{\sic}{s m}{% \ifekd@inside@app - #2% + \ifekd@keepinapp + \IfBooleanTF{#1} + {\sicb@value #2} + {\sicb@value #2\sice@value}% + \else + #2% + \fi \else - \IfBooleanTF{#1} - {\sicb@value #2} - {\sicb@value #2\sice@value}% + \IfBooleanTF{#1} + {\sicb@value #2} + {\sicb@value #2\sice@value}% \fi } \NewDocumentCommand{\gap}{m}{% @@ -1502,6 +1551,25 @@ \global\ekd@test@vpnumtrue \fi } +\ifboolexpr{bool {@pkg@poetry@verse} or bool {ekd@memoir@loaded}} + {\newcommand{\@vsifplus}[1]{\@ifnextchar +{\@firstoftwo{#1}}} + \renewcommand{\@vscentercr}{% + \ifhmode \unskip\else \@nolnerr\fi + \@vsifgt{\ifnum@brokenline\@vstypelinenum\fi\verselinebreak}{% + \@vsifplus{\ifnum@brokenline\@vstypelinenum\fi\stepcounter{vslineno}% + \par\@ifstar{\nobreak\@vsxcentercr}{% + \@vsifbang{\@ifnextchar[ {\@vsicentercr}{}}{\@vsxcentercr}% + }% + }{% + \@vstypelinenum + \incr@vsline% + \par\@ifstar{\nobreak\@vsxcentercr}{% + \@vsifbang{\@ifnextchar[ {\@vsicentercr}{}}{\@vsxcentercr}% + }% + }% + }% + } + }{} \if@pkg@poetry@verse \patchcmd{\start@vsline}{% \ifaltindent}{% @@ -1513,7 +1581,8 @@ code type = \def\type@value{#1}, } \ifekd@memoir@loaded - \linenumberfont{\normalfont\footnotesize} + \def\vlvnumfont{\normalfont\footnotesize} + \def\verselinenumfont#1{\def\vlvnumfont{#1}} \else \verselinenumfont{\normalfont\footnotesize} \fi |