From a8880a5ee484845d9a526c5ca8d21d31214af22b Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Sun, 8 Mar 2020 03:01:00 +0000
Subject: CTAN sync 202003080300

---
 macros/latex/contrib/reledmac/reledmac.dtx | 105 +++++++++++++++++------------
 1 file changed, 62 insertions(+), 43 deletions(-)

(limited to 'macros/latex/contrib/reledmac/reledmac.dtx')

diff --git a/macros/latex/contrib/reledmac/reledmac.dtx b/macros/latex/contrib/reledmac/reledmac.dtx
index 41a7e62244..2634484f6a 100644
--- a/macros/latex/contrib/reledmac/reledmac.dtx
+++ b/macros/latex/contrib/reledmac/reledmac.dtx
@@ -295,7 +295,7 @@
 % \changes{v1.23.0}{2015/05/18}{Compatibility between nofamiliar/nocriticals option and minipage/ledgroup.}
 % \changes{v1.23.0}{2015/05/18}{Fix error of \protect\cs{iftrue} not closed.}
 % \changes{v1.23.0}{2015/05/18}{Allow use of \protect\cs{sameword} with inputenc managing of UTF-8.}
-% \changes{v1.23.0}{2015/05/18}{Error message when using \protect\cs{beginnumbering}\ ...\ \protect\cs{endnumbering} without \protect\cs{pstart}.}
+% \changes{v1.23.0}{2015/05/18}{Error message when using \protect\cs{beginnumbering}\ldots\ \protect\cs{endnumbering} without \protect\cs{pstart}.}
 % \changes{v1.23.0}{2015/05/18}{New tools to ensure the line-list file uses the right version of commands when upgrading the eledmac version.}
 % \changes{v1.23.0}{2015/05/18}{Fix a bug with \protect\cs{skipnumbering} called immediately after a \protect\cs{pstart}.}
 % \changes{v1.23.0}{2015/05/18}{Fix spurious space with \protect\cs{skipnumbering} (bug added on v1.21.0).}
@@ -382,7 +382,7 @@
 % \changes{v2.7.2}{2015/12/13}{Fix problem of hyphenation when using \protect\package{hyperref} package (added in v2.7.0).}
 % \changes{v2.8.0}{2016/01/15}{\protect\macpackage cross-referencing can take advantage of \protect\package{xr} package.}
 % \changes{v2.8.0}{2016/01/15}{No indentation for paragraphed notes in ledgroup. Can be changed with \protect\cs{Xparindent} and \protect\cs{parindentX}.}
-% \changes{v2.8.0}{2016/01/15}{More \protect\cs{edgls...} commands.}
+% \changes{v2.8.0}{2016/01/15}{More \protect\cs{edgls\ldots} commands.}
 % \changes{v2.8.1}{2016/02/22}{Warnings for undefined labels are really parsable by latexmk}
 % \changes{v2.8.2}{2016/02/27}{Fix a bug with \protect\cs{AtEveryPstart} added in version 2.0.0.}
 % \changes{v2.8.2}{2016/02/27}{Fix a bug with vertical space after the between-sectioning command as optional argument of a \protect\cs{pstart} and \protect\cs{pstart} content}
@@ -449,8 +449,8 @@
 % \changes{v2.16.5}{2016/10/20}{Fix potential spurious spaces in endnotes.}
 % \changes{v2.16.6}{2016/11/14}{Take into account \protect\cs{linenumberstyle} when using \protect\cs{edlineref}.}
 % \changes{v2.16.6}{2016/11/14}{Fix a bug with the line number style in \protect\cs{doennotes} when referring to right side line in parallel typesetting.}
-% \changes{v2.16.7}{2016/12/12}{Fix a bug with \protect\cs{numberpstarttrue} when using multiple \protect\cs{beginnumbering}\ ...\ \protect\cs{endnumbering}.}
-% \changes{v2.16.7}{2016/12/12}{Fix a bug with \protect\cs{msdata} when using multiple \protect\cs{beginnumbering}\ ...\ \protect\cs{endnumbering}.}
+% \changes{v2.16.7}{2016/12/12}{Fix a bug with \protect\cs{numberpstarttrue} when using multiple \protect\cs{beginnumbering}\ldots\ \protect\cs{endnumbering}.}
+% \changes{v2.16.7}{2016/12/12}{Fix a bug with \protect\cs{msdata} when using multiple \protect\cs{beginnumbering}\ldots\ \protect\cs{endnumbering}.}
 % \changes{v2.16.8}{2016/12/16}{Fix a bug with \protect\cs{edindex} in footnotes in parallel typesetting.}
 % \changes{v2.17.0}{2016/12/23}{Add \protect\cs{edglsadd} command.}
 % \changes{v2.17.0}{2016/12/23}{Add \protect\cs{setmsdataposition} setting.}
