summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/luatexja/src/patches/lltjp-atbegshi.sty
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-08-09 03:02:03 +0000
committerNorbert Preining <norbert@preining.info>2020-08-09 03:02:03 +0000
commit68df63effba2e77fb0218b91a6722821355885cd (patch)
treeb83f3e8c1ebfbfd59df87a4a6e89abb5a0442008 /macros/luatex/generic/luatexja/src/patches/lltjp-atbegshi.sty
parent1c9455caf30309c8b8ba69afdc5a16a83d9f9a58 (diff)
CTAN sync 202008090302
Diffstat (limited to 'macros/luatex/generic/luatexja/src/patches/lltjp-atbegshi.sty')
-rw-r--r--macros/luatex/generic/luatexja/src/patches/lltjp-atbegshi.sty62
1 files changed, 38 insertions, 24 deletions
diff --git a/macros/luatex/generic/luatexja/src/patches/lltjp-atbegshi.sty b/macros/luatex/generic/luatexja/src/patches/lltjp-atbegshi.sty
index ecdfd48c22..8512023874 100644
--- a/macros/luatex/generic/luatexja/src/patches/lltjp-atbegshi.sty
+++ b/macros/luatex/generic/luatexja/src/patches/lltjp-atbegshi.sty
@@ -2,23 +2,40 @@
% lltjp-atbegshi.sty
%
-\ifdefined\NeedsTeXFormat
- \NeedsTeXFormat{LaTeX2e}
- \ProvidesPackage{lltjp-atbegshi}[2020-07-30 Patch to atbegshi for LuaTeX-ja]
- \RequirePackage{atbegshi}
-\else
- \input atbegshi.sty
-\fi
+\newif\ifltj@ltshipout@avail
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{lltjp-atbegshi}[2020-08-08 Patching \string\shipout\space hooks for LuaTeX-ja]
+\@ifl@t@r\fmtversion{2020-10-01}{%
+ \ifnum\patch@level<0\relax \ifnum\patch@level<-6 \ltj@ltshipout@availtrue\fi
+ \else\ltj@ltshipout@availtrue\fi
+}{}
+\ifltj@ltshipout@avail\else\RequirePackage{atbegshi}\fi
+
+% concept: execute all hooks inside yoko direction \vbox
-%--------------------------------------
-% following codes are almost copied from
-% pxatbegshi.sty 2019/09/07 v0.5 (in platex-tools bundle, by H. Yamashita).
+\ifltj@ltshipout@avail
+%<*ltshipout>-----------------------------------
+%
+\RequirePackage{expl3}
+\ExplSyntaxOn\makeatletter
+\box_new:N \l__platex_shipout_dummy_box
+\pretocmd {\__shipout_execute_cont:}
+ {\tex_setbox:D \l__platex_shipout_dummy_box \tex_vbox:D \c_group_begin_token \yoko } {} {}
+\apptocmd {\__shipout_execute_cont:} {\c_group_end_token} {} {}
+\ExplSyntaxOff
+%</ltshipout>-----------------------------------
+
+\else
+\AtBeginShipoutInit
+%<*atbegshi>-------------------------------------
+% patching atbegshi.sty
+%%% following codes are almost copied from
+%%% pxatbegshi.sty 2019/09/07 v0.5 (in platex-tools bundle, by H. Yamashita).
%% internal macros are locally effective
\begingroup
-%--------------------------------------- helpers
-
+% helpers
%% unique tokens
\def\pxabgs@mark{\pxabgs@mark@}
\def\pxabgs@fin{\pxabgs@fin@}
@@ -27,29 +44,25 @@
\def\pxabgs@patch@cmd#1#2#3{%
\ifx#1\relax\else
\def\pxabgs@next##1#2##2\pxabgs@mark##3\pxabgs@fin{%
- \ifx\pxabgs@mark##3\pxabgs@mark
- \let#1\relax
+ \ifx\pxabgs@mark##3\pxabgs@mark\let#1\relax
\else
- \def\pxabgs@fragment{##2}%
- \def#1{##1#3##2}%
+ \def\pxabgs@fragment{##2}\def#1{##1#3##2}%
\fi}%
\expandafter\pxabgs@next#1\pxabgs@mark#2\pxabgs@mark\pxabgs@fin
\fi
}
-%---------------------------------------
-
-% concept: execute all hooks inside yoko direction \vbox
-
% prepare
-\let\pxabgs@AtBegShi@Output\AtBegShi@Output
+\ifdefined\AtBegShi@Output
+ \let\pxabgs@AtBegShi@Output\AtBegShi@Output
+\else\let\pxabgs@AtBegShi@Output\relax\fi
% try first patch
\pxabgs@patch@cmd\pxabgs@AtBegShi@Output
{\let\AtBegShi@OrgProtect\protect}%
{\setbox8\vbox\bgroup\yoko\let\AtBegShi@OrgProtect\protect}
\pxabgs@patch@cmd\pxabgs@AtBegShi@Output
- {\AtBeginShipoutOriginalShipout\box\AtBeginShipoutBox}%
- {\AtBeginShipoutOriginalShipout\box\AtBeginShipoutBox\egroup}
+ {\AtBeginShipoutOriginalShipout\box\AtBeginShipoutBox}%
+ {\AtBeginShipoutOriginalShipout\box\AtBeginShipoutBox\egroup}
\pxabgs@patch@cmd\pxabgs@AtBegShi@Output
{%
\begingroup
@@ -75,5 +88,6 @@
\endgroup
%% internal macros are no longer effective
-
+%</atbegshi>-------------------------------------
+\fi
\endinput