Skip to content

Commit

Permalink
remove fallback for delayed shipout
Browse files Browse the repository at this point in the history
  • Loading branch information
u-fischer committed Feb 12, 2025
1 parent 6db6253 commit 0a17694
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 116 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ this project uses date-based 'snapshot' version identifiers.
## [Unreleased]

### Added
- removed fallback code for delayedshipout
- removed code related to now unused kernel hooks
- phoneme key for `\tagstructbegin`.

## [2025-01-10]
Expand Down
21 changes: 1 addition & 20 deletions doc/tagpdf.tex
Original file line number Diff line number Diff line change
Expand Up @@ -899,26 +899,7 @@ \subsection{Task 1: Marking the chunks: the mark-content-step}
mark these text chunks correctly one has to analyze the code creating
such content to find suitable places to inject the literals.

\item The literals are inserted directly and not at shipout. This means
that due to the asynchronous page breaking of \TeX\ the MCID-number
can be wrong even if the counter is reset at every page. This package
uses in generic mode a label-ref-system to get around this problem.
This sadly means that often at least three compilations are needed
until everything has settled down.

It can actually be worse: If the text is changed after the MCID-numbers
have been assigned, and a new mc-chunk is inserted in the middle of the
page, then all the numbers have to be recalculated and that requires
again a number of compilations until it really settles down again.
Internal references are especially problematic here, as the first
compilation typically creates a non-link |??|, and only the second
inserts the structure and the new mc. When the reference system in \LaTeX\
will be extended, care will be taken to ensure that already the dummy
text builds a chunk. Until then the advice is to first compile the
document and resolve all cross-reference and to activate tagging only at
the end.



\item There exist environments which process their content more than once
-- examples are \texttt{align} and \texttt{tabularx}.
So one has to check for doublets and holes in the counting system.
Expand Down
97 changes: 15 additions & 82 deletions tagpdf-mc-generic.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -544,89 +544,22 @@
% We also define a wrapper around the low-level command as luamode will need
% something different.
% \begin{macrocode}
\bool_if:NTF\g_@@_delayed_shipout_bool
{
\hook_gput_code:nnn {shipout/before}{tagpdf}{ \flag_clear:n { @@/mcid } }
\cs_set_protected:Npn \@@_mc_bdc_mcid:nn #1 #2
{
\int_gincr:N \c@g_@@_MCID_abs_int
\@@_property_record:eV
{
mcid-\int_use:N \c@g_@@_MCID_abs_int
}
\c_@@_property_mc_clist
\@@_mc_bdc_shipout:ee
{#1}
{
/MCID~\flag_height:n { @@/mcid }
\flag_raise:n { @@/mcid }~ #2
}
}
}
% \end{macrocode}
% if the engine is too old, we have to revert to earlier method.
% \begin{macrocode}
{
\msg_new:nnn { tagpdf } { old-engine }
{
The~engine~or~the~PDF management~is~too~old~or\\
delayed~shipout~has~been~disabled.\\
Fast~numbering~of~MC-chunks~not~available.\\
More~compilations~will~be~needed~in~generic~mode.
}
\msg_warning:nn { tagpdf} { old-engine }
\@@_prop_new:N \g_@@_MCID_byabspage_prop
\int_new:N \g_@@_MCID_tmp_bypage_int
\cs_generate_variant:Nn \@@_mc_bdc:nn {ne}
% \end{macrocode}
% revert the attribute:
% \begin{macrocode}
\property_gset:nnnn {tagmcid } { now }
{0} { \int_use:N \g_@@_MCID_tmp_bypage_int }
\cs_new_protected:Npn \@@_mc_bdc_mcid:nn #1 #2
\hook_gput_code:nnn {shipout/before}{tagpdf}{ \flag_clear:n { @@/mcid } }
\cs_set_protected:Npn \@@_mc_bdc_mcid:nn #1 #2
{
\int_gincr:N \c@g_@@_MCID_abs_int
\@@_property_record:eV
{
\int_gincr:N \c@g_@@_MCID_abs_int
\tl_set:Ne \l_@@_mc_ref_abspage_tl
{
\property_ref:enn %3 args
{
mcid-\int_use:N \c@g_@@_MCID_abs_int
}
{ tagabspage }
{-1}
}
\prop_get:NoNTF
\g_@@_MCID_byabspage_prop
{
\l_@@_mc_ref_abspage_tl
}
\l_@@_mc_tmpa_tl
{
%key already present, use value for MCID and add 1 for the next
\int_gset:Nn \g_@@_MCID_tmp_bypage_int { \l_@@_mc_tmpa_tl }
\@@_prop_gput:Nee
\g_@@_MCID_byabspage_prop
{ \l_@@_mc_ref_abspage_tl }
{ \int_eval:n {\l_@@_mc_tmpa_tl +1} }
}
{
%key not present, set MCID to 0 and insert 1
\int_gzero:N \g_@@_MCID_tmp_bypage_int
\@@_prop_gput:Nee
\g_@@_MCID_byabspage_prop
{ \l_@@_mc_ref_abspage_tl }
{1}
}
\@@_property_record:eV
{
mcid-\int_use:N \c@g_@@_MCID_abs_int
}
\c_@@_property_mc_clist
\@@_mc_bdc:ne
{#1}
{ /MCID~\int_eval:n { \g_@@_MCID_tmp_bypage_int }~ \exp_not:n { #2 } }
}
}
mcid-\int_use:N \c@g_@@_MCID_abs_int
}
\c_@@_property_mc_clist
\@@_mc_bdc_shipout:ee
{#1}
{
/MCID~\flag_height:n { @@/mcid }
\flag_raise:n { @@/mcid }~ #2
}
}
\cs_new_protected:Npn \@@_mc_bdc_mcid:n #1
{
\@@_mc_bdc_mcid:nn {#1} {}
Expand Down
16 changes: 2 additions & 14 deletions tagpdf.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -207,23 +207,11 @@
%</base>
% \end{macrocode}
%\section{Package options}
% There are only two documented options to switch for luatex between generic and luamode,
% TODO try to get rid of them.
% The option \texttt{disabledelayedshipout} is only temporary to be able to debug
% problem with the new shipout keyword if needed.
% \begin{macrocode}
%<*package>
\bool_new:N\g_@@_mode_lua_bool
\bool_new:N\g_@@_delayed_shipout_bool
\bool_lazy_and:nnT
{ \bool_if_exist_p:N \l__pdfmanagement_delayed_shipout_bool }
{ \l__pdfmanagement_delayed_shipout_bool }
{
\bool_gset_true:N\g_@@_delayed_shipout_bool
}
\DeclareOption {luamode} { \sys_if_engine_luatex:T { \bool_gset_true:N \g_@@_mode_lua_bool } }
\DeclareOption {genericmode}{ \bool_gset_false:N\g_@@_mode_lua_bool }
\DeclareOption {disabledelayedshipout}{ \bool_gset_false:N\g_@@_delayed_shipout_bool }
\DeclareOption {luamode} { \sys_if_engine_luatex:T { \bool_gset_true:N \g__tag_mode_lua_bool } }
\DeclareOption {genericmode}{ \bool_gset_false:N\g__tag_mode_lua_bool }
\ExecuteOptions{luamode}
\ProcessOptions
% \end{macrocode}
Expand Down

0 comments on commit 0a17694

Please sign in to comment.