diff options
author | Robert Alessi <alessi@robertalessi.net> | 2021-03-07 21:01:58 +0100 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2021-03-07 21:01:58 +0100 |
commit | 33f82d0b5dd71e4a3bf69aee538bba8c86038e61 (patch) | |
tree | 60777968fe8348075ae5f71d12197be1ccf10799 /ekdosis.dtx | |
parent | 67361972da8072e57f1afe3226bf387de99c5bb8 (diff) | |
download | ekdosis-33f82d0b5dd71e4a3bf69aee538bba8c86038e61.tar.gz |
better handling of patterns in linestotei() and versetotei()
Diffstat (limited to 'ekdosis.dtx')
-rw-r--r-- | ekdosis.dtx | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx index 36d6e8c..0badedd 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx | |||
@@ -3052,11 +3052,11 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+ | |||
3052 | % \DescribeOption{lang} |lang|$=$\meta{languagename} | 3052 | % \DescribeOption{lang} |lang|$=$\meta{languagename} |
3053 | % \newfeature[v1.2]\label{ref:app-lang-opt} | 3053 | % \newfeature[v1.2]\label{ref:app-lang-opt} |
3054 | % \hfill\tcboxverb{Default: not set}\\ | 3054 | % \hfill\tcboxverb{Default: not set}\\ |
3055 | % |lang=<languagename>| is used as described \vpageref{ref:app-lang} | 3055 | % |lang=<languagename>| is used as described |
3056 | % when it is needed to apply in the apparatus criticus a language | 3056 | % \vpageref[above]{ref:app-lang} when it is needed to apply in the |
3057 | % different from the one that is selected in the edition | 3057 | % apparatus criticus a language different from the one that is |
3058 | % text. |languagename| can be any value accepted by \pkg{babel} or | 3058 | % selected in the edition text. |languagename| can be any value |
3059 | % \pkg{polyglossia}. | 3059 | % accepted by \pkg{babel} or \pkg{polyglossia}. |
3060 | % | 3060 | % |
3061 | % As an example, an apparatus criticus with references to line numbers | 3061 | % As an example, an apparatus criticus with references to line numbers |
3062 | % printed in normal font, a colon as a separator between lemma texts | 3062 | % printed in normal font, a colon as a separator between lemma texts |
@@ -8050,8 +8050,8 @@ local app = lpeg.Cs("app") | |||
8050 | local lemrdg = lpeg.Cs(lpeg.Cs("lem") + lpeg.Cs("rdg")) | 8050 | local lemrdg = lpeg.Cs(lpeg.Cs("lem") + lpeg.Cs("rdg")) |
8051 | local note = lpeg.Cs("note") | 8051 | local note = lpeg.Cs("note") |
8052 | local lnbrk = lpeg.Cs("\\\\") | 8052 | local lnbrk = lpeg.Cs("\\\\") |
8053 | local poemline = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.S("*!")^-1 * bsqbrackets^-1) | 8053 | local poemline = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.S("*!")^-1 * bsqbrackets^-1 * spcenc^-1) |
8054 | local poemlineb = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.P(">") * bsqbrackets^-1) | 8054 | local poemlineb = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.P(">") * bsqbrackets^-1 * spcenc^-1) |
8055 | local endpoem = lpeg.Cs(lnbrk * lpeg.S("*!") * bsqbrackets^-1) | 8055 | local endpoem = lpeg.Cs(lnbrk * lpeg.S("*!") * bsqbrackets^-1) |
8056 | local sections = lpeg.Cs(lpeg.P("book") + lpeg.P("part") + lpeg.P("chapter") | 8056 | local sections = lpeg.Cs(lpeg.P("book") + lpeg.P("part") + lpeg.P("chapter") |
8057 | + lpeg.P("section") + lpeg.P("subsection") | 8057 | + lpeg.P("section") + lpeg.P("subsection") |
@@ -8651,7 +8651,7 @@ local function linestotei(str) | |||
8651 | -- str = string.gsub(str, "^%s?(.-)\\\\[%!%*]?%s?$", "\n<l>%1</l>\n") | 8651 | -- str = string.gsub(str, "^%s?(.-)\\\\[%!%*]?%s?$", "\n<l>%1</l>\n") |
8652 | str = gsub(str, poemline * spcenc^-1 * -1, "</l>\n") | 8652 | str = gsub(str, poemline * spcenc^-1 * -1, "</l>\n") |
8653 | -- str = gsub(str, endpoem, "</l>\n") | 8653 | -- str = gsub(str, endpoem, "</l>\n") |
8654 | str = gsub(str, poemlineb, "\n<lb/>") | 8654 | str = gsub(str, poemlineb, "<lb/> ") |
8655 | str = gsub(str, poemline, "</l>\n<l>") | 8655 | str = gsub(str, poemline, "</l>\n<l>") |
8656 | -- str = str.."</l>\n" | 8656 | -- str = str.."</l>\n" |
8657 | return str | 8657 | return str |
@@ -8660,18 +8660,22 @@ end | |||
8660 | -- better use lpeg: look into this later | 8660 | -- better use lpeg: look into this later |
8661 | local function versetotei(str) | 8661 | local function versetotei(str) |
8662 | str = string.gsub(str, "(\\begin%s?%{ekdverse%})(%b[])(.-)(\\end%s?%{ekdverse%})", function(benv, opt, arg, eenv) | 8662 | str = string.gsub(str, "(\\begin%s?%{ekdverse%})(%b[])(.-)(\\end%s?%{ekdverse%})", function(benv, opt, arg, eenv) |
8663 | arg = string.gsub(arg, "\\par%s?", "") | ||
8663 | arg = linestotei(arg) | 8664 | arg = linestotei(arg) |
8664 | return string.format("%s%s%s%s", benv, opt, arg, eenv) | 8665 | return string.format("%s%s%s%s", benv, opt, arg, eenv) |
8665 | end) | 8666 | end) |
8666 | str = string.gsub(str, "(\\begin%s?%{ekdverse%})(.-)(\\end%s?%{ekdverse%})", function(benv, arg, eenv) | 8667 | str = string.gsub(str, "(\\begin%s?%{ekdverse%})(.-)(\\end%s?%{ekdverse%})", function(benv, arg, eenv) |
8668 | arg = string.gsub(arg, "\\par%s?", "") | ||
8667 | arg = linestotei(arg) | 8669 | arg = linestotei(arg) |
8668 | return string.format("%s%s%s", benv, arg, eenv) | 8670 | return string.format("%s%s%s", benv, arg, eenv) |
8669 | end) | 8671 | end) |
8670 | str = string.gsub(str, "(\\begin%s?%{verse%})(%b[])(.-)(\\end%s?%{verse%})", function(benv, opt, arg, eenv) | 8672 | str = string.gsub(str, "(\\begin%s?%{verse%})(%b[])(.-)(\\end%s?%{verse%})", function(benv, opt, arg, eenv) |
8673 | arg = string.gsub(arg, "\\par%s?", "") | ||
8671 | arg = linestotei(arg) | 8674 | arg = linestotei(arg) |
8672 | return string.format("%s%s%s%s", benv, opt, arg, eenv) | 8675 | return string.format("%s%s%s%s", benv, opt, arg, eenv) |
8673 | end) | 8676 | end) |
8674 | str = string.gsub(str, "(\\begin%s?%{verse%})(.-)(\\end%s?%{verse%})", function(benv, arg, eenv) | 8677 | str = string.gsub(str, "(\\begin%s?%{verse%})(.-)(\\end%s?%{verse%})", function(benv, arg, eenv) |
8678 | arg = string.gsub(arg, "\\par%s?", "") | ||
8675 | arg = linestotei(arg) | 8679 | arg = linestotei(arg) |
8676 | return string.format("%s%s%s", benv, arg, eenv) | 8680 | return string.format("%s%s%s", benv, arg, eenv) |
8677 | end) | 8681 | end) |