@@ -540,9 +540,12 @@
 % \changes{v2.32.2}{2019/11/28}{Fix spurious vertical space in familiar footnotes with \protect\LuaLaTeX.}
 % \changes{v2.32.3}{2019/12/09}{Fix bug with critical footnotes when typesetting arabic text with \protect\package{polyglossia}.}
 % \changes{v2.32.4}{2020/02/04}{Fix bug \protect\cs{footnoteXmark} and \protect\cs{footnoteXtext}.}
-% \changes{v2.32.4}{2020/01/04}{\protect\cs{footnoteXmark} and \protect\cs{footnoteXtext} can now have an optional argument, setting the footnotenote number.}
+% \changes{v2.32.4}{2020/01/04}{\protect\cs{footnoteXmark} and \protect\cs{footnoteXtext} can now have an optional argument, setting the footnote number.}
 % \changes{v2.32.4}{2020/02/04}{Fix bug when using \protect\cs{Xgroupbyline} and twocol arrangement.}
 % \changes{v2.32.4}{2020/02/04}{Fix bug with three and two columns footnotes when using \protect\package{bidi}.}
+% \changes{v2.32.5}{2020/03/08}{Fix bug with \protect\cs{edindex} inside \protect\cs{eledsection} and related.}
+% \changes{v2.32.5}{2020/03/08}{Fix bug with page number in index with \protect\cs{edindex} when indexing a critical notes.}
+% \changes{v2.32.5}{2020/03/08}{Fix bug with macro inside \protect\cs{sameword} with no-\protect\XeTeX\ engines.}
 %      Typeset scholarly editions with \LaTeX\thanks{This file (\dtxfilename)
 % has version number \fileversion, last revised \filedate.}}
 %
@@ -801,6 +804,7 @@
 %
 %Please read \reff{Xmaxhnotes}.
 %
+% If you use \LuaTeX\  engine, you need \LuaTeX\ 1.1.0 or later.
 % A file may mix \emph{numbered} and \emph{unnumbered} text.
 %
 % Numbered text is printed with marginal line numbers and can include
@@ -1395,7 +1399,7 @@
 % If you want to change the separator, you can use \\
 % \cs{setlinenumannotationsep}\marg{sep}
 % \subsubsection{Annotations in the apparatus}
-% Some others options for the annotation in the apparatus are described on \reff{annotation-inapparatus}
+% Some other options for the annotation in the apparatus are described on \reff{annotation-inapparatus}
 % \subsection{Executing code at each line}\label{linehook}
 % \Macpackage provides an advanced feature for users.
 % \DescribeMacro{\dolinehook}\DescribeMacro{\doinsidelinehook}
@@ -1779,6 +1783,10 @@
 %
 % With these tools, \XeTeX\ / \LuaTeX\ will dynamicaly normalize unicode input when reading the file.
 % Consequently, you will have no problems with the \protect\cs{sameword} command.
+% \subsubsection{Notes about right-to-left texts}
+% Due to some internal limits of \XeTeX, \cs{sameword} does not work with right-to-left text with this engine.
+%
+% If you need to use \cs{sameword} with right-to-left text, you must use \LuaTeX.
 % \subsubsection{Use with \protect\cs{lemma} command}
 % If you use the \protect\cs{lemma} command, \macpackage\ cannot know to which occurence of \cs{sameword} in the first argument of \cs{edtext} a word marked with \cs{sameword} in \cs{lemma} should refer.
 %
@@ -2267,7 +2275,7 @@
 % \subsubsection{Print line number only at first time}
 % \DescribeMacro{\Xnumberonlyfirstinline}\label{Xnumberonlyfirstinline}
 % \changes{v1.0.1}{2012/09/16}{Correction on \protect\cs{Xnumberonlyfirstinline} with lineation by pstart or by page.}
-% By default, the line number is printed in every note. If you want to print it only the first time for a given line number
+% By default, the line number is printed inside every note. If you want to print it only the first time for a given line number
 % (i.e., once for line 1, once for line 2, etc.), you can use \protect\cs{Xnumberonlyfirstinline}\oarg{s}.
 %
 %
