latex3 / tagging-project

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

Is the order of execution of the hyp respectively tagpdf labelled part of hook contentsline/text/{before,after} guaranteed? #53

Open jfbu opened 6 months ago

jfbu commented 6 months ago

From what I gathered from discussion of hooks, the order in which hooks are executed is not guaranteed except if some explicit ordering rules are applied.

Currently it appears no explicit ordering rules are declared for example for contentsline/text/before but it is in fact crucial that the hyp chunk is done after the tagpdf chunk.

To test this I imposed the reversed order causing breakage:

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

\usepackage{hyperref}

\begin{document}

\ShowHook{contentsline/text/before}
\ShowHook{contentsline/text/after}

\DeclareHookRule{contentsline/text/before}{hyp}{before}{tagpdf}
\DeclareHookRule{contentsline/text/after}{hyp}{after}{tagpdf}

\ShowHook{contentsline/text/before}
\ShowHook{contentsline/text/after}

\tableofcontents

\part{ONE}

\chapter{Test chapter one}

\section{Section one one}

\subsection{Subsection one one one}

\subsection{Subsection one  one two}

\end{document}

Causes many warnings starting with

Package tagpdf Warning: Parent-Child 'TOCI/' --> 'Link/pdf2'.
(tagpdf)                Relation is not allowed (struct 9, /TOCI --> struct
(tagpdf)                10) on line 1
FrankMittelbach commented 6 months ago

From what I gathered from discussion of hooks, the order in which hooks are executed is not guaranteed except if some explicit ordering rules are applied.

correct

Currently it appears no explicit ordering rules are declared for example for contentsline/text/before but it is in fact crucial that the hyp chunk is done after the tagpdf chunk.

also correct. This is why we said elsewhere that using the public hooks is not the final solution (they will all be replaced by sockets dedicated to tagging) but this was done to get quick workable prototype even though with that restriction.

Now that we have sockets in the kernel they will one after another replace the currently use of public hooks.

u-fischer commented 6 months ago

Well I know the order because I added both ;-). And as long as nobody messes around with the order, it should be ok.

As Frank wrote, the tagging code will probably move at some time, but I would like to have a bit more examples and feedback about the tagging first (which why it is neat that etoc adds tagging support ;-)).

jfbu commented 6 months ago

@FrankMittelbach @u-fischer I think I have reached a reasonable state regarding tagging and etoc at 1.2e-dev-2024/01/03.

I opened this issue here because it had been very important for me to understand how hyperlink tagging had to be inserted, once I understood I probably could not reuse the kernel hooks myself but had to imitate them rather.

Although this is not the place here I very briefly mention that

and that the main issues I see for etoc at this stage are: