latex3 / tagging-project

Issues related to the tagging project
https://latex3.github.io/tagging-project/
LaTeX Project Public License v1.3c
32 stars 13 forks source link

kanbun package incompatible #596

Open mbertucci47 opened 1 month ago

mbertucci47 commented 1 month ago

The kanbun package is incompatible. The example

\DocumentMetadata
  {
    lang=en-US,
    pdfversion=2.0,
    pdfstandard=ua-2,
    testphase={phase-III,math,title,table,firstaid}
  }
\documentclass{article}
\usepackage{luatexja}
\usepackage{kanbun}
\begin{document}
\Kanbun
月落チ烏啼キテ霜満ツ[レ]天ニ,
江楓漁火対ス[二]愁眠ニ[一]。
姑(こ)蘇(そ)城外ノ寒山寺,
夜半ノ鐘声到ル[二]客船ニ[一]。
\EndKanbun
\printkanbun
\end{document}

errors with

Inserting `tagpdf' in `pre_shipout_filter'.
Inserting `tagpdf' in `pre_shipout_filter'.[\directlua]:1: attempt to call a nil
 value (global 'register_verbatim')
stack traceback:
    [\directlua]:1: in main chunk.
\Kanbun ->\directlua {register_verbatim()}

l.13 \Kanbun

The lua interpreter ran into a problem, so the
remainder of this lua chunk will be ignored.

! Undefined control sequence.
l.18 \EndKanbun
u-fischer commented 1 month ago

It errors already earlier:

\kanbun_current_kanjiunit=\box79
[\directlua]:1: invalid escape sequence near '"\@'.
l.371 }

The problem is that the kanbun package uses return "\\newif\\ifcontinue\\continuetrue ... in a \directlua. This works more or less in standard latex, where \\ is protected but fails with the block code where it expands to \@normalcr. The kanbun package should probably use `\noexpand\\newif etc. Then it compiles.

The other question is why the block code unprotects \\ and if one should correct that:

\makeatletter
\RequirePackage{tagpdf-base}
\show\\ 
\RequirePackage{latex-lab-testphase-block}
\show\\ \show\@normalcr

gives

> \\=\protected macro:
->\let \reserved@e \relax \let \reserved@f \relax \@ifstar {\let \reserved@e \v
adjust \let \reserved@f \nobreak \@xnewline }\@xnewline .
l.233 \show\\

and then

> \\=macro:
->\@normalcr .
l.235 \show\\
              \show\@normalcr
? 
> \@normalcr=\protected macro:
->\let \reserved@e \relax \let \reserved@f \relax \@ifstar {\let \reserved@e \v
adjust \let \reserved@f \nobreak \@xnewline }\@xnewline .
l.235 \show\\ \show\@normalcr
FrankMittelbach commented 1 month ago

I can't remember if there was a reason or if this just happened by accident, but it is is certainly something one could find out and change.

u-fischer commented 1 month ago

@FrankMittelbach I tried to change in \DeclareTemplateCode{para}{std}{1} the cr-cmd = \\ to cr-cmd = \@normalcr but the blocks-verse-01 test looped ... .