[latex3-commits] [git/LaTeX3-latex3-latex2e] gh253: implementation for #253 (bb252af8)
Frank Mittelbach
frank.mittelbach at latex-project.org
Tue Oct 5 11:55:08 CEST 2021
Repository : https://github.com/latex3/latex2e
On branch : gh253
Link : https://github.com/latex3/latex2e/commit/bb252af8f6ef14fc8de0f4253a3907a096acd203
>---------------------------------------------------------------
commit bb252af8f6ef14fc8de0f4253a3907a096acd203
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date: Tue Oct 5 11:55:08 2021 +0200
implementation for #253
>---------------------------------------------------------------
bb252af8f6ef14fc8de0f4253a3907a096acd203
base/doc/ltnews34.tex | 17 +++++++++++
base/ltoutenc.dtx | 60 ++++++++++++++++++++++++++++-----------
base/testfiles-TU/github-0253.lvt | 31 ++++++++++++++++++++
base/testfiles-TU/github-0253.tlg | 26 +++++++++++++++++
4 files changed, 117 insertions(+), 17 deletions(-)
diff --git a/base/doc/ltnews34.tex b/base/doc/ltnews34.tex
index 57e101e8..f4d78bdd 100644
--- a/base/doc/ltnews34.tex
+++ b/base/doc/ltnews34.tex
@@ -481,6 +481,23 @@ whether used or not.
+\subsection{Cleanup of the Unicode declaration interface}
+
+When declaring encoding specific commands for the Unicode (TU)
+encoding some declarations, such as \cs{DeclareUnicodeComposite} do
+not have the encoding name as an explicit argument but use
+\cs{UnicodeEncodingName} implicitly. Others, such as
+\cs{DeclareUnicodeAccent} require it as an explicit argument. This
+inconsistency has now been removed and the encoding name is always
+implicit. To avoid a breaking change for a few packages on CTAN
+\cs{DeclareUnicodeAccent} still accepts three arguments if the second
+argument is \texttt{TU} or \cs{UnicodeEncodingName}. Once all packages
+have been updated this code branch will get removed.
+%
+\githubissue{253}
+
+
+
\subsection{???}
%
diff --git a/base/ltoutenc.dtx b/base/ltoutenc.dtx
index 14518d2f..58e63788 100644
--- a/base/ltoutenc.dtx
+++ b/base/ltoutenc.dtx
@@ -3016,8 +3016,31 @@
\char#1\relax}
% \end{macrocode}
%
-% \begin{macrocode}
-\def\DeclareUnicodeAccent#1#2#3{%
+% In its original implementation \cs{DeclareUnicodeAccent} was
+% given 3 arguments (with second the ``Unicode encoding'' a.k.a.,
+% \cs{UnicodeEncodingName}) while in other places, e.g.,
+% \cs{DeclareUnicodeComposite}, we always made encoding implicit. So
+% we now change it here to implicit too so that the interfaces
+% become a bit more consistent. To avoid making that a
+% breaking change (even though it only affects two packages on
+% CTAN) we test for \verb=#2= being \cs{UnicodeEncodingName}. This
+% would not catch if somebody used
+% \verb|\DeclareUnicodeAccent{\=}{TU-sub}{"0304}|
+% but that fortunately hasn't happened. With the implicit argument
+% you would need to change \cs{UnicodeEncodingName} instead, as you
+% have to do anyway for the other interface commands.
+% \begin{macrocode}
+\def\DeclareUnicodeAccent#1#2{%
+ \edef\reserved at a{#2}%
+ \edef\reserved at b{\UnicodeEncodingName}%
+ \ifx\reserved at a\reserved at b
+ \def\reserved at a{\DeclareUnicodeAccent@{#1}}%
+ \else
+ \def\reserved at a{\DeclareUnicodeAccent@{#1}\UnicodeEncodingName}%
+ \fi
+ \reserved at a{#2}%
+}
+\def\DeclareUnicodeAccent@#1#2#3{%
\DeclareTextCommand{#1}{#2}{\add at unicode@accent{#3}}%
}
% \end{macrocode}
@@ -3264,21 +3287,24 @@
% \end{macrocode}
% Accents must be declared before the composites that use them.
% \begin{macrocode}
-\DeclareUnicodeAccent{\`} \UnicodeEncodingName{"0300}
-\DeclareUnicodeAccent{\'} \UnicodeEncodingName{"0301}
-\DeclareUnicodeAccent{\^} \UnicodeEncodingName{"0302}
-\DeclareUnicodeAccent{\~} \UnicodeEncodingName{"0303}
-\DeclareUnicodeAccent{\=} \UnicodeEncodingName{"0304}
-\DeclareUnicodeAccent{\u} \UnicodeEncodingName{"0306}
-\DeclareUnicodeAccent{\.} \UnicodeEncodingName{"0307}
-\DeclareUnicodeAccent{\"} \UnicodeEncodingName{"0308}
-\DeclareUnicodeAccent{\r} \UnicodeEncodingName{"030A}
-\DeclareUnicodeAccent{\H} \UnicodeEncodingName{"030B}
-\DeclareUnicodeAccent{\v} \UnicodeEncodingName{"030C}
-\DeclareUnicodeAccent{\b} \UnicodeEncodingName{"0332}
-\DeclareUnicodeAccent{\d} \UnicodeEncodingName{"0323}
-\DeclareUnicodeAccent{\c} \UnicodeEncodingName{"0327}
-\DeclareUnicodeAccent{\k} \UnicodeEncodingName{"0328}
+\DeclareUnicodeAccent{\`}{"0300}
+\DeclareUnicodeAccent{\'}{"0301}
+\DeclareUnicodeAccent{\^}{"0302}
+\DeclareUnicodeAccent{\~}{"0303}
+\DeclareUnicodeAccent{\=}{"0304}
+\DeclareUnicodeAccent{\u}{"0306}
+\DeclareUnicodeAccent{\.}{"0307}
+\DeclareUnicodeAccent{\"}{"0308}
+\DeclareUnicodeAccent{\r}{"030A}
+\DeclareUnicodeAccent{\H}{"030B}
+\DeclareUnicodeAccent{\v}{"030C}
+\DeclareUnicodeAccent{\b}{"0332}
+\DeclareUnicodeAccent{\d}{"0323}
+\DeclareUnicodeAccent{\c}{"0327}
+\DeclareUnicodeAccent{\k}{"0328}
+% \end{macrocode}
+% The odd one out:
+% \begin{macrocode}
\DeclareTextCommand\textcommabelow \UnicodeEncodingName[1]
{\hmode at bgroup\ooalign{\null#1\crcr\hidewidth\raise-.31ex
\hbox{\check at mathfonts\fontsize\ssf at size\z@
diff --git a/base/testfiles-TU/github-0253.lvt b/base/testfiles-TU/github-0253.lvt
new file mode 100644
index 00000000..f09b24a7
--- /dev/null
+++ b/base/testfiles-TU/github-0253.lvt
@@ -0,0 +1,31 @@
+\documentclass{article}
+
+\pagestyle{empty}
+
+\input{test2e}
+
+\START
+
+\ShowCommand\=
+\expandafter\show
+\csname TU\string\=\endcsname
+
+\DeclareUnicodeAccent{\=}\UnicodeEncodingName{"0300}
+
+% composites change the internals, so we have to apply at least one again
+\DeclareUnicodeComposite{\=} {A}{"0100}
+
+\ShowCommand\=
+\expandafter\show
+\csname TU\string\=\endcsname
+
+
+\DeclareUnicodeAccent{\=}{"0304} % new syntax
+\relax
+\DeclareUnicodeComposite{\=} {A}{"0100}
+
+\ShowCommand\=
+\expandafter\show
+\csname TU\string\=\endcsname
+
+\END
diff --git a/base/testfiles-TU/github-0253.tlg b/base/testfiles-TU/github-0253.tlg
new file mode 100644
index 00000000..054fa5e5
--- /dev/null
+++ b/base/testfiles-TU/github-0253.tlg
@@ -0,0 +1,26 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+> \==macro:
+->\TU-cmd \=\TU\= .
+<argument> \=
+l. ...\ShowCommand\=
+> \TU\==macro:
+#1->\@text at composite \TU\= #1\@empty \@text at composite {\add at unicode@accent {"0304}{#1}}.
+<recently read> \TU\=
+l. ...\csname TU\string\=\endcsname
+> \==macro:
+->\TU-cmd \=\TU\= .
+<argument> \=
+l. ...\ShowCommand\=
+> \TU\==macro:
+#1->\@text at composite \TU\= #1\@empty \@text at composite {\add at unicode@accent {"0300}{#1}}.
+<recently read> \TU\=
+l. ...\csname TU\string\=\endcsname
+> \==macro:
+->\TU-cmd \=\TU\= .
+<argument> \=
+l. ...\ShowCommand\=
+> \TU\==macro:
+#1->\@text at composite \TU\= #1\@empty \@text at composite {\add at unicode@accent {"0304}{#1}}.
+<recently read> \TU\=
+l. ...\csname TU\string\=\endcsname
More information about the latex3-commits
mailing list.