@@ -2289,18 +2297,18 @@
 %
 % \subsubsection{Print line number annotation only at first time}\label{annotation-inapparatus}
 % \DescribeMacro{\Xlinenumannotationonlyfirst}
-% By default, the line number annotation (\reff{annotion} is printed in every note. If you want to print it only the first time for a given annotation
+% By default, the line number annotation (\reff{annotion} is printed inside every note. If you want to print it only the first time for a given annotation
 % you can use \cs{Xlinenumannotationonlyfirst}\oarg{s}.
 %
-% Note the two followings points:
+% Note the two following points:
 % \begin{itemize}
 % \item If you use \option{noresetlinenumannotation} option of \macpackage, the \cs{Xlinenumannotationonlyfirst} won't take account of the official line number.
-% \item The \cs{Xlinenumannotationonlyfirst} works for consecutive lemma with the same annotation. That is, if you have for example a lemma with \verb+A+ annotation, then a lemma with \verb+B+ annotation, then a lemma with \verb+A+ annotation, all lemma will have its annotation in the apparatus.
+% \item The \cs{Xlinenumannotationonlyfirst} works for consecutive lemmas with the same annotation. That is, if you have for example a lemma with \verb+A+ annotation, then a lemma with \verb+B+ annotation, then a lemma with \verb+A+ annotation, all lemmas will have its own annotation in the apparatus.
 % \end{itemize}
 %
 % \DescribeMacro{\Xlinenumannotationonlyfirstintwo}
-% Suppose you have a lemma on annoation~1 and a lemma between annotation~1 and annotation~3.
-% With \cs{Xlinenumannotationonlyfirst}, the second lemma is considered to be with the same line annotation as the first lemma.
+% Suppose you have a lemma on annotation~1 and a lemma between annotation~1 and annotation~3.
+% With \cs{Xlinenumannotationonlyfirst}, the second lemma is considered to have the same annotation as the first lemma.
 % But if  you use both \cs{Xlinenumannotationonlyfirst}\oarg{s} and \cs{Xlinenumannotationonlyfirstintwo}\oarg{s}, a distinction is made.
 %
 %
@@ -4321,7 +4329,7 @@
 %    \begin{macrocode}
 %<*code>
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{reledmac}[2020/02/04 v2.32.4 typesetting critical editions]%
+\ProvidesPackage{reledmac}[2020/03/08 v2.32.5 typesetting critical editions]%
 %    \end{macrocode}
 %
 % \subsection{Package options}
@@ -4494,6 +4502,11 @@
 \ifx\directlua\undefined\else%
   \directlua{tex.enableprimitives("",{"textdir","pardir","bodydir"})}
 \fi
+\ifluatex%
+  \ifnum\luatexversion<110%
+    \PackageWarning{reledmac}{You need to use LuaTeX 1.1.0 or higher}{\@ehc}%
+  \fi%
+\fi%
 %    \end{macrocode}
 % \subsection{Boolean flags}
 % \begin{macro}{\ifl@dmemoir}
@@ -4590,7 +4603,13 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
-%
+% \begin{macro}{\led@err@samewordRTL}
+%    \begin{macrocode}
+\newcommand*{\led@err@samewordRTL}{%
+  \reledmac@error{You can't use \string\sameword \MessageBreak with XeLaTeX \MessageBreak when typesetting RTL text.\MessageBreak Please use LuaTeX instead.}{\@ehc}%
+}%
+%    \end{macrocode}
+% \end{macro}
 % \begin{macro}{\led@err@edtextoutsidepstart}
 % \begin{macro}{\led@err@PstartInEdtext}
 % \begin{macro}{\led@err@PendInEdtext}
@@ -7287,7 +7306,7 @@
 % \end{macro}
 % \end{macro}
 % \begin{macro}{\new@line}
-% \begin{macro}{\l@the@c@page}
+% \begin{macro}{\set@this@c@page}
 % The \protect\cs{new@line} macro sends the \protect\cs{@nl} command to the line-list
 % file, to mark the start of a new text line, and its page number.
 % \label{new@line@pagecounting}
@@ -7305,6 +7324,7 @@
 % \changes{v0.6.0}{2004/11/16}{Extended \protect\cs{new@line} to output page numbers}
 %    \begin{macrocode}
 \newcommand*{\new@line}{%
+  \set@this@c@page%
   \ifnumberline%
     \IfStrEq{\led@pb@setting}{after}%
       {\xifinlist{\the\absline@num}{\l@prev@nopb}%
@@ -7312,9 +7332,9 @@
           {\numgdef{\@next@page}{\c@par@page+\@ne}%
           \write\linenum@out{\string\@nl[\@next@page][\@next@page]}%
         }%
-        {\write\linenum@out{\string\@nl[\the\c@par@page][\thepage]}}%
+        {\write\linenum@out{\string\@nl[\the\@this@c@page][\thepage]}}%
       }%
-      {\write\linenum@out{\string\@nl[\the\c@par@page][\thepage]}}}%
+      {\write\linenum@out{\string\@nl[\the\@this@c@page][\thepage]}}}%
     {}%
     \IfStrEq{\led@pb@setting}{before}%
       {\numdef{\next@absline}{\the\absline@num+\@ne}%
@@ -7323,9 +7343,9 @@
           {\numgdef{\nc@page}{\c@par@page+\@ne}%
           \write\linenum@out{\string\@nl[\nc@page][\nc@page]}%
           }%
-          {\write\linenum@out{\string\@nl[\the\c@par@page][\thepage]}}%
+          {\write\linenum@out{\string\@nl[\the\@this@c@page][\thepage]}}%
         }%
-        {\write\linenum@out{\string\@nl[\the\c@par@page][\thepage]}}%
+        {\write\linenum@out{\string\@nl[\the\@this@c@page][\thepage]}}%
       }%
       {}%
     \IfStrEqCase{\led@pb@setting}%
@@ -7333,18 +7353,19 @@
       {before}{\relax}%
       {after}{\relax}%
     }[%
-      \write\linenum@out{\string\@nl[\the\c@par@page][\thepage]}%
+      \write\linenum@out{\string\@nl[\the\@this@c@page][\thepage]}%
     ]%
   \fi%
 }
 
