Skip to content

Commit

Permalink
change tagstop
Browse files Browse the repository at this point in the history
  • Loading branch information
u-fischer committed Dec 8, 2023
1 parent 1db5b4a commit dee83ba
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 51 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ this project uses date-based 'snapshot' version identifiers.
- ignore AFref, AFinline-key with empty value.
- Documentation changes
- move para bool to tagpdf-base

- \tag_stop:/\tag_start: keep tracking of nesting with a counter.

### Fixed
- test for structure end if tagging has been stopped.


### Removed
- \tag_stop_group_begin: and \tag_stop_group_end:

## [2023-11-19]
Version: 0.98q

Expand Down
20 changes: 6 additions & 14 deletions doc/tagpdf.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1961,27 +1961,19 @@ \subsection{Interrupting the tagging}
\begin{docCommand}[nosep]{tag_start:}{}\end{docCommand}
\begin{docCommand}[nosep]{tagstop}{}\end{docCommand}
\begin{docCommand}[nosep]{tagstart}{}\end{docCommand}
\begin{docCommand}[nosep]{tag_stop_group_begin:}{}\end{docCommand}
\begin{docCommand}{tag_start_group_end:}{}\end{docCommand}
\begin{docCommand}[nosep]{tag_stop:n}{\marg{label}}\end{docCommand}
\begin{docCommand}{tag_start:n}{\marg{label}}\end{docCommand}

This commands stop and start tagging in the current group by switching
\emph{local} booleans. They also stop the increasing of the counters which
keep track of paragraphs if the correct wrapper commands are used. The
grouping commands also open and close a group.
keep track of paragraphs if the correct wrapper commands are used.

Restarting tagging is normally only needed if groups can't be used and then
must be done with care: |\tagstart| should normally only restart tagging if
the corresponding stop command actually stopped tagging. In complicated
case the following labeled version can be used:

\begin{docCommand}[nosep]{tag_stop:n}{\marg{label}}\end{docCommand}
\begin{docCommand}{tag_start:n}{\marg{label}}\end{docCommand}
the corresponding stop command actually stopped tagging. This is implement
through a local counter which keeps track of the level.

This commands stop and start tagging in the current group
by switching \emph{local} booleans, but |\tag_start:n|
only restarts if the corresponding |tag_stop:n| actually
stopped something. This is meant for a situation like the following,
where you don't want that the inner |\tag_start:n| restarts tagging.
The \meta{label} can be used to identify the command in debugging message.

