summaryrefslogtreecommitdiff
path: root/macros/luatex/latex/luabidi/tex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-10-03 03:01:05 +0000
committerNorbert Preining <norbert@preining.info>2023-10-03 03:01:05 +0000
commit75afa6c3d445abbfd4e8c0cb9d2d24eb4d1b71fe (patch)
treebe5945dc96693dc01b26eb16df1472a193fdf93c /macros/luatex/latex/luabidi/tex
parent5f9c1e9c3c9b2ac59c6f868744ee6fafee27ab39 (diff)
CTAN sync 202310030301
Diffstat (limited to 'macros/luatex/latex/luabidi/tex')
-rw-r--r--macros/luatex/latex/luabidi/tex/luabidi.sty55
1 files changed, 39 insertions, 16 deletions
diff --git a/macros/luatex/latex/luabidi/tex/luabidi.sty b/macros/luatex/latex/luabidi/tex/luabidi.sty
index 4277a1f173..47e4d92d07 100644
--- a/macros/luatex/latex/luabidi/tex/luabidi.sty
+++ b/macros/luatex/latex/luabidi/tex/luabidi.sty
@@ -1,13 +1,14 @@
%% This file is luabidi.sty
%% This is part of the luabidi package
%%
-%% Copyright © 2009 Vafa Khalighi, 2013--2019 Arthur Reutenauer, 2019 Jürgen Spitzmüller
+%% Copyright © 2009 Vafa Khalighi, 2013--2023 Arthur Reutenauer,
+%% 2019--2023 Jürgen Spitzmüller
%%
%%%% It may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{luabidi}[2019/10/27 v0.5
+\ProvidesPackage{luabidi}[2023/10/01 v0.6
Bidirectional typesetting in LuaTeX]
\RequirePackage{etoolbox}
@@ -29,20 +30,19 @@
\newif\if@RTL
\newif\if@RTLmain
-\@RTLmainfalse
-\def\setRTLmain{\@RTLmaintrue\pagedir TRT \bodydir TRT \pardir TRT \textdir TRT}
-\def\setRTL{\@RTLtrue\pardir TRT \textdir TRT}
+\def\setRTLmain{\@RTLmaintrue\pagedir TRT\bodydir TRT\pardir TRT\textdir TRT}
+\def\setRTL{\@RTLtrue\bodydir TRT\pardir TRT\textdir TRT}
\let\setRL=\setRTL
-\def\setLTR{\@RTLfalse\pardir TLT \textdir TLT}
+\def\setLTR{\@RTLfalse\bodydir TLT\pardir TLT\textdir TLT}
\let\setLR=\setLTR
\let\unsetRTL=\setLTR
\let\unsetLTR=\setRTL
-\def\RTL{\@RTLtrue\trivlist \pardir TRT \textdir TRT\item\relax}
-\def\endRTL{\@RTLfalse\endtrivlist}
-\def\LTR{\trivlist \pardir TLT \textdir TLT\item\relax}
-\def\endLTR{\endtrivlist}
-\def\@ensure@RTL#1{\if@RTL#1\else\RLE{#1}\fi}
-\def\@ensure@LTR#1{\if@RTL\LRE{#1}\else{#1}\fi}
+\def\RTL{\par\@RTLtrue\bodydir TRT\pardir TRT\textdir TRT}
+\def\endRTL{\par}
+\def\LTR{\par\@RTLfalse\bodydir TLT\pardir TLT \textdir TLT}
+\def\endLTR{\par}
+\def\@ensure@RTL#1{\if@RTL #1\else\RLE{#1}\fi}
+\def\@ensure@LTR#1{\if@RTL\LRE{#1}\else #1\fi}
\def\@ensure@dir#1{\if@RTL\RLE{#1}\else{#1}\fi}
\let\@ensure@maindir=\@ensuredir
\let\n@xt=\
@@ -52,13 +52,38 @@
\def\pRLE{\protect\afterassignment\moreRLE \let\n@xt= }
\def\bracetext{\ifcat\n@xt{\else\ifcat\n@xt}\fi
\errmessage{Missing left brace has been substituted}\fi \bgroup}
-\def\moreLRE{\bracetext \aftergroup\unsetLTR \setLTR\@RTLfalse}
-\def\moreRLE{\bracetext \aftergroup\unsetRTL \setRTL\@RTLtrue}
+\def\moreLRE{\bracetext \leavevmode\@RTLfalse\textdir TLT}
+\def\moreRLE{\bracetext \leavevmode\@RTLtrue\textdir TRT}
\let\LR=\LRE
\let\RL=\RLE
\def\hboxR#1{\hbox{\RL{#1}}}
%
+% If \pagedir is different from \pardir then \shapemode needs to be 2 for \parshape in lists
+%
+
+\let\luabidi@OL@list\list
+\patchcmd\list{\parshape}{\luabidi@parshape}{}{}
+\def\luabidi@parshape#1#2#3{%
+ \parshape #1 #2 #3 %
+ \ifnum\pagedirection=\pardirection\else
+ \shapemode\tw@
+\fi}
+
+%
+% making sure \bodydir is the same as \pagedir at \output time
+%
+
+\output\expandafter{\expandafter\bodydir\expandafter\pagedir\the\output}
+
+%
+% The following registers are set to 1 to fix some bugs in the engine. See sections 3.3.3 and 7.5.3 of LuaTeX's manual.
+%
+
+\matheqdirmode=1
+\breakafterdirmode=1
+
+%
% Footnotes
%
@@ -70,11 +95,9 @@
% This needs to be loaded late because of the switch
\AtEndPreamble{%
- \makeatletter
\ifluabidi@autofootnoterule
\input{luabidi-autofootnoterule.def}
\fi
- \makeatother
}
\endinput