summaryrefslogtreecommitdiff
path: root/macros/latex-dev/required/firstaid/latex2e-first-aid-for-external-files.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex-dev/required/firstaid/latex2e-first-aid-for-external-files.dtx')
-rw-r--r--macros/latex-dev/required/firstaid/latex2e-first-aid-for-external-files.dtx168
1 files changed, 129 insertions, 39 deletions
diff --git a/macros/latex-dev/required/firstaid/latex2e-first-aid-for-external-files.dtx b/macros/latex-dev/required/firstaid/latex2e-first-aid-for-external-files.dtx
index 84ddacb269..702dca0229 100644
--- a/macros/latex-dev/required/firstaid/latex2e-first-aid-for-external-files.dtx
+++ b/macros/latex-dev/required/firstaid/latex2e-first-aid-for-external-files.dtx
@@ -111,8 +111,8 @@
% \end{macrocode}
%
% \begin{macrocode}
-\def\LaTeXFirstAidDate{2021/06/08}
-\def\LaTeXFirstAidVersion{v1.0m}
+\def\LaTeXFirstAidDate{2021/06/28}
+\def\LaTeXFirstAidVersion{v1.0o}
% \end{macrocode}
%
% \begin{macrocode}
@@ -120,8 +120,8 @@
[\LaTeXFirstAidDate\space \LaTeXFirstAidVersion\space
LaTeX kernel fixes to external files and packages]
% \end{macrocode}
- %
-
+%
+%
% \begin{macro}{\FirstAidNeededT}
% This is a very simple help to ensure that we only apply first aid
% to an unmodified package or class. It only works in the case the
@@ -135,7 +135,13 @@
\ExplSyntaxOn
\cs_new:Npn\FirstAidNeededT#1#2#3{
\exp_args:Ncx\str_if_eq:onF{ver@#1.#2}{#3}
- { \typeout{==>~ First~ Aid~ for~ #1.#2~ no~ longer~ applied!} }
+ { \typeout{==>~ First~ Aid~ for~ #1.#2~ no~ longer~ applied!^^J
+ \@spaces Expected:^^J
+ \@spaces\@spaces #3^^J
+ \@spaces but~ found:^^J
+ \@spaces\@spaces \use:c{ver@#1.#2}^^J
+ \@spaces so~ I'm~ assuming~ it~ got~ fixed.
+ } }
\exp_args:Ncx\str_if_eq:onT{ver@#1.#2}{#3}
}
\ExplSyntaxOff
@@ -221,9 +227,9 @@
%
% \begin{macrocode}
\newcommand\AtBeginOfFile [2]
- {\AddToHook{file/before/#1}{#2}}
+ {\AddToHook{file/#1/before}{#2}}
\newcommand\AtEndOfFile [2]
- {\AddToHook{file/after/#1}{#2}}
+ {\AddToHook{file/#1/after}{#2}}
% \end{macrocode}
%
% Some commands offered a starred form
@@ -232,8 +238,8 @@
{\IfBooleanTF{#1}%
{\@ifpackageloaded{#2}%
{#3}%
- {\AddToHook{package/before/#2}{#3}}}%
- {\AddToHook{package/before/#2}{#3}}%
+ {\AddToHook{package/#2/before}{#3}}}%
+ {\AddToHook{package/#2/before}{#3}}%
}
% \end{macrocode}
%
@@ -242,8 +248,8 @@
{\IfBooleanTF{#1}%
{\@ifpackageloaded{#2}%
{#3}%
- {\AddToHook{package/after/#2}{#3}}}%
- {\AddToHook{package/after/#2}{#3}}%
+ {\AddToHook{package/#2/after}{#3}}}%
+ {\AddToHook{package/#2/after}{#3}}%
}
% \end{macrocode}
%
@@ -254,25 +260,25 @@
{\IfBooleanTF{#1}%
{\@ifclassloaded{#2}%
{#3}%
- {\AddToHook{class/before/#2}{#3}}}%
- {\AddToHook{class/before/#2}{#3}}%
+ {\AddToHook{class/#2/before}{#3}}}%
+ {\AddToHook{class/#2/before}{#3}}%
}
\DeclareDocumentCommand \AtEndOfClassFile {smm}
{\IfBooleanTF{#1}%
{\@ifclassloaded{#2}%
{#3}%
- {\AddToHook{class/after/#2}{#3}}}%
- {\AddToHook{class/after/#2}{#3}}%
+ {\AddToHook{class/#2/after}{#3}}}%
+ {\AddToHook{class/#2/after}{#3}}%
}
% \end{macrocode}
%
% \begin{macrocode}
\newcommand\AtBeginOfIncludeFile [2]
- {\AddToHook{include/before/#1}{#2}}
+ {\AddToHook{include/#1/before}{#2}}
\newcommand\AtEndOfIncludeFile [2]
- {\AddToHook{include/end/#1}{#2}}
+ {\AddToHook{include/#1/end}{#2}}
\newcommand\AfterIncludeFile [2]
- {\AddToHook{include/after/#1}{#2}}
+ {\AddToHook{include/#1/after}{#2}}
% \end{macrocode}
%
% \begin{macrocode}
@@ -296,7 +302,7 @@
% If the package gets updated one can easily take that out simply
% through
%\begin{verbatim}
-% \RemoveFromHook{file/after/biditools.sty}[firstaid]
+% \RemoveFromHook{file/biditools.sty/after}[firstaid]
%\end{verbatim}
% This makes it easy to test new bidi code while the first aid code
% is still in the kernel.
@@ -306,7 +312,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\AddToHook{file/after/biditools.sty}[firstaid]{%
+\AddToHook{file/biditools.sty/after}[firstaid]{%
\FirstAidNeededT{biditools}{sty}%
{2020/05/13 v2 Programming tools for bidi package}%
{%
@@ -341,7 +347,7 @@
% Again a case of a no longer correct \cs{endgroup} in document.
% Here the fix is simply though.
% \begin{macrocode}
-\AddToHook{file/after/dinbrief.cls}[firstaid]{%
+\AddToHook{file/dinbrief.cls/after}[firstaid]{%
\FirstAidNeededT{dinbrief}{cls}{2000/03/02 LaTeX2e class}%
{\AddToHook{env/document/begin}{\begingroup}}%
}
@@ -363,7 +369,7 @@
%
% \begin{macrocode}
\ExplSyntaxOn
-\AddToHook{file/after/pgfpages.sty}[firstaid]{%
+\AddToHook{file/pgfpages.sty/after}[firstaid]{%
% \end{macrocode}
% Undo overwriting \cs{shipout}:
% \begin{macrocode}
@@ -390,7 +396,7 @@
%
% \begin{macrocode}
\ExplSyntaxOn
-\AddToHook{file/after/pgfmorepages.sty}[firstaid]{
+\AddToHook{file/pgfmorepages.sty/after}[firstaid]{
\cs_set_nopar:Npn \pgfhookintoshipout {
\cs_set_eq:NN \pgfpages@originalshipout \tex_shipout:D
\cs_set_eq:NN \tex_shipout:D \pgfpages@interceptshipout
@@ -468,7 +474,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\AddToHook{file/after/CJK.sty}[firstaid]{%
+\AddToHook{file/CJK.sty/after}[firstaid]{%
\FirstAidNeededT{CJK}{sty}%
{2015/04/18 4.8.4}%
{%
@@ -493,20 +499,22 @@
%
% A few classes unconditionally define \cs{footref}. Until that has
% changed we provide some first aid to let them do this.
+%
+% --- This seems to be resolved now ---
%
% \begin{macrocode}
-\AddToHook{file/after/scrkbase.sty}[firstaid]{%
- \FirstAidNeededT{scrkbase}{sty}%
- {2020/09/21 v3.32 KOMA-Script package (KOMA-Script-dependent basics and keyval usage)}%
- {\let\footref\@undefined}
- }
+%\AddToHook{file/scrkbase.sty/after}[firstaid]{%
+% \FirstAidNeededT{scrkbase}{sty}%
+% {2020/09/21 v3.32 KOMA-Script package (KOMA-Script-dependent basics and keyval usage)}%
+% {\let\footref\@undefined}
+% }
% \end{macrocode}
%
% \begin{macrocode}
-\AddToHook{class/before/memoir}[firstaid]{%
- % for version {2020/10/04 v3.7n configurable book, report, article document class}%
- \let\footref\@undefined
-}
+%\AddToHook{class/memoir/before}[firstaid]{%
+% % for version {2020/10/04 v3.7n configurable book, report, article document class}%
+% \let\footref\@undefined
+%}
% \end{macrocode}
%
%
@@ -528,7 +536,7 @@
% This firstaid therefore jumps over the problematical point by
% pushing the count allocation to a safe value if necessary.
% \begin{macrocode}
-\AddToHook{file/after/bigfoot.sty}{%
+\AddToHook{file/bigfoot.sty/after}{%
\ifnum\count10<\insc@unt
\global\count10=\insc@unt
\fi
@@ -548,7 +556,7 @@
%
%
%
-% \subsection{\cs{ulem} first aid}
+% \subsection{\pkg{ulem} first aid}
%
% In 2020 we fixed various kernel commands to accept \pkg{calc}
% syntax. The \pkg{ulem} package redefines some internals and that
@@ -558,14 +566,14 @@
% moment \pkg{ulem} gets adjusted.
%
% \begin{macrocode}
-\AddToHook{file/after/ulem.sty}[firstaid]{%
+\AddToHook{file/ulem.sty/after}[firstaid]{%
\def\@hspace#1{\begingroup\setlength\skip@{#1}%
\edef\x{\endgroup\hskip\the\skip@\relax}\x}%
}
% \end{macrocode}
%
%
-% \subsection{\cs{varwidth} first aid}
+% \subsection{\pkg{varwidth} first aid}
%
% The \pkg{varwidth} package does a lot of low-level paragraph
% manipulation assuming traditional \TeX{} paragraphs. However, with
@@ -577,13 +585,13 @@
% \cs{unskip}.
%
% \begin{macrocode}
-\AddToHook{file/after/varwidth.sty}[firstaid]{%
+\AddToHook{file/varwidth.sty/after}[firstaid]{%
\FirstAidNeededT{varwidth}{sty}%
{2009/03/30 ver 0.92; \space Variable-width minipages}%
{%
\def\@vwid@sift{%
\skip@\lastskip\unskip
- \unskip % <---- the first aid here
+ \ifdim\lastskip=\z@\unskip\fi % <---- the first aid here (not just unskip)
\dimen@\lastkern\unkern
\count@\lastpenalty\unpenalty
\setbox\z@\lastbox
@@ -618,6 +626,88 @@
% {Temporary fixes for the kernel \\
% (until the next patch-level release)}
%
+% This fixes GitHub issue 591. It is only needed in Lua\TeX\ and replaces just one
+% instance of \cs{tex\_par:D} with the following version which removes
+% other nodes in the current list first.
+% \begin{macrocode}
+\ExplSyntaxOn
+\sys_if_engine_luatex:T
+ {
+ \newluafunction \g__para_end_empty_par_id_int
+ \exp_args:Nx \everyjob {
+ \exp_not:V \everyjob
+ \exp_not:N \lua_now:n {
+ local~texnest, flush_list, par_token = tex.nest, node.flush_list, token.create'tex_par:D'~
+ lua.get_functions_table()[\int_use:N \g__para_end_empty_par_id_int] = function()
+ local~nest_level = texnest.top~
+ local~cur_head = nest_level.head~
+ flush_list(cur_head.next)
+ nest_level.tail, cur_head.next = cur_head, nil~
+ token.put_next(par_token)
+ end
+ }
+ }
+ \protected \luadef \__para_end_empty_par: \g__para_end_empty_par_id_int
+ \group_begin:
+ \cs_set:Npn \__para_extract_everypar:w #1 \the \toks #2 \s_stop
+ {
+ \tl_gset:Nn \g__para_standard_everypar_tl {
+ \box_gset_to_last:N \g_para_indent_box
+ \group_begin:
+ \__para_end_empty_par:
+ \group_end:
+ \tex_everypar:D { \msg_error:nnnn { hooks }{ para-mode }{before}{vertical} }
+ \@kernel@before@para@before
+ \hook_use:n {para/before}
+ \group_begin:
+ \tex_everypar:D {}
+ \skip_zero:N \tex_parskip:D
+ \tex_noindent:D
+ \group_end:
+ \tex_everypar:D{\g__para_standard_everypar_tl}
+ \@kernel@before@para@begin
+ \hook_use:n {para/begin}
+ \if_mode_horizontal: \else:
+ \msg_error:nnnn { hooks }{ para-mode }{begin}{vertical} \fi:
+ \__para_handle_indent:
+ \the \toks #2
+ }
+ }
+ \exp_last_unbraced:No \__para_extract_everypar:w \g__para_standard_everypar_tl \s_stop
+ \group_end:
+ }
+\ExplSyntaxOff
+% \end{macrocode}
+%
+% The next fixes Github issue 605 (by inserting a \cs{scan\_stop:}
+% before doing the check for hmode).
+% \begin{macrocode}
+\ExplSyntaxOn
+\cs_set_protected:Npn \para_end: {
+ \scan_stop:
+ \mode_if_horizontal:TF {
+ \mode_if_inner:F {
+ \tex_unskip:D
+ \hook_use:n{para/end}
+ \@kernel@after@para@end
+ \mode_if_horizontal:TF {
+ \if_int_compare:w 0 < \tex_lastnodetype:D
+ \tex_kern:D \c_zero_dim
+ \fi:
+ \tex_par:D
+ \hook_use:n{para/after}
+ \@kernel@after@para@after
+ }
+ { \msg_error:nnnn { hooks }{ para-mode }{end}{horizontal} }
+ }
+ }
+ \tex_par:D
+}
+\cs_set_eq:NN \par \para_end:
+\cs_set_eq:NN \@@par \para_end:
+\cs_set_eq:NN \endgraf \para_end:
+\ExplSyntaxOff
+% \end{macrocode}
%
% \begin{macrocode}
%</kernel>