\begin{taglstlisting}
\tag_stop:n{outer}
Expand Down
6 changes: 4 additions & 2 deletions tagpdf-mc-shared.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,14 @@
{
\tag_mc_end_push:
\tag_mc_begin:n {artifact=#1}
\tag_stop_group_begin:
\group_begin:
\tag_stop:n{artifact-group}
}

\cs_set_protected:Npn \tag_mc_artifact_group_end:
{
\tag_stop_group_end:
\tag_start:n{artifact-group}
\group_end:
\tag_mc_end:
\tag_mc_begin_pop:n{}
}
Expand Down
42 changes: 13 additions & 29 deletions tagpdf.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@
% \end{syntax}
% \end{function}
%
% \begin{function}{ \tag_stop_group_begin:, \tag_stop_group_end:,
% \begin{function}{
% \tag_stop:, \tag_start:,
% \tagstop, \tagstart }
% We need commands to stop tagging in some places.
% They simply switches the two local booleans. The grouping commands
% can be used to group the effect.
% They simply switches the two local booleans.
% \end{function}
%
% \begin{function}{\tag_stop:n, \tag_start:n }%
Expand Down Expand Up @@ -462,16 +461,17 @@
%
% \section{General tagging commands}
%
% \begin{macro}{\tag_stop_group_begin:,
% \tag_stop_group_end:,
% \begin{macro}{
% \tag_stop:,\tag_start:,
% \tag_stop:n,\tag_start:n}
% We need commands to stop tagging in some places.
% This simply switches the two local booleans.
% In some cases tagging should only restart, if
% it actually was stopped before. For this it is possible
% to label a stop.

% The commands keep track of the nesting with a local
% counter. Tagging only is only restarted at the outer level,
% if the current level is 1.
% The commands with argument allow to give a label. This is only used
% in debugging messages to allow to follow the nesting.
%
% \begin{variable}{\l_@@_tag_stop_int}
% When stop/start pairs are nested we do not want the inner
% start command to restart tagging. To control this we use a
Expand All @@ -485,22 +485,6 @@
% \end{variable}
%
% \begin{macrocode}
%<package>\cs_new_protected:Npn \tag_stop_group_begin:
%<debug>\cs_set_protected:Npn \tag_stop_group_begin:
{
\group_begin:
%<debug> \msg_note:nnx {tag / debug }{tag-stop}{ \int_use:N \l_@@_tag_stop_int }
\int_incr:N \l_@@_tag_stop_int
\bool_set_false:N \l_@@_active_struct_bool
\bool_set_false:N \l_@@_active_mc_bool
\@@_stop_para_ints:
}
%<package>\cs_set_eq:NN \tag_stop_group_end: \group_end:
%<debug>\cs_set_protected:Npn \tag_stop_group_end:
%<debug> {
%<debug> \group_end:
%<debug> \msg_note:nnx {tag / debug }{tag-start}{ \int_use:N \l_@@_tag_stop_int }
%<debug> }
\cs_set_protected:Npn \tag_stop:
{
%<debug> \msg_note:nnx {tag / debug }{tag-stop}{ \int_use:N \l_@@_tag_stop_int }
Expand All @@ -511,13 +495,13 @@
}
\cs_set_protected:Npn \tag_start:
{
\int_decr:N \l_@@_tag_stop_int
\int_if_zero:nF { \l_@@_tag_stop_int } { \int_decr:N \l_@@_tag_stop_int }
\int_if_zero:nT { \l_@@_tag_stop_int }
{
\bool_set_true:N \l_@@_active_struct_bool
\bool_set_true:N \l_@@_active_mc_bool
\@@_start_para_ints:
}
}
%<debug> \msg_note:nnx {tag / debug }{tag-start}{ \int_use:N \l_@@_tag_stop_int }
}
\cs_set_eq:NN\tagstop\tag_stop:
Expand All @@ -534,13 +518,13 @@
}
\cs_set_protected:Npn \tag_start:n #1
{
\int_decr:N \l_@@_tag_stop_int
\int_if_zero:nF { \l_@@_tag_stop_int } { \int_decr:N \l_@@_tag_stop_int }
\int_if_zero:nT { \l_@@_tag_stop_int }
{
\bool_set_true:N \l_@@_active_struct_bool
\bool_set_true:N \l_@@_active_mc_bool
\@@_start_para_ints:
}
}
%<debug> \msg_note:nnxx {tag / debug }{tag-start}{ \int_use:N \l_@@_tag_stop_int }{#1}
}
%</package|debug>
Expand Down
12 changes: 12 additions & 0 deletions testfiles-luatex/debug-structures-2.tlg
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: hangfrom [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: hangfrom [on line ...]
Package tagpdf Warning: structure with label blub has already been used
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: headfoot [on line ...]
[1
] (debug-structures-2.aux)
LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
Expand Down
12 changes: 12 additions & 0 deletions testfiles-luatex/debug-structures.tlg
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: hangfrom [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: hangfrom [on line ...]
Package tagpdf Warning: structure with label blub has already been used
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: headfoot [on line ...]
[1
] (debug-structures.aux)
LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
Expand Down
12 changes: 12 additions & 0 deletions testfiles-pdftex/debug-structures-2.pdftexmain.tlg
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: hangfrom [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: hangfrom [on line ...]
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: headfoot [on line ...]
[1
] (debug-structures-2.aux)
=========================
Expand Down
12 changes: 12 additions & 0 deletions testfiles-pdftex/debug-structures-2.tlg
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: hangfrom [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: hangfrom [on line ...]
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: headfoot [on line ...]
[1
] (debug-structures-2.aux)
=========================
Expand Down
12 changes: 12 additions & 0 deletions testfiles-pdftex/debug-structures.pdftexmain.tlg
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: hangfrom [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: hangfrom [on line ...]
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: headfoot [on line ...]
[1
] (debug-structures.aux)
=========================
Expand Down
12 changes: 12 additions & 0 deletions testfiles-pdftex/debug-structures.tlg
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: hangfrom [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: hangfrom [on line ...]
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: headfoot [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: headfoot [on line ...]
[1
] (debug-structures.aux)
=========================
Expand Down
18 changes: 16 additions & 2 deletions testfiles/test-start-stop.lvt
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,29 @@
\ASSERTSTR{\tag_status:}{ACTIVE}
}

\TEST{tag-stop-label2}
\TEST{tag-stop-label1}
{
\ASSERTSTR{\tag_status:}{ACTIVE}
\tag_stop:n{L1}
\ASSERTSTR{\tag_status:}{NOT~ACTIVE}
\tag_start:n{L1}
\ASSERTSTR{\tag_status:}{ACTIVE}
}

\TEST{tag-stop-label-nested}
{
\ASSERTSTR{\tag_status:}{ACTIVE}
\tag_stop:n{L1}
\ASSERTSTR{\tag_status:}{NOT~ACTIVE}
\tag_start:n{LXX}
\tag_stop:n{L2}
\ASSERTSTR{\tag_status:}{NOT~ACTIVE}
\tag_start:n{L2}
\ASSERTSTR{\tag_status:}{NOT~ACTIVE}
\tag_start:n{L1}
\ASSERTSTR{\tag_status:}{ACTIVE}
}


\tag_stop:

\TEST{tag-stop-label2}
Expand Down
13 changes: 11 additions & 2 deletions testfiles/test-start-stop.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,23 @@ PASSED
PASSED
============================================================
============================================================
TEST 4: tag-stop-label2
TEST 4: tag-stop-label1
============================================================
PASSED
PASSED
PASSED
============================================================
============================================================
TEST 5: tag-stop-label2
TEST 5: tag-stop-label-nested
============================================================
PASSED
PASSED
PASSED
PASSED
PASSED
============================================================
============================================================
TEST 6: tag-stop-label2
============================================================
PASSED
PASSED
Expand Down

0 comments on commit dee83ba

Please sign in to comment.