latex3 / tagpdf

Tagging support code for LaTeX
59 stars 7 forks source link

warning mentions `Em/pdf2` even though pdfversion is set at 1.7 #93

Open jfbu opened 7 months ago

jfbu commented 7 months ago

Artificial document (deliberately attempting illegal nesting)

\DocumentMetadata{
 uncompress,
 pdfversion=1.7,
 lang=en-US,
 testphase=phase-III
}
\documentclass{article}

\begin{document}

\emph{hallo!\ShowTagging{struct-stack}}

\ExplSyntaxOn
\__tag_toc_starttoc_init:n{toc}
\__tag_toc_contentsline_begin:nnn{section}{dummy}{dummydest}
\ShowTagging{struct-stack}\emph{dummy section}\par
\__tag_toc_contentsline_end:n{section}{dummy}{dummydest}
\__tag_toc_starttoc_finalize:
\ExplSyntaxOff
\end{document}

generates on first pdflatex run:

Package tagpdf Warning: Parent-Child 'TOCI/' --> 'Em/pdf2'.
(tagpdf)                Relation is not allowed (struct 5, /TOCI --> struct 6)
(tagpdf)                on line 16

but the pdfversion is 1.7. Does this mean that Em/pdf2 is used internally (I see also /Em in the pdf if using 2.0 so not saying at all here perhaps mark-up not pdf 1.7 one, clearly that can't be the case), or is this artifact (sic) from warning process?

I have not yet assimilated docs.

u-fischer commented 7 months ago

Em can also be used with pdfversion 1.7, there it is role mapped to Span which isn't allowed directly inside TOCI. So the warning is correct only a bit unclear if you don't know the inner working. (It is a bit of a struggle to get in the relevant info without getting too verbose, and quite probably the messages will continue to change based on feed back and experience). If you increase the log-level things gets a bit clearer:

\DocumentMetadata{pdfversion=1.7,testphase={phase-III},debug={log=v}}
\documentclass{article}
\begin{document}
\tagstructbegin{tag=TOCI}\tagstructbegin{tag=Em}\tagstructend\tagstructend

blub
\end{document}

this then gives:

Package tagpdf Info: Parent-Child 'TOCI' --> 'Span'.
(tagpdf)             Relation is -1 (='∅')
(tagpdf)             Rolemapped from: 'TOCI' --> 'Em' on line 106

Package tagpdf Warning: Parent-Child 'TOCI/' --> 'Em/pdf2'.
(tagpdf)                Relation is not allowed (struct 4, /TOCI --> struct 5)
(tagpdf)                on line 106

With pdf 2.0 this would change to:

Package tagpdf Info: Parent-Child 'TOCI' --> 'Em'.
(tagpdf)             Relation is -1 (='∅')
(tagpdf)             Rolemapped from 'TOCI/pdf' --> 'Em/pdf2' on line 106

Package tagpdf Warning: Parent-Child 'TOCI/pdf' --> 'Em/pdf2'.
(tagpdf)                Relation is not allowed (struct 4, /TOCI --> struct 5)
(tagpdf)                on line 106
jfbu commented 7 months ago

I had not tested the increased verbosity. Would you consider adding an option to treat warnings as errors? I added this manually in my test files, was happy to find quickly how to from l3msg.pdf:

\ExplSyntaxOn
 \msg_redirect_module:nnn { tag } { warning } { error }
\ExplSyntaxOff

It works!