From a8b15bd1d34d435cceb19eb4761879026ce92734 Mon Sep 17 00:00:00 2001 From: gusbrs <19410606+gusbrs@users.noreply.github.com> Date: Mon, 14 Oct 2024 17:43:46 -0300 Subject: [PATCH] Provide xtemplate based definitions for list environments And with this, we have tagging implemented entirely relying on the public API for the purpose. --- postnotes.dtx | 70 ++++++++++++++++++++------ testfiles-4runs/pn-tagsup01.luatex.tlg | 2 +- testfiles-4runs/pn-tagsup01.tlg | 2 +- testfiles-4runs/pn-tagsup01.xetex.tlg | 2 +- testfiles-4runs/pn-tagsup02.luatex.tlg | 2 +- testfiles-4runs/pn-tagsup02.tlg | 2 +- testfiles-4runs/pn-tagsup02.xetex.tlg | 2 +- testfiles-4runs/pn-tagsup04.luatex.tlg | 2 +- testfiles-4runs/pn-tagsup04.tlg | 2 +- testfiles-4runs/pn-tagsup04.xetex.tlg | 2 +- 10 files changed, 64 insertions(+), 24 deletions(-) diff --git a/postnotes.dtx b/postnotes.dtx index 56b9329..ec46eb6 100644 --- a/postnotes.dtx +++ b/postnotes.dtx @@ -3109,25 +3109,65 @@ \socket_assign_plug:nn { tagsupport/postnotes/printtext/begin } { default } \socket_assign_plug:nn { tagsupport/postnotes/printtext/end } { default } % \end{macrocode} -% As far as I can tell, there is no (public) interface to control/tweak the -% default tagging of lists (see \url{https://tex.stackexchange.com/q/703083}). -% So I could only make things work by tampering with -% \pkg{latex-lab-testphase-block}'s internals. -% \begin{macrocode} - \cs_new:Npn \@@_tagsup_print_block_begin: - { \tag_struct_begin:n { tag=L, attribute-class=EndnotesList } } - \AddToHook { postnotes/print/begin } [ postnotes/tagsup ] +% Provide \pkg{xtemplate} based redefinitions of \env{postnoteslist} and +% \pkg{postnoteslisthang}. This is needed because, as far as I can tell, it +% is the only way to set \opt{tag} and \opt{attribute-class} for the list +% struct without tampering with \pkg{latex-lab-testphase-block}'s internals. +% \begin{macrocode} + \DeclareInstance { blockenv } { postnoteslist } { display } + { + env-name = postnoteslist , + tag-name = L , + tag-class = EndnotesList , + tagging-recipe = list , + inner-level-counter = , + level-increase = true , + setup-code = , + block-instance = list , + inner-instance = postnoteslist , + } + \DeclareInstanceCopy { blockenv } { postnoteslisthang } { postnoteslist } + \EditInstance { blockenv } { postnoteslisthang } + { env-name = postnoteslisthang } + \DeclareInstance { list } { postnoteslist } { std } + { item-instance = postnoteslist } + \DeclareInstance { item } { postnoteslist } { std } + { + label-format = { \hspace { \labelsep } \normalfont ~ #1 } , + label-align = left , + } + \RenewDocumentEnvironment { postnoteslist } { } + { + \UseInstance { blockenv } { postnoteslist } + { + leftmargin = 0pt , + label-width = 0pt , + item-indent = .5\parindent , + rightmargin = 0pt , + parindent = \parindent , + par-skip = \parskip , + item-skip = 0pt , + beginsep = .5\topsep , + begin-par-skip = .5\partopsep , + } + } + { \endblockenv } + \RenewDocumentEnvironment { postnoteslisthang } { } { - \bool_if:NT \l_@@_print_as_list_bool + \UseInstance { blockenv } { postnoteslisthang } { - \exp_args:Ne \AddToHookNext - { env / \l_@@_print_env_tl / begin } - { - \cs_set_eq:NN \__block_list_begin: - \@@_tagsup_print_block_begin: - } + leftmargin = 1em , + label-width = -\leftmargin , + item-indent = -2\leftmargin , + rightmargin = 0pt , + parindent = \parindent , + par-skip = \parskip , + item-skip = 0pt , + beginsep = .5\topsep , + begin-par-skip = .5\partopsep , } } + { \endblockenv } % \end{macrocode} % Setup for \cs{label} and \cs{zlabel} inside the note. % \begin{macrocode} diff --git a/testfiles-4runs/pn-tagsup01.luatex.tlg b/testfiles-4runs/pn-tagsup01.luatex.tlg index a8ff3ce..4fe7dee 100644 --- a/testfiles-4runs/pn-tagsup01.luatex.tlg +++ b/testfiles-4runs/pn-tagsup01.luatex.tlg @@ -731,7 +731,7 @@ The sequence \g__tag_struct_tag_stack_seq contains the items (without outer brac Package tagpdf Info: Parent-Child 'Sect' --> 'L'. (tagpdf) Relation is 1 (='0..n') (tagpdf) Rolemapped from 'Sect/pdf2' --> 'L/pdf2' on line ... -tagpdf DEBUG Info: Struct 35 begin inserted with options: tag=L,attribute-class=EndnotesList +tagpdf DEBUG Info: Struct 35 begin inserted with options: tag=\l__tag_L_tag_tl ,attribute-class=\l__tag_L_attr_class_tl (tagpdf DEBUG) [on line ...] The sequence \g__tag_struct_tag_stack_seq contains the items (without outer braces): > {{L}{L}} diff --git a/testfiles-4runs/pn-tagsup01.tlg b/testfiles-4runs/pn-tagsup01.tlg index 768a385..b6d1d1e 100644 --- a/testfiles-4runs/pn-tagsup01.tlg +++ b/testfiles-4runs/pn-tagsup01.tlg @@ -1019,7 +1019,7 @@ The sequence \g__tag_struct_tag_stack_seq contains the items (without outer brac Package tagpdf Info: Parent-Child 'Sect' --> 'L'. (tagpdf) Relation is 1 (='0..n') (tagpdf) Rolemapped from 'Sect/pdf2' --> 'L/pdf2' on line ... -tagpdf DEBUG Info: Struct 35 begin inserted with options: tag=L,attribute-class=EndnotesList +tagpdf DEBUG Info: Struct 35 begin inserted with options: tag=\l__tag_L_tag_tl ,attribute-class=\l__tag_L_attr_class_tl (tagpdf DEBUG) [on line ...] The sequence \g__tag_struct_tag_stack_seq contains the items (without outer braces): > {{L}{L}} diff --git a/testfiles-4runs/pn-tagsup01.xetex.tlg b/testfiles-4runs/pn-tagsup01.xetex.tlg index a40b034..cef8459 100644 --- a/testfiles-4runs/pn-tagsup01.xetex.tlg +++ b/testfiles-4runs/pn-tagsup01.xetex.tlg @@ -1030,7 +1030,7 @@ The sequence \g__tag_struct_tag_stack_seq contains the items (without outer brac Package tagpdf Info: Parent-Child 'Sect' --> 'L'. (tagpdf) Relation is 1 (='0..n') (tagpdf) Rolemapped from 'Sect/pdf2' --> 'L/pdf2' on line ... -tagpdf DEBUG Info: Struct 35 begin inserted with options: tag=L,attribute-class=EndnotesList +tagpdf DEBUG Info: Struct 35 begin inserted with options: tag=\l__tag_L_tag_tl ,attribute-class=\l__tag_L_attr_class_tl (tagpdf DEBUG) [on line ...] The sequence \g__tag_struct_tag_stack_seq contains the items (without outer braces): > {{L}{L}} diff --git a/testfiles-4runs/pn-tagsup02.luatex.tlg b/testfiles-4runs/pn-tagsup02.luatex.tlg index 8cc96af..576e2d1 100644 --- a/testfiles-4runs/pn-tagsup02.luatex.tlg +++ b/testfiles-4runs/pn-tagsup02.luatex.tlg @@ -731,7 +731,7 @@ The sequence \g__tag_struct_tag_stack_seq contains the items (without outer brac Package tagpdf Info: Parent-Child 'Sect' --> 'L'. (tagpdf) Relation is 1 (='0..n') (tagpdf) Rolemapped from: 'Sect' --> 'L' on line ... -tagpdf DEBUG Info: Struct 35 begin inserted with options: tag=L,attribute-class=EndnotesList +tagpdf DEBUG Info: Struct 35 begin inserted with options: tag=\l__tag_L_tag_tl ,attribute-class=\l__tag_L_attr_class_tl (tagpdf DEBUG) [on line ...] The sequence \g__tag_struct_tag_stack_seq contains the items (without outer braces): > {{L}{L}} diff --git a/testfiles-4runs/pn-tagsup02.tlg b/testfiles-4runs/pn-tagsup02.tlg index b346e37..4e40c29 100644 --- a/testfiles-4runs/pn-tagsup02.tlg +++ b/testfiles-4runs/pn-tagsup02.tlg @@ -1019,7 +1019,7 @@ The sequence \g__tag_struct_tag_stack_seq contains the items (without outer brac Package tagpdf Info: Parent-Child 'Sect' --> 'L'. (tagpdf) Relation is 1 (='0..n') (tagpdf) Rolemapped from: 'Sect' --> 'L' on line ... -tagpdf DEBUG Info: Struct 35 begin inserted with options: tag=L,attribute-class=EndnotesList +tagpdf DEBUG Info: Struct 35 begin inserted with options: tag=\l__tag_L_tag_tl ,attribute-class=\l__tag_L_attr_class_tl (tagpdf DEBUG) [on line ...] The sequence \g__tag_struct_tag_stack_seq contains the items (without outer braces): > {{L}{L}} diff --git a/testfiles-4runs/pn-tagsup02.xetex.tlg b/testfiles-4runs/pn-tagsup02.xetex.tlg index 6849b6c..e06e12e 100644 --- a/testfiles-4runs/pn-tagsup02.xetex.tlg +++ b/testfiles-4runs/pn-tagsup02.xetex.tlg @@ -1030,7 +1030,7 @@ The sequence \g__tag_struct_tag_stack_seq contains the items (without outer brac Package tagpdf Info: Parent-Child 'Sect' --> 'L'. (tagpdf) Relation is 1 (='0..n') (tagpdf) Rolemapped from: 'Sect' --> 'L' on line ... -tagpdf DEBUG Info: Struct 35 begin inserted with options: tag=L,attribute-class=EndnotesList +tagpdf DEBUG Info: Struct 35 begin inserted with options: tag=\l__tag_L_tag_tl ,attribute-class=\l__tag_L_attr_class_tl (tagpdf DEBUG) [on line ...] The sequence \g__tag_struct_tag_stack_seq contains the items (without outer braces): > {{L}{L}} diff --git a/testfiles-4runs/pn-tagsup04.luatex.tlg b/testfiles-4runs/pn-tagsup04.luatex.tlg index 44056b8..d5271e4 100644 --- a/testfiles-4runs/pn-tagsup04.luatex.tlg +++ b/testfiles-4runs/pn-tagsup04.luatex.tlg @@ -205,7 +205,7 @@ The sequence \g__tag_struct_tag_stack_seq contains the items (without outer brac Package tagpdf Info: Parent-Child 'Sect' --> 'L'. (tagpdf) Relation is 1 (='0..n') (tagpdf) Rolemapped from 'Sect/pdf2' --> 'L/pdf2' on line ... -tagpdf DEBUG Info: Struct 18 begin inserted with options: tag=L,attribute-class=EndnotesList +tagpdf DEBUG Info: Struct 18 begin inserted with options: tag=\l__tag_L_tag_tl ,attribute-class=\l__tag_L_attr_class_tl (tagpdf DEBUG) [on line ...] The sequence \g__tag_struct_tag_stack_seq contains the items (without outer braces): > {{L}{L}} diff --git a/testfiles-4runs/pn-tagsup04.tlg b/testfiles-4runs/pn-tagsup04.tlg index 6c5e2d4..36c0727 100644 --- a/testfiles-4runs/pn-tagsup04.tlg +++ b/testfiles-4runs/pn-tagsup04.tlg @@ -259,7 +259,7 @@ The sequence \g__tag_struct_tag_stack_seq contains the items (without outer brac Package tagpdf Info: Parent-Child 'Sect' --> 'L'. (tagpdf) Relation is 1 (='0..n') (tagpdf) Rolemapped from 'Sect/pdf2' --> 'L/pdf2' on line ... -tagpdf DEBUG Info: Struct 18 begin inserted with options: tag=L,attribute-class=EndnotesList +tagpdf DEBUG Info: Struct 18 begin inserted with options: tag=\l__tag_L_tag_tl ,attribute-class=\l__tag_L_attr_class_tl (tagpdf DEBUG) [on line ...] The sequence \g__tag_struct_tag_stack_seq contains the items (without outer braces): > {{L}{L}} diff --git a/testfiles-4runs/pn-tagsup04.xetex.tlg b/testfiles-4runs/pn-tagsup04.xetex.tlg index 4a1b013..300390a 100644 --- a/testfiles-4runs/pn-tagsup04.xetex.tlg +++ b/testfiles-4runs/pn-tagsup04.xetex.tlg @@ -261,7 +261,7 @@ The sequence \g__tag_struct_tag_stack_seq contains the items (without outer brac Package tagpdf Info: Parent-Child 'Sect' --> 'L'. (tagpdf) Relation is 1 (='0..n') (tagpdf) Rolemapped from 'Sect/pdf2' --> 'L/pdf2' on line ... -tagpdf DEBUG Info: Struct 18 begin inserted with options: tag=L,attribute-class=EndnotesList +tagpdf DEBUG Info: Struct 18 begin inserted with options: tag=\l__tag_L_tag_tl ,attribute-class=\l__tag_L_attr_class_tl (tagpdf DEBUG) [on line ...] The sequence \g__tag_struct_tag_stack_seq contains the items (without outer braces): > {{L}{L}}