-\newcommand{\l@the@c@page}{%
+\newcount\@this@c@page%%
+\newcommand{\set@this@c@page}{%
   \ifboolexpr{%
     bool{sameparallelpagenumber}%
     or bool{prevpgnotnumbered}%
   }%
-  {\the\c@par@page}%
-  {\the\c@page}%
+  {\global\@this@c@page=\c@par@page}%
+  {\global\@this@c@page=\c@page}%
 }%
 %    \end{macrocode}
 % \end{macro}
@@ -8258,7 +8279,7 @@
 % The general mechanism is the following:
 % \begin{itemize}
 %    \item \textbf{At the first run}, each \protect\cs{sameword} command increments an \protect\package{etoolbox} counter the name of which contains the argument of the \protect\cs{sameword} commands.
-%    \item Then this counter, associated with the argument of \protect\cs{sameword} is stored with the \protect\cs{@sw} command in the auxiliary file of the current \macpackage\ section (the \verb+.1+, \verb+.2+... file).
+%    \item Then this counter, associated with the argument of \protect\cs{sameword} is stored with the \protect\cs{@sw} command in the auxiliary file of the current \macpackage\ section (the \verb+.1+, \verb+.2+\ldots\ file).
 %    \item \textbf{When this auxiliary file is read at the second run}, different operations are achieved:
 %  \begin{enumerate}
 %         \item  Get the rank of each \protect\cs{sameword} in a line (relative rank) from the rank of each \protect\cs{sameword} in all the numbered section (absolute rank):
@@ -8329,13 +8350,8 @@
 %   \end{itemize}
 % \end{itemize}
 % After theory, implementation.
+% First, getting a sanitized form of the argument of \cs{sameword}
 % \begin{macro}{\get@sw@txt}
-% As the argument of \protect\cs{sameword} can contain an active character if we
-% use \protect\package{inputenc} with \verb+utf8+ option instead of native UTF-8 engine,
-% we store its detokenized content in a macro in order to allow the dynamic name of macro with \protect\cs{csname}.\footnote{See \url{http://tex.stackexchange.com/q/244538/7712}.}
-%
-% Because there is a bug with \protect\cs{detokenize} and \XeTeX\ when using non BMP characters\footnote{\url{http://sourceforge.net/p/xetex/bugs/108/}},
-% we detokenize only for non-\XeTeX engines. In any case, in \XeTeX a \protect\cs{csname} construction can contain UTF-8 characters without a problem, as UTF-8 characters are not managed with category codes, but instead read directly as UTF-8 characters.
 %    \begin{macrocode}
 \newcommand{\get@sw@txt}[1]{%
   \begingroup%
@@ -8351,11 +8367,7 @@
 %    \end{macrocode}
 % And now, define \cs{sw@txt}.
 %   \begin{macrocode}
-    \ifxetex%
-      \@tmpa{\xdef\sw@txt{#1}}%
-    \else%
-      \@tmpa{\expandafter\xdef\expandafter\sw@txt\expandafter{\detokenize{#1}}}%
-    \fi%
+      \@tmpa{\protected@xdef\sw@txt{#1}}%
   \endgroup%
 }%
 %    \end{macrocode}
@@ -8393,6 +8405,11 @@
 % The hight level macro \protect\cs{sameword}, used by the editor.
 %    \begin{macrocode}
 \newcommandx{\sameword}[2][1,usedefault]{%
+     \ifxetex%
+       \if@RTL%
+        \led@err@samewordRTL%
+       \fi%
+     \fi%
      \leavevmode%
      \get@sw@txt{#2}%
 %    \end{macrocode}
@@ -8829,7 +8846,7 @@
     }%
 %    \end{macrocode}
 % Restore standard \enquote{nobreak} and \enquote{autopar} settings.
-% Normally, \cs{if@nobreak} is true only immediately after a sectioning command (see latex.ltx file). As a \cs{pstart}\ ...\ \cs{pend} structure can't contain any sectioning command, we set \cs{if@nobreak} to false.
+% Normally, \cs{if@nobreak} is true only immediately after a sectioning command (see latex.ltx file). As a \cs{pstart}\ldots\  \cs{pend} structure can't contain any sectioning command, we set \cs{if@nobreak} to false.
 %    \begin{macrocode}
   \@nobreakfalse%
   \ifautopar%
@@ -9123,6 +9140,7 @@
 % Because of how this prints, a vertical spacing correction is added.
 %    \begin{macrocode}
 \def\print@eledsection{%
+    \disable@edindex%
     \if@firstlineofpage%
       \set@Xtxtbeforenotes%
       \set@txtbeforenotesX%
@@ -9153,6 +9171,7 @@
     \fi%
     \vskip-\baselineskip%
     \continuousnumberingwithcolumns@sync@linenumber@singletext%
+    \restore@edindex%
 }
 %    \end{macrocode}
 % \end{macro}
@@ -12274,13 +12293,6 @@
 \def\printlines#1|#2|#3|#4|#5|#6|#7|#8|{%
   \begingroup%
 %    \end{macrocode}
-% If we use \LuaTeX, ensure we use good text's direction.
-%    \begin{macrocode}
-  \ifluatex%
-    \edef\@tmp{\the\textdir}%
-    \ifdefstring{\@tmp}{TLT}{}{\textdir TLT}%Test in order to prevent spurious space (bug #397)
-  \fi%
-%    \end{macrocode}
 % Decide which part of line number components we will print.
 %    \begin{macrocode}
   \setprintlines{#1}{#2}{#3}{#4}{#5}{#6}%
@@ -18000,6 +18012,8 @@
 {\led@error@fail@patch@makeindex}%
 \newcommand{\edindex}[1]{\@bsphack\@esphack}
 \newcommandx{\dummy@edindex}[2][1=\expandonce\jobname,usedefault]{}%
+\newcommand{\disable@edindex}{\let\old@edindex\edindex\let\edindex\dummy@edindex}%
+\newcommand{\restore@edindex}{\let\edindex\old@edindex}%
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -21453,6 +21467,11 @@
 % \subsection{critical-keys for \emph{Emacs}}
 % The \emph{Emacs} editor has a package to help inserting \macpackage's commands (Juan Manuel Macías Chaín).\\
 % \url{https://gitlab.com/maciaschain/critical-keys}
+% \subsection{critical-marks for \emph{Emacs}}
+% A set of functions for \emph{Emacs} that run in the export process from Org Mode to
+% LaTeX and replace a series of simple textual marks with the basic \macpackage's commands (Juan Manuel Macías Chaín)
+% \url{https://gitlab.com/maciaschain/critical-marks}
+%\subsection{Import from TEI}
 % \subsection{Import from TEI}
 % There are multiple tools to convert from XML-TEI to \emph{reledmac}. Here is a non exhaustive-list:
 % \begin{itemize}
-- 
cgit v1.2.3

