diff options
author | Robert Alessi <alessi@robertalessi.net> | 2021-03-05 11:35:53 +0100 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2021-03-05 11:35:53 +0100 |
commit | e136252b4485d1003f5296cdb07feb27417d9070 (patch) | |
tree | 151cff5f666ee136e1d9ed20e4452e965e344d93 | |
parent | a716e7c6d21ec84dceace6170c4547047a615e95 (diff) | |
download | ekdosis-e136252b4485d1003f5296cdb07feb27417d9070.tar.gz |
allow to set for the apparatus a language different from the one of the edition text
-rw-r--r-- | ekdosis.dtx | 82 |
1 files changed, 67 insertions, 15 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx index 8b19765..0b5ec2f 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx | |||
@@ -2979,6 +2979,11 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+ | |||
2979 | % document to change the default setting. Leaving this argument empty | 2979 | % document to change the default setting. Leaving this argument empty |
2980 | % as in \cs{SetDefaultRule}|{}| removes the line. | 2980 | % as in \cs{SetDefaultRule}|{}| removes the line. |
2981 | % | 2981 | % |
2982 | % \DescribeMacro{\SetApparatusLanguage} \newfeature[v1.2] | ||
2983 | % \cs{SetApparatusLang}\marg{languagename} can be used when it is | ||
2984 | % needed to apply in the apparatus criticus a language different from | ||
2985 | % the one that is selected in the edition text. | ||
2986 | % | ||
2982 | % \paragraph{General Command} | 2987 | % \paragraph{General Command} |
2983 | % \DescribeMacro{\SetApparatus} \cs{SetApparatus}\marg{csv list of | 2988 | % \DescribeMacro{\SetApparatus} \cs{SetApparatus}\marg{csv list of |
2984 | % apparatus settings}\label{ref:apparatus-settings-b}\\ | 2989 | % apparatus settings}\label{ref:apparatus-settings-b}\\ |
@@ -3011,8 +3016,14 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+ | |||
3011 | % also be used to remove the line.\\ | 3016 | % also be used to remove the line.\\ |
3012 | % \DescribeOption{norule}\hfill\tcboxverb{Default: not set}\\ | 3017 | % \DescribeOption{norule}\hfill\tcboxverb{Default: not set}\\ |
3013 | % |norule| does not accept any value and has the same effect as | 3018 | % |norule| does not accept any value and has the same effect as |
3014 | % |rule=none|.\label{ref:apparatus-settings-e} | 3019 | % |rule=none|.\label{ref:apparatus-settings-e}\\ |
3015 | % | 3020 | % \DescribeOption{lang} |lang|$=$\meta{languagename} |
3021 | % \newfeature[v1.2]\hfill\tcboxverb{Default: not set}\\ | ||
3022 | % |lang=<languagename>| is used as described above when it is needed | ||
3023 | % to apply in the apparatus criticus a language different from the one | ||
3024 | % that is selected in the edition text. |languagename| can be any | ||
3025 | % value accepted by \pkg{babel} or \pkg{polyglossia}. | ||
3026 | % | ||
3016 | % As an example, an apparatus criticus with references to line numbers | 3027 | % As an example, an apparatus criticus with references to line numbers |
3017 | % printed in normal font, a colon as a separator between lemma texts | 3028 | % printed in normal font, a colon as a separator between lemma texts |
3018 | % and variant readings, a broad space as a delimiter between entries | 3029 | % and variant readings, a broad space as a delimiter between entries |
@@ -3106,6 +3117,7 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+ | |||
3106 | % \DescribeOption{ehook} | 3117 | % \DescribeOption{ehook} |
3107 | % \DescribeOption{rule} | 3118 | % \DescribeOption{rule} |
3108 | % \DescribeOption{norule} | 3119 | % \DescribeOption{norule} |
3120 | % \DescribeOption{lang} | ||
3109 | % With regard to layout, any declared layer inherits the default values | 3121 | % With regard to layout, any declared layer inherits the default values |
3110 | % described above in \vref{sec:single-layer-app}. That said, as the | 3122 | % described above in \vref{sec:single-layer-app}. That said, as the |
3111 | % optional argument of \cs{DeclareApparatus} accepts the exact same | 3123 | % optional argument of \cs{DeclareApparatus} accepts the exact same |
@@ -6418,6 +6430,7 @@ Sample text with a \textcolor{red}{word} in red. | |||
6418 | store bhook = \bhook@val, | 6430 | store bhook = \bhook@val, |
6419 | store ehook = \ehook@val, | 6431 | store ehook = \ehook@val, |
6420 | store maxentries = \limit@val, | 6432 | store maxentries = \limit@val, |
6433 | store lang = \lang@val, | ||
6421 | initial direction = LR, | 6434 | initial direction = LR, |
6422 | initial delim = {}, | 6435 | initial delim = {}, |
6423 | initial ehook = {\csname ekd@end@apparatus\endcsname} | 6436 | initial ehook = {\csname ekd@end@apparatus\endcsname} |
@@ -6449,7 +6462,8 @@ Sample text with a \textcolor{red}{word} in red. | |||
6449 | \luastringO{\sep@val}, | 6462 | \luastringO{\sep@val}, |
6450 | \luastringO{\bhook@val}, | 6463 | \luastringO{\bhook@val}, |
6451 | \luastringO{\ehook@val}, | 6464 | \luastringO{\ehook@val}, |
6452 | \luastringO{\limit@val} | 6465 | \luastringO{\limit@val}, |
6466 | \luastringO{\lang@val} | ||
6453 | )} | 6467 | )} |
6454 | \egroup | 6468 | \egroup |
6455 | } | 6469 | } |
@@ -6584,7 +6598,9 @@ Sample text with a \textcolor{red}{word} in red. | |||
6584 | initial delim = {}, | 6598 | initial delim = {}, |
6585 | store rule = \ekd@default@rule, | 6599 | store rule = \ekd@default@rule, |
6586 | initial rule = \rule{0.4\columnwidth}{0.4pt}, | 6600 | initial rule = \rule{0.4\columnwidth}{0.4pt}, |
6587 | noval norule = \def\ekd@default@rule{\mbox{}} | 6601 | noval norule = \def\ekd@default@rule{\mbox{}}, |
6602 | store lang = \ekd@singleapp@lang, | ||
6603 | initial lang = \ltx@ifpackageloaded{babel}{\languagename}{} | ||
6588 | } | 6604 | } |
6589 | % \end{macrocode} | 6605 | % \end{macrocode} |
6590 | % \begin{macro}{\SetApparatus} | 6606 | % \begin{macro}{\SetApparatus} |
@@ -6642,6 +6658,17 @@ Sample text with a \textcolor{red}{word} in red. | |||
6642 | \NewDocumentCommand{\SetUnitDelimiter}{m}{\def\ekd@unit@delim{#1}} | 6658 | \NewDocumentCommand{\SetUnitDelimiter}{m}{\def\ekd@unit@delim{#1}} |
6643 | % \end{macrocode} | 6659 | % \end{macrocode} |
6644 | % \end{macro} | 6660 | % \end{macro} |
6661 | % \begin{macro}{\SetApparatusLanguage} | ||
6662 | % \changes{v1.2}{2021/03/05}{defines an alternate language to be | ||
6663 | % applied in apparatus entries} | ||
6664 | % \cs{SetApparatusLang}\marg{languagename} can be used when | ||
6665 | % it is needed to apply in the apparatus criticus a language | ||
6666 | % different from the one that is selected in the edition text. | ||
6667 | % \begin{macrocode} | ||
6668 | \NewDocumentCommand{\SetApparatusLanguage}{m}{% | ||
6669 | \def\ekd@singleapp@lang{#1}} | ||
6670 | % \end{macrocode} | ||
6671 | % \end{macro} | ||
6645 | % \begin{macro}{\footnoteruletrue} | 6672 | % \begin{macro}{\footnoteruletrue} |
6646 | % \begin{macro}{\footnoterulefalse} | 6673 | % \begin{macro}{\footnoterulefalse} |
6647 | % As \pkg{ekdosis} takes care of drawing a rule separating the main | 6674 | % As \pkg{ekdosis} takes care of drawing a rule separating the main |
@@ -7062,6 +7089,19 @@ Sample text with a \textcolor{red}{word} in red. | |||
7062 | } | 7089 | } |
7063 | % \end{macrocode} | 7090 | % \end{macrocode} |
7064 | % \end{macro} | 7091 | % \end{macro} |
7092 | % \begin{macro}{\app@lang} | ||
7093 | % This macro is used internally by \cs{lem}, \cs{rdg} and \cs{note} to | ||
7094 | % set the language for apparatus entries. | ||
7095 | % \begin{macrocode} | ||
7096 | \def\app@lang{% | ||
7097 | \ifekd@mapps | ||
7098 | \luadirect{tex.sprint(ekdosis.getapplang(\luastring{\ekdan@type}))}% | ||
7099 | \else | ||
7100 | \ekd@singleapp@lang | ||
7101 | \fi | ||
7102 | } | ||
7103 | % \end{macrocode} | ||
7104 | % \end{macro} | ||
7065 | % \begin{macro}{\lem} | 7105 | % \begin{macro}{\lem} |
7066 | % \cs{lem}\oarg{options}\marg{lemma text} inserts \meta{lemma text} | 7106 | % \cs{lem}\oarg{options}\marg{lemma text} inserts \meta{lemma text} |
7067 | % both in the edition text and in the apparatus criticus by default, | 7107 | % both in the edition text and in the apparatus criticus by default, |
@@ -7145,8 +7185,8 @@ Sample text with a \textcolor{red}{word} in red. | |||
7145 | \ifdefined\ekdlr@pre% | 7185 | \ifdefined\ekdlr@pre% |
7146 | \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi | 7186 | \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi |
7147 | \ltx@ifpackageloaded{babel}% | 7187 | \ltx@ifpackageloaded{babel}% |
7148 | {{\noexpand\selectlanguage{\languagename}% | 7188 | {{\unexpanded\expandafter{\ekd@lemmastyle}% |
7149 | \unexpanded\expandafter{\ekd@lemmastyle}% | 7189 | \noexpand\selectlanguage{\app@lang}% |
7150 | \unexpanded\expandafter{\ekdlr@alt}}}% | 7190 | \unexpanded\expandafter{\ekdlr@alt}}}% |
7151 | {\unexpanded\expandafter{\ekd@lemmastyle}% | 7191 | {\unexpanded\expandafter{\ekd@lemmastyle}% |
7152 | \unexpanded\expandafter{\ekdlr@alt}}% | 7192 | \unexpanded\expandafter{\ekdlr@alt}}% |
@@ -7156,8 +7196,8 @@ Sample text with a \textcolor{red}{word} in red. | |||
7156 | \ifdefined\ekdlr@pre% | 7196 | \ifdefined\ekdlr@pre% |
7157 | \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi | 7197 | \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi |
7158 | \ltx@ifpackageloaded{babel}% | 7198 | \ltx@ifpackageloaded{babel}% |
7159 | {{\noexpand\selectlanguage{\languagename}% | 7199 | {{\unexpanded\expandafter{\ekd@lemmastyle}% |
7160 | \unexpanded\expandafter{\ekd@lemmastyle}% | 7200 | \noexpand\selectlanguage{\app@lang}% |
7161 | \unexpanded{#2}}}{% | 7201 | \unexpanded{#2}}}{% |
7162 | {\unexpanded\expandafter{\ekd@lemmastyle}\unexpanded{#2}}}% | 7202 | {\unexpanded\expandafter{\ekd@lemmastyle}\unexpanded{#2}}}% |
7163 | \ifdefined\ekdlr@post% | 7203 | \ifdefined\ekdlr@post% |
@@ -7234,7 +7274,7 @@ Sample text with a \textcolor{red}{word} in red. | |||
7234 | \ifdefined\ekdlr@pre% | 7274 | \ifdefined\ekdlr@pre% |
7235 | \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi | 7275 | \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi |
7236 | \ltx@ifpackageloaded{babel}% | 7276 | \ltx@ifpackageloaded{babel}% |
7237 | {{\noexpand\selectlanguage{\languagename}% | 7277 | {{\noexpand\selectlanguage{\app@lang}% |
7238 | \unexpanded\expandafter{\ekdlr@alt}}}% | 7278 | \unexpanded\expandafter{\ekdlr@alt}}}% |
7239 | {\unexpanded\expandafter{\ekdlr@alt}}% | 7279 | {\unexpanded\expandafter{\ekdlr@alt}}% |
7240 | \ifdefined\ekdlr@post% | 7280 | \ifdefined\ekdlr@post% |
@@ -7243,7 +7283,7 @@ Sample text with a \textcolor{red}{word} in red. | |||
7243 | \ifdefined\ekdlr@pre% | 7283 | \ifdefined\ekdlr@pre% |
7244 | \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi | 7284 | \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi |
7245 | \ltx@ifpackageloaded{babel}% | 7285 | \ltx@ifpackageloaded{babel}% |
7246 | {{\noexpand\selectlanguage{\languagename}\unexpanded{#2}}}{% | 7286 | {{\noexpand\selectlanguage{\app@lang}\unexpanded{#2}}}{% |
7247 | {\unexpanded{#2}}}% | 7287 | {\unexpanded{#2}}}% |
7248 | \ifdefined\ekdlr@post% | 7288 | \ifdefined\ekdlr@post% |
7249 | \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi | 7289 | \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi |
@@ -7342,8 +7382,8 @@ Sample text with a \textcolor{red}{word} in red. | |||
7342 | \current@ref@arg{\ekdn@labelb}{\ekdn@labele}%\hskip .25em | 7382 | \current@ref@arg{\ekdn@labelb}{\ekdn@labele}%\hskip .25em |
7343 | \ifdefined\ekdn@lem | 7383 | \ifdefined\ekdn@lem |
7344 | \ltx@ifpackageloaded{babel}% | 7384 | \ltx@ifpackageloaded{babel}% |
7345 | {{\noexpand\selectlanguage{\languagename}% | 7385 | {{\unexpanded\expandafter{\ekd@lemmastyle}% |
7346 | \unexpanded\expandafter{\ekd@lemmastyle}% | 7386 | \noexpand\selectlanguage{\app@lang}% |
7347 | \unexpanded\expandafter{\ekdn@lem}}}% | 7387 | \unexpanded\expandafter{\ekdn@lem}}}% |
7348 | {\unexpanded\expandafter{\ekd@lemmastyle}% | 7388 | {\unexpanded\expandafter{\ekd@lemmastyle}% |
7349 | \unexpanded\expandafter{\ekdn@lem}}% | 7389 | \unexpanded\expandafter{\ekdn@lem}}% |
@@ -7351,7 +7391,7 @@ Sample text with a \textcolor{red}{word} in red. | |||
7351 | \unexpanded\expandafter{\ekdn@sep}\fi | 7391 | \unexpanded\expandafter{\ekdn@sep}\fi |
7352 | \else\fi% | 7392 | \else\fi% |
7353 | \ltx@ifpackageloaded{babel}% | 7393 | \ltx@ifpackageloaded{babel}% |
7354 | {{\noexpand\selectlanguage{\languagename}\unexpanded{#2}}}{% | 7394 | {{\noexpand\selectlanguage{\app@lang}\unexpanded{#2}}}{% |
7355 | {\unexpanded{#2}}}}}% | 7395 | {\unexpanded{#2}}}}}% |
7356 | \ifekd@mapps% | 7396 | \ifekd@mapps% |
7357 | \unconditional@appin[\ekdan@type]{\note@contents}% | 7397 | \unconditional@appin[\ekdan@type]{\note@contents}% |
@@ -9603,7 +9643,8 @@ function ekdosis.newapparatus(teitype, | |||
9603 | appsep, | 9643 | appsep, |
9604 | appbhook, | 9644 | appbhook, |
9605 | appehook, | 9645 | appehook, |
9606 | applimit) | 9646 | applimit, |
9647 | applang) | ||
9607 | if isintable(apparatuses, teitype) | 9648 | if isintable(apparatuses, teitype) |
9608 | then | 9649 | then |
9609 | tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" | 9650 | tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" |
@@ -9617,12 +9658,23 @@ function ekdosis.newapparatus(teitype, | |||
9617 | sep = appsep, | 9658 | sep = appsep, |
9618 | bhook = appbhook, | 9659 | bhook = appbhook, |
9619 | ehook = appehook, | 9660 | ehook = appehook, |
9620 | limit = applimit}) | 9661 | limit = applimit, |
9662 | lang = applang}) | ||
9621 | end | 9663 | end |
9622 | bagunits[teitype] = 1 | 9664 | bagunits[teitype] = 1 |
9623 | return true | 9665 | return true |
9624 | end | 9666 | end |
9625 | 9667 | ||
9668 | function ekdosis.getapplang(teitype) | ||
9669 | i = get_a_index(teitype, apparatuses) | ||
9670 | if apparatuses[i].lang ~= "" | ||
9671 | then | ||
9672 | return apparatuses[i].lang | ||
9673 | else | ||
9674 | return "\\languagename" | ||
9675 | end | ||
9676 | end | ||
9677 | |||
9626 | function ekdosis.getappdelim(str) | 9678 | function ekdosis.getappdelim(str) |
9627 | for i = 1,#apparatuses | 9679 | for i = 1,#apparatuses |
9628 | do | 9680 | do |