Skip to content

Commit

Permalink
Don't tag listenv=none as list
Browse files Browse the repository at this point in the history
  • Loading branch information
gusbrs committed Oct 15, 2024
1 parent e62bd2d commit 1bf4be5
Show file tree
Hide file tree
Showing 8 changed files with 845 additions and 1,813 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from `footmisc`.
- Provide (experimental) support for PDF tagging. For this, the required LaTeX
kernel version was bumped to 2024-06-01. Tagging support requires
`testphase=phase-III`.
`testphase=phase-III` (`phase-II` with `listenv=none`).

## [v0.2.8](https://github.com/gusbrs/postnotes/compare/v0.2.7...v0.2.8) (2023-12-12)

Expand Down
111 changes: 51 additions & 60 deletions postnotes.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -2773,9 +2773,10 @@
%
% \subsection*{PDF Tagging (experimental)}
%
% Note: All of this presumes
% \texttt{\cs{DocumentMetadata}\{testphase=phase-III\}} and was only tested
% with it.
% Note: All of this mostly presumes
% \texttt{\cs{DocumentMetadata}\{testphase=phase-III\}} and was tested with
% it. For \opt{listenv=none}, I'd expect things to work with
% \texttt{phase-II}, but this is only lightly tested.
%
% A first thing to consider in tagging endnotes is how we want to represent
% them in the PDF structure. My first thought, for lack of another, was:
Expand All @@ -2799,8 +2800,8 @@
% an issue: they have a natural place to be plugged into. Furthermore, making
% an endnote a child of the text surrounding its mark leaves an empty
% ``skeleton'' of the endnotes section: the heading, the list structure, etc.
% Technically, we could clean that too, but from experience that is an uphill
% battle against the tagging performed by \pkg{latex-lab}/\pkg{tagpdf}.
% Technically, we could clean that too, but clearly that's not the way to
% go\dots{}.
%
% Finally, the parent-child relation is not required by \texttt{PDF} standards
% for the relevant structure types. The \texttt{PDF} 2.0 standard
Expand Down Expand Up @@ -2854,22 +2855,20 @@
% \texttt{endnotelabel} element to be a child of the \texttt{endnote} element.
% Thus, we have a conflict, the mc-chunk can only be used once, and can be
% either the \texttt{Lbl} of the \texttt{LI}, or the \texttt{endnotelabel} for
% the \texttt{endnote}. Currently, I'm using an \texttt{EndnotesList} class,
% which we define to have \texttt{ListNumbering} as \texttt{Ordered}, with the
% mark as \texttt{Lbl} for \texttt{LI}, and letting \texttt{endnote} be a
% child of \texttt{LBody}. In a way, the possibility of exporting the tagged
% content to different formats makes me think that this is the most
% appropriate for the list case. For the case of \texttt{listenv=none}, I
% built a list structure so that the endnotes are tagged exactly the same as
% if there was a list environment in the \LaTeX{} side. This eliminates
% inconsistencies on the resulting tagged PDF between the two cases and
% improves machine readability. The structure is always the same. All in
% all, it should be viable to adjust these choices (modulo the usual battle
% with the default tagging code), but it is just very hard to reach a decision
% without knowledge of applications and use cases (including standards and
% practices, relevant software which consume the resulting PDF, providing
% accessibility or other byproducts, etc.). So, a call to be revisited in the
% future, pending users' feedback.
% the \texttt{endnote}. Currently, for the list case, I'm using an
% \texttt{EndnotesList} class, which we define to have \texttt{ListNumbering}
% as \texttt{Ordered}, with the mark as \texttt{Lbl} for \texttt{LI}, and
% letting \texttt{endnote} be a child of \texttt{LBody}. In a way, the
% possibility of exporting the tagged content to different formats makes me
% think that this is the most appropriate for the this case. For the case of
% \texttt{listenv=none}, the \texttt{endnote}s were made child of the
% \texttt{Sect} in which they occur. The \texttt{endnotelabel} was then
% included as part (child) of the \texttt{endnote}. In this, this treatment
% emulates the one given for footnotes in the kernel. But, at the same time,
% it is less than ideal for machine readability purposes, since whether the
% \texttt{endnotelabel} is part of \texttt{endnote} or not depends on if there
% is a list environment involved. Alas, I see no easy way around the PDF
% standard restriction for the list case.
%
%
% On the \LaTeX{} side of things, adding support for tagging entails two basic
Expand Down Expand Up @@ -2947,8 +2946,11 @@
{
role/new-tag = { tag=endnote, role=FENote } ,
role/new-tag = { tag=endnotemark, role=Lbl } ,
role/new-attribute = { EndnoteType } { /O /FENote /NoteType /Endnote } ,
role/new-attribute = { EndnotesList } { /O /List /ListNumbering /Ordered } ,
role/new-tag = { tag=endnotelabel, role=Lbl } ,
role/new-attribute =
{ EndnoteType } { /O /FENote /NoteType /Endnote } ,
role/new-attribute =
{ EndnotesList } { /O /List /ListNumbering /Ordered } ,
}
% \end{macrocode}
% \cs{postnote}
Expand Down Expand Up @@ -3006,42 +3008,43 @@
% \cs{printpostnotes}
% \begin{macrocode}
\socket_new_plug:nnn { tagsupport/postnotes/printlist/begin } { default }
{
\bool_if:NTF \l_@@_print_as_list_bool
{ \tag_tool:n { para/tagging=false } }
{
\tag_tool:n { para/tagging=false }
\mode_leave_vertical:
\tag_struct_begin:n { tag=L, attribute-class=EndnotesList }
}
}
{ \tag_tool:n { para/tagging=false } }
\socket_new_plug:nnn { tagsupport/postnotes/printlist/end } { default }
{
\bool_if:NF \l_@@_print_as_list_bool
{ \tag_struct_end: } % L
}
{ }
\socket_assign_plug:nn { tagsupport/postnotes/printlist/begin } { default }
\socket_assign_plug:nn { tagsupport/postnotes/printlist/end } { default }
\socket_new_plug:nnn { tagsupport/postnotes/printnote/begin } { default }
{
\bool_if:NF \l_@@_print_as_list_bool
{
\mode_leave_vertical:
\tag_struct_begin:n { tag=LI }
}
\tag_struct_begin:n
{
tag = endnote ,
attribute-class = EndnoteType ,
label = { postnote. \l_postnotes_print_note_id_tl } ,
% \end{macrocode}
% CHECK Should we really add a back reference here? I couldn't find any hint
% about this in the standards, but \pkg{latex-lab-footnotes} does it. No
% harm, I guess.
% \begin{macrocode}
ref = { postnotemark. \l_postnotes_print_note_id_tl } ,
}
\@@_tagsup_store_sctructnum:nN
{ postnote } \l_postnotes_print_note_id_tl
}
}
\socket_new_plug:nnn { tagsupport/postnotes/printnote/end } { default }
{
\bool_if:NF \l_@@_print_as_list_bool
{ \tag_struct_end: } % LI
{ \tag_struct_end: } % endnote
}
\socket_assign_plug:nn { tagsupport/postnotes/printnote/begin } { default }
\socket_assign_plug:nn { tagsupport/postnotes/printnote/end } { default }
\socket_new_plug:nnn { tagsupport/postnotes/printmark/begin } { default }
{
\bool_if:NF \l_@@_print_as_list_bool
{
\tag_struct_begin:n { tag=Lbl }
\tag_struct_begin:n { tag=endnotelabel }
\tag_mc_begin:n{ tag=Lbl }
}
}
Expand All @@ -3050,7 +3053,7 @@
\bool_if:NF \l_@@_print_as_list_bool
{
\tag_mc_end:
\tag_struct_end: % Lbl
\tag_struct_end: % endnotelabel
}
}
\socket_assign_plug:nn { tagsupport/postnotes/printmark/begin } { default }
Expand All @@ -3065,9 +3068,7 @@
attribute-class = EndnoteType ,
label = { postnote. \l_postnotes_print_note_id_tl } ,
% \end{macrocode}
% CHECK Should we really add a back reference here? I couldn't find any hint
% about this in the standards, but \pkg{latex-lab-footnotes} does it. No
% harm, I guess.
% CHECK Ditto.
% \begin{macrocode}
ref = { postnotemark. \l_postnotes_print_note_id_tl } ,
}
Expand All @@ -3079,16 +3080,6 @@
\tag_mc_begin:n{}
}
{
\tag_struct_begin:n { tag=LBody }
\tag_struct_begin:n
{
tag = endnote ,
attribute-class = EndnoteType ,
label = { postnote. \l_postnotes_print_note_id_tl } ,
ref = { postnotemark. \l_postnotes_print_note_id_tl } ,
}
\@@_tagsup_store_sctructnum:nN
{ postnote } \l_postnotes_print_note_id_tl
\tag_struct_begin:n { tag=text-unit }
\tag_struct_begin:n { tag=text }
\tag_tool:n { para/tagging=true }
Expand All @@ -3110,8 +3101,6 @@
\tag_tool:n { para/tagging=false }
\tag_struct_end: % text
\tag_struct_end: % text-unit
\tag_struct_end: % endnote
\tag_struct_end: % LBody
}
}
\socket_assign_plug:nn { tagsupport/postnotes/printtext/begin } { default }
Expand Down Expand Up @@ -3210,7 +3199,8 @@
{
\tl_if_empty:NF \l_@@_note_label_tl
{
\prop_gput:cnV { \@@_data_name:e { \l_postnotes_note_id_tl } }
\prop_gput:cnV
{ \@@_data_name:e { \l_postnotes_note_id_tl } }
{ label } \l_@@_note_label_tl
}
}
Expand All @@ -3220,7 +3210,8 @@
{
\tl_if_empty:NF \l_@@_note_zlabel_tl
{
\prop_gput:cnV { \@@_data_name:e { \l_postnotes_note_id_tl } }
\prop_gput:cnV
{ \@@_data_name:e { \l_postnotes_note_id_tl } }
{ zlabel } \l_@@_note_zlabel_tl
}
}
Expand All @@ -3245,7 +3236,7 @@
}
}
% \end{macrocode}
% \pkg{latex-lab-footnotes} creates the footnote structure element
% CHECK \pkg{latex-lab-footnotes} creates the footnote structure element
% (\texttt{FENote} tag) and adds to it a \texttt{/Ref} entry pointing to the
% structures of \emph{all} marks related to the note, and that includes
% \cs{footref}s. I don't see anything stating something of the sort in the
Expand Down
4 changes: 2 additions & 2 deletions testfiles-4runs/pn-tagsup01.xetex.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -2227,7 +2227,7 @@ Completed box being shipped out [3]
..\special{pdf:obj @pdf.obj94 << /Limits [(ID.002) (ID.051)]/Names [(ID.002) @pdf.obj21 (ID.003) @pdf.obj22 (ID.004) @pdf.obj23 (ID.005) @pdf.obj24 (ID.006) @pdf.obj25 (ID.007) @pdf.obj26 (ID.008) @pdf.obj27 (ID.009) @pdf.obj28 (ID.010) @pdf.obj29 (ID.011) @pdf.obj30 (ID.012) @pdf.obj32 (ID.013) @pdf.obj33 (ID.014) @pdf.obj35 (ID.015) @pdf.obj36 (ID.016) @pdf.obj38 (ID.017) @pdf.obj39 (ID.018) @pdf.obj41 (ID.019) @pdf.obj42 (ID.020) @pdf.obj44 (ID.021) @pdf.obj45 (ID.022) @pdf.obj47 (ID.023) @pdf.obj48 (ID.024) @pdf.obj50 (ID.025) @pdf.obj51 (ID.026) @pdf.obj53 (ID.027) @pdf.obj54 (ID.028) @pdf.obj56 (ID.029) @pdf.obj57 (ID.030) @pdf.obj59 (ID.031) @pdf.obj60 (ID.032) @pdf.obj62 (ID.033) @pdf.obj63 (ID.034) @pdf.obj64 (ID.035) @pdf.obj65 (ID.036) @pdf.obj66 (ID.037) @pdf.obj67 (ID.038) @pdf.obj68 (ID.039) @pdf.obj70 (ID.040) @pdf.obj71 (ID.041) @pdf.obj72 (ID.042) @pdf.obj73 (ID.043) @pdf.obj74 (ID.044) @pdf.obj75 (ID.045) @pdf.obj76 (ID.046) @pdf.obj78 (ID.047) @pdf.obj79 (ID.048) @pdf.obj80 (ID.049) @pdf.obj81 (ID.050) @pdf.obj82 (ID.051) @pdf.obj83 ] >>}
..\special{pdf:obj @pdf.obj95 << /Limits [(ID.052) (ID.060)]/Names [(ID.052) @pdf.obj84 (ID.053) @pdf.obj86 (ID.054) @pdf.obj87 (ID.055) @pdf.obj88 (ID.056) @pdf.obj89 (ID.057) @pdf.obj90 (ID.058) @pdf.obj91 (ID.059) @pdf.obj92 (ID.060) @pdf.obj93 ] >>}
..\special{pdf:obj @pdf.obj96 << /Kids [@pdf.obj94 @pdf.obj95] >>}
..\special{pdf:obj @pdf.obj7 << /Artifact /NonStruct /DocumentFragment /Art /Aside /Note /H7 /H6 /H8 /H6 /H9 /H6 /H10 /H6 /Title /P /FENote /Note /Sub /Span /Em /Span /Strong /Span /title /P /part /P /section /H1 /subsection /H2 /subsubsection /H3 /paragraph /H4 /subparagraph /H5 /list /L /itemize /L /enumerate /L /description /L /quote /BlockQuote /quotation /BlockQuote /verbatim /P /item /LI /itemlabel /Lbl /itembody /LBody /footnote /Note /footnotemark /Lbl /footnotelabel /Lbl /text-unit /Part /text /P /theorem-like /Sect /codeline /Span /float /Note /figures /Sect /tables /Sect /endnote /Note /endnotemark /Lbl >>}
..\special{pdf:obj @pdf.obj7 << /Artifact /NonStruct /DocumentFragment /Art /Aside /Note /H7 /H6 /H8 /H6 /H9 /H6 /H10 /H6 /Title /P /FENote /Note /Sub /Span /Em /Span /Strong /Span /title /P /part /P /section /H1 /subsection /H2 /subsubsection /H3 /paragraph /H4 /subparagraph /H5 /list /L /itemize /L /enumerate /L /description /L /quote /BlockQuote /quotation /BlockQuote /verbatim /P /item /LI /itemlabel /Lbl /itembody /LBody /footnote /Note /footnotemark /Lbl /footnotelabel /Lbl /text-unit /Part /text /P /theorem-like /Sect /codeline /Span /float /Note /figures /Sect /tables /Sect /endnote /Note /endnotemark /Lbl /endnotelabel /Lbl >>}
..\special{pdf:obj @pdf.obj97 << /justify <</O/Layout/TextAlign/Justify>>
/EndnotesList <</O/List/ListNumbering/Ordered>>
/EndnoteType <</O/FENote/NoteType/Endnote>>
Expand All @@ -2239,7 +2239,7 @@ Completed box being shipped out [3]
..\special{pdf:obj @pdf.obj15 << /Type /Namespace /NS (https://www.latex-project.org/ns/dflt/2022) /RoleMapNS @pdf.obj16 >>}
..\special{pdf:obj @pdf.obj18 << /chapter [/H1 @pdf.obj11] /section [/H2 @pdf.obj11] /subsection [/H3 @pdf.obj11] /subsubsection [/H4 @pdf.obj11] /paragraph [/H5 @pdf.obj11] /subparagraph [/H6 @pdf.obj11] >>}
..\special{pdf:obj @pdf.obj17 << /Type /Namespace /NS (https://www.latex-project.org/ns/book/2022) /RoleMapNS @pdf.obj18 >>}
..\special{pdf:obj @pdf.obj20 << /endnote [/FENote @pdf.obj11] /endnotemark [/Lbl @pdf.obj11] >>}
..\special{pdf:obj @pdf.obj20 << /endnote [/FENote @pdf.obj11] /endnotemark [/Lbl @pdf.obj11] /endnotelabel [/Lbl @pdf.obj11] >>}
..\special{pdf:obj @pdf.obj19 << /Type /Namespace /NS (data:,A63761E-9D7-4FBB-9B27-C3BC8D9BFB06) /RoleMapNS @pdf.obj20 >>}
..\special{pdf:obj @pdf.obj8 [ @pdf.obj9 @pdf.obj11 @pdf.obj13 @pdf.obj15 @pdf.obj17 @pdf.obj19 ]}
..\special{pdf:obj @pdf.obj21 << /Type /StructElem /S /Document /NS @pdf.obj11 /P @pdf.obj5 /K [@pdf.obj24 @pdf.obj62] /ID (ID.002) >>}
Expand Down
2 changes: 1 addition & 1 deletion testfiles-4runs/pn-tagsup02.xetex.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -2227,7 +2227,7 @@ Completed box being shipped out [3]
..\special{pdf:obj @pdf.obj82 << /Limits [(ID.002) (ID.051)]/Names [(ID.002) @pdf.obj9 (ID.003) @pdf.obj10 (ID.004) @pdf.obj11 (ID.005) @pdf.obj12 (ID.006) @pdf.obj13 (ID.007) @pdf.obj14 (ID.008) @pdf.obj15 (ID.009) @pdf.obj16 (ID.010) @pdf.obj17 (ID.011) @pdf.obj18 (ID.012) @pdf.obj20 (ID.013) @pdf.obj21 (ID.014) @pdf.obj23 (ID.015) @pdf.obj24 (ID.016) @pdf.obj26 (ID.017) @pdf.obj27 (ID.018) @pdf.obj29 (ID.019) @pdf.obj30 (ID.020) @pdf.obj32 (ID.021) @pdf.obj33 (ID.022) @pdf.obj35 (ID.023) @pdf.obj36 (ID.024) @pdf.obj38 (ID.025) @pdf.obj39 (ID.026) @pdf.obj41 (ID.027) @pdf.obj42 (ID.028) @pdf.obj44 (ID.029) @pdf.obj45 (ID.030) @pdf.obj47 (ID.031) @pdf.obj48 (ID.032) @pdf.obj50 (ID.033) @pdf.obj51 (ID.034) @pdf.obj52 (ID.035) @pdf.obj53 (ID.036) @pdf.obj54 (ID.037) @pdf.obj55 (ID.038) @pdf.obj56 (ID.039) @pdf.obj58 (ID.040) @pdf.obj59 (ID.041) @pdf.obj60 (ID.042) @pdf.obj61 (ID.043) @pdf.obj62 (ID.044) @pdf.obj63 (ID.045) @pdf.obj64 (ID.046) @pdf.obj66 (ID.047) @pdf.obj67 (ID.048) @pdf.obj68 (ID.049) @pdf.obj69 (ID.050) @pdf.obj70 (ID.051) @pdf.obj71 ] >>}
..\special{pdf:obj @pdf.obj83 << /Limits [(ID.052) (ID.060)]/Names [(ID.052) @pdf.obj72 (ID.053) @pdf.obj74 (ID.054) @pdf.obj75 (ID.055) @pdf.obj76 (ID.056) @pdf.obj77 (ID.057) @pdf.obj78 (ID.058) @pdf.obj79 (ID.059) @pdf.obj80 (ID.060) @pdf.obj81 ] >>}
..\special{pdf:obj @pdf.obj84 << /Kids [@pdf.obj82 @pdf.obj83] >>}
..\special{pdf:obj @pdf.obj7 << /Artifact /NonStruct /DocumentFragment /Art /Aside /Note /H7 /H6 /H8 /H6 /H9 /H6 /H10 /H6 /Title /P /FENote /Note /Sub /Span /Em /Span /Strong /Span /title /P /part /P /section /H1 /subsection /H2 /subsubsection /H3 /paragraph /H4 /subparagraph /H5 /list /L /itemize /L /enumerate /L /description /L /quote /BlockQuote /quotation /BlockQuote /verbatim /P /item /LI /itemlabel /Lbl /itembody /LBody /footnote /Note /footnotemark /Lbl /footnotelabel /Lbl /text-unit /Part /text /P /theorem-like /Sect /codeline /Span /float /Note /figures /Sect /tables /Sect /endnote /Note /endnotemark /Lbl >>}
..\special{pdf:obj @pdf.obj7 << /Artifact /NonStruct /DocumentFragment /Art /Aside /Note /H7 /H6 /H8 /H6 /H9 /H6 /H10 /H6 /Title /P /FENote /Note /Sub /Span /Em /Span /Strong /Span /title /P /part /P /section /H1 /subsection /H2 /subsubsection /H3 /paragraph /H4 /subparagraph /H5 /list /L /itemize /L /enumerate /L /description /L /quote /BlockQuote /quotation /BlockQuote /verbatim /P /item /LI /itemlabel /Lbl /itembody /LBody /footnote /Note /footnotemark /Lbl /footnotelabel /Lbl /text-unit /Part /text /P /theorem-like /Sect /codeline /Span /float /Note /figures /Sect /tables /Sect /endnote /Note /endnotemark /Lbl /endnotelabel /Lbl >>}
..\special{pdf:obj @pdf.obj85 << /justify <</O/Layout/TextAlign/Justify>>
/EndnotesList <</O/List/ListNumbering/Ordered>>
/EndnoteType <</O/FENote/NoteType/Endnote>>
Expand Down
Loading

0 comments on commit 1bf4be5

Please sign in to comment.