From ca17f652236af2ce3a16cb0125fb6e190d59cc17 Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Thu, 18 Mar 2021 03:01:43 +0000
Subject: CTAN sync 202103180301

---
 language/japanese/jlreq/jlreq.cls | 146 +++++++++++++++++++++++++-------------
 1 file changed, 98 insertions(+), 48 deletions(-)

(limited to 'language/japanese/jlreq/jlreq.cls')

diff --git a/language/japanese/jlreq/jlreq.cls b/language/japanese/jlreq/jlreq.cls
index 71f7426605..1bee6df730 100644
--- a/language/japanese/jlreq/jlreq.cls
+++ b/language/japanese/jlreq/jlreq.cls
@@ -5,7 +5,7 @@
 %%
 % (based on JLReq 20200811 https://www.w3.org/TR/2020/NOTE-jlreq-20200811/)
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesClass{jlreq}[2020/12/29 jlreq]
+\ProvidesClass{jlreq}[2021/03/17 jlreq]
 \RequirePackage{xkeyval,everyhook,etoolbox,ifthen}
 \RequirePackage{jlreq-helpers}
 
@@ -15,6 +15,8 @@
 \cs_new:Nn \l_jlreq_do: {}
 \str_new:N \l_jlreq_tmpa_str
 \str_new:N \l_jlreq_tmpb_str
+\str_new:N \l_jlreq_tmpc_str
+\bool_new:N \l_jlreq_tmpa_bool
 \ExplSyntaxOff
 
 \newcommand*{\jlreq@undeferr}[1]{\ClassError{jlreq}{Trying to delete \string#1 even though it is not defined, may be a bug}{\@ehc}}
@@ -380,7 +382,6 @@
   \edef\jlreq@jfmnameg{\jlreq@jfmname@prefix jlreqg} % ゴシックなJFMの名前
   \jlreq@aftercls@addtodeletecs{\jlreq@jfmname}
   \jlreq@aftercls@addtodeletecs{\jlreq@jfmnameg}
-  \AtBeginDocument{\PushPostHook{par}{\futurelet\jlreq@nextchar\jlreq@openbracket@hook}}
 \fi
 
 % (u)pLaTeXの場合ここで初めて\epTeXinputencodingが発行されるので，
@@ -802,14 +803,18 @@
 \edef\jlreq@charlist@katakana{アイウエオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモヤユヨラリルレロワヰヱヲンヴ\ifx p\jlreq@engine\else ヷヸヹヺ\fi}% カ゚キ゚ク゚ケ゚コ゚セ゚ツ゚ト゚
 
 %.. 行頭括弧調整
+\AtBeginDocument{\PushPostHook{par}{\jlreq@hook@everypar}}
+\def\jlreq@hook@everypar{}
+\jlreq@saveoriginalcs{item}
 \ifx l\jlreq@engine
-  % \item後の行頭括弧のために仕込み．
-  \jlreq@saveoriginalcs{list}
-  \jlreq@saveoriginalcs{endlist}
-  \PushPostHook{par}{\jlreq@parhook@atbeginlist}
-  \pretocmd{\list}{\def\jlreq@parhook@atbeginlist{\ltjfakeparbegin}}{}{}
-  \apptocmd{\endlist}{\def\jlreq@parhook@atbeginlist{}}{}{}
-  \def\jlreq@parhook@atbeginlist{}
+  % \itemの直後は折り返し行頭と同じにする．
+  \def\item{%
+    \def\jlreq@hook@everypar{%
+      \def\jlreq@hook@everypar{}%
+      \inhibitglue
+    }%
+    \jlreq@useoriginalcs{item}%
+  }
 \else
   % 非LuaTeXの場合はJFMの入れ替えと\everyparでの処理で対処．
   % 行頭括弧に対して\inhibitglueを入れたりする命令を作る
@@ -819,13 +824,22 @@
   \expandafter\jlreq@do\jlreq@charlist@openingbrackets\jlreq@endmark
   % JFM glueの伸び縮みで行頭括弧が揃わないのを防ぐために常に\inhibitglueを入れる．
   \ifthenelse{\equal{\jlreq@open@bracket@pos}{nibu_tentsuki}}{
-    \edef\jlreq@openbracket@hook@{\noexpand\ifnum0\expandonce{\jlreq@tempa}>0 \unexpanded{\hskip -.5\jlreq@zw\inhibitglue}\noexpand\fi}
+    \edef\jlreq@openbracket@hook@ii{\noexpand\ifnum0\expandonce{\jlreq@tempa}>0 \unexpanded{\hskip -.5\jlreq@zw\inhibitglue}\noexpand\fi}
   }{% zenkakunibu_nibu,zenkaku_tentsuki
-    \edef\jlreq@openbracket@hook@{\noexpand\ifnum0\expandonce{\jlreq@tempa}>0 \unexpanded{\inhibitglue}\noexpand\fi}
+    \edef\jlreq@openbracket@hook@ii{\noexpand\ifnum0\expandonce{\jlreq@tempa}>0 \unexpanded{\inhibitglue}\noexpand\fi}
   }
   % source special対策
-  \def\jlreq@openbracket@hook{\ifx\jlreq@nextchar\special\expandafter\jlreq@openbracket@hook@@\else\expandafter\jlreq@openbracket@hook@\fi}
-  \def\jlreq@openbracket@hook@@#1#2{#1{#2}\futurelet\jlreq@nextchar\jlreq@openbracket@hook}
+  \def\jlreq@openbracket@hook@i{\ifx\jlreq@nextchar\special\expandafter\jlreq@openbracket@hook@iii\else\expandafter\jlreq@openbracket@hook@ii\fi}
+  \def\jlreq@openbracket@hook@iii#1#2{#1{#2}\futurelet\jlreq@nextchar\jlreq@openbracket@hook@i}
+  \def\jlreq@openbracket@hook{\futurelet\jlreq@nextchar\jlreq@openbracket@hook@i}
+  \let\jlreq@hook@everypar=\jlreq@openbracket@hook
+  \def\item{%
+    \def\jlreq@hook@everypar{%
+      \let\jlreq@hook@everypar=\jlreq@openbracket@hook
+      \inhibitglue
+    }%
+    \jlreq@useoriginalcs{item}%
+  }
 \fi
 
 %.. 禁則処理
@@ -2743,35 +2757,47 @@
   \jlreq@do
 }
 % {1 = 命令名}{2 = レベル}{3 = *}{4 = running head}{5 = 見出し}{6 = ラベルフォーマット}{7 = ラベルありフォーマット}{8 = ラベルなしフォーマット}
-\long\def\jlreq@RuninHeading@start@@#1#2#3#4#5#6#7#8{%
-  \if@noskipsec\leavevmode\fi
-  \begingroup
-    \def\jlreq@do{\global\@noskipsectrue}%
-    \ifnum0\jlreq@ifempty{#3}{}{1}\ifnum #2>\c@secnumdepth 1\fi>0
-      \def\jlreq@tempa##1{#8}%
-    \else
-      \appto\jlreq@do{\refstepcounter{#1}}%
-      \def\jlreq@tempa##1{#7}%
-    \fi
-    \par
-    \eappto\jlreq@do{%
-      \noexpand\everypar{%
-        \noexpand\if@noskipsec
-          \unexpanded{\global\@noskipsecfalse}%
-          \unexpanded{{\setbox\jlreq@tempboxa\lastbox}}%
-          \noexpand\begingroup
-            \expandonce{\jlreq@tempa{#5}}%
-            \expandonce{\csname jlreq@heading@maketoc@#1\endcsname}{#3}{#6}{#4}%
-          \noexpand\endgroup
-        \noexpand\else
-          \unexpanded{\everypar{}}%
-        \noexpand\fi
+\edef\jlreq@tempa{%
+  \unexpanded{\long\def\jlreq@RuninHeading@start@@#1#2#3#4#5#6#7#8}{%
+    \unexpanded{%
+    \if@noskipsec\leavevmode\fi
+    \begingroup
+      \def\jlreq@do{\global\@noskipsectrue}%
+      \ifnum0\jlreq@ifempty{#3}{}{1}\ifnum #2>\c@secnumdepth 1\fi>0
+        \def\jlreq@tempa##1{#8}%
+      \else
+        \appto\jlreq@do{\refstepcounter{#1}}%
+        \def\jlreq@tempa##1{#7}%
+      \fi
+      \par}%
+      \unexpanded{\eappto\jlreq@do}{%
+        \unexpanded{\noexpand\everypar}{%
+          \unexpanded{%
+          \noexpand\if@noskipsec
+            \unexpanded{\global\@noskipsecfalse}%
+            \unexpanded{{\setbox\jlreq@tempboxa\lastbox}}%
+            \noexpand\begingroup
+              \expandonce{\jlreq@tempa{#5}}%
+              \expandonce{\csname jlreq@heading@maketoc@#1\endcsname}\unexpanded{{#3}{#6}{#4}}%
+            \noexpand\endgroup
+            \unexpanded{\def\jlreq@hook@everypar{\inhibitglue}}%
+          \noexpand\else
+            \unexpanded{\everypar{}}%
+          }%
+            \ifx l\jlreq@engine
+              \unexpanded{\unexpanded{\def\jlreq@hook@everypar{}}}%
+            \else
+              \unexpanded{\unexpanded{\let\jlreq@hook@everypar\jlreq@openbracket@hook}}%
+            \fi
+         \unexpanded{\noexpand\fi}%
+        }%
       }%
-    }%
-  \expandafter\endgroup
-  \jlreq@do
-  \ignorespaces
+    \unexpanded{\expandafter\endgroup
+    \jlreq@do
+    \ignorespaces}%
+  }
 }
+\jlreq@tempa
 
 % \DeclareRuninHeading{命令名}{レベル}{設定}
 \newcommand*{\DeclareRuninHeading}[3]{%
@@ -2964,11 +2990,29 @@
   \@ifundefined{#1}{\DeclareCutinHeading{#1}{#2}{#3}}{}%
 }
 
-\newcommand{\ModifyHeading}[2]{%
-  \@ifundefined{jlreq@heading@setting@#1}{\ClassError{jlreq}{Unknown heading: #1}{\@ehc}}{}%
-  \edef\jlreq@do{\csexpandonce{jlreq@heading@type@#1}{#1}{\csexpandonce{jlreq@heading@level@#1}}{\csexpandonce{jlreq@heading@setting@#1},\unexpanded{#2}}}%
-  \jlreq@do
+\ExplSyntaxOn
+\NewDocumentCommand{\ModifyHeading}{m m}{
+  \@ifundefined{jlreq@heading@setting@#1}{\ClassError{jlreq}{Unknown heading: #1}{\@ehc}}{}
+  \group_begin:
+    \tl_set:Nn \l_jlreq_tmpa_tl {#2}
+    \str_set:Nn \l_jlreq_tmpa_str {#2}
+    \str_case_e:nn {\jlreq@HeadingType{#1}} {
+      {BlockHeading}{
+        \bool_set_false:N \l_jlreq_tmpa_bool
+        \str_if_in:NnT \l_jlreq_tmpa_str {before_space=}{\bool_set_true:N \l_jlreq_tmpa_bool}
+        \str_if_in:NnT \l_jlreq_tmpa_str {before_space~=}{\bool_set_true:N \l_jlreq_tmpa_bool}
+        \bool_if:NT \l_jlreq_tmpa_bool {\tl_put_left:Nn \l_jlreq_tmpa_tl {before_lines={},}}
+        \bool_set_false:N \l_jlreq_tmpa_bool
+        \str_if_in:NnT \l_jlreq_tmpa_str {after_space=}{\bool_set_true:N \l_jlreq_tmpa_bool}
+        \str_if_in:NnT \l_jlreq_tmpa_str {after_space~=}{\bool_set_true:N \l_jlreq_tmpa_bool}
+        \bool_if:NT \l_jlreq_tmpa_bool {\tl_put_left:Nn \l_jlreq_tmpa_tl {after_lines={},}}
+      }
+    }
+    \cs_set:Nx \l_jlreq_do: {\exp_not:v {jlreq@heading@type@#1}{\exp_not:n {#1}}{\exp_not:v {jlreq@heading@level@#1}}{\exp_not:v {jlreq@heading@setting@#1},\exp_not:V \l_jlreq_tmpa_tl}}
+  \exp_after:wN \group_end:
+  \l_jlreq_do:
 }
+\ExplSyntaxOff
 % 見出し#1をマクロ#2に保存する
 \newcommand{\SaveHeading}[2]{%
   \@ifundefined{jlreq@heading@setting@#1}{\ClassError{jlreq}{Unknown heading: #1}{\@ehc}}{}%
@@ -3267,7 +3311,7 @@
       }{#2}%
     }
   \fi
-  \def\jlreq@footnote@delayfootnote@immediate#1#2{%
+  \long\def\jlreq@footnote@delayfootnote@immediate#1#2{%
     \jlreq@if{\ifnum #1<\jlreq@currentpage\relax\fi}{%
       \xappto\jlreq@footnote@delayfootnoteslist{\unexpanded{\jlreq@footnote@delayfootnote{#1}{#2}}}%
     }{#2}%
@@ -4710,6 +4754,7 @@
       \ifnum0\ifx c\jlreq@align 1\fi\ifx r\jlreq@align 1\fi>0 \hfil\fi
       \unhbox\@tempboxa
       \ifnum0\ifx c\jlreq@align 1\fi\ifx l\jlreq@align 1\fi>0 \hfil\fi
+      \par
     }%
   \fi
   \vskip\belowcaptionskip}}
@@ -4813,6 +4858,7 @@
   \fi
 }
 
+\ExplSyntaxOn
 \if@titlepage
   \newcommand{\maketitle}{%
     % jarticleとかからあまり変更していない
@@ -4865,14 +4911,18 @@
         \@maketitle
       \fi
       % \pagestyle{empty}の時はそのまま．
-      \ifnum0\ifx\@oddhead\@empty\else1\fi\ifx\@evenhead\@empty\else1\fi>0
-        \thispagestyle{plain}%
-      \fi
+      \bool_if:nT{!(
+        \tl_if_empty_p:o \@oddhead &&
+        \tl_if_empty_p:o \@evenhead &&
+        \tl_if_empty_p:o \@oddfoot &&
+        \tl_if_empty_p:o \@evenfoot
+      )}{\thispagestyle{plain}}
       \@thanks
     \endgroup
     \jlreq@endofmaketitle
   }
 \fi
+\ExplSyntaxOff
 % いろいろクリアする．
 \def\jlreq@endofmaketitle{%
   \setcounter{footnote}{0}%
-- 
cgit v1.2.3

