From 2fc2609488764102ce43194e9288b7bd8e25f17f Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Sun, 16 May 2021 03:00:44 +0000
Subject: CTAN sync 202105160300

---
 macros/latex/contrib/tagpdf/tagpdf-mc.dtx | 73 ++++++++++++++++++++++++-------
 1 file changed, 56 insertions(+), 17 deletions(-)

(limited to 'macros/latex/contrib/tagpdf/tagpdf-mc.dtx')

diff --git a/macros/latex/contrib/tagpdf/tagpdf-mc.dtx b/macros/latex/contrib/tagpdf/tagpdf-mc.dtx
index a2cc7f349d..565e41b372 100644
--- a/macros/latex/contrib/tagpdf/tagpdf-mc.dtx
+++ b/macros/latex/contrib/tagpdf/tagpdf-mc.dtx
@@ -27,7 +27,7 @@
 %    \begin{macrocode}
 %<@@=tag>
 %<*shared>
-\ProvidesExplPackage {tagpdf-mc-code-shared} {2021/02/23} {0.80}
+\ProvidesExplPackage {tagpdf-mc-code-shared} {2021/05/14} {0.81}
   {part of tagpdf - code related to marking chunks -
    code shared by generic and luamode }
 % I use a latex counter for the absolute count, so that it is added to
@@ -56,6 +56,9 @@
 % value: the structure number the mc is in
 \_@@_prop_new:N \g_@@_mc_parenttree_prop
 
+% some commands (e.g. links) want to close a previous mc and reopen it after
+% there work. For this we create a stack:
+\seq_new:N \g_@@_mc_stack_seq
 % shared keys
 % the rest are in the splitted code
 \tl_new:N \l_@@_mc_artifact_type_tl
@@ -119,11 +122,58 @@
 % we need to define it for both modes to avoid a problem with the label
 \int_new:N \g_@@_MCID_tmp_bypage_int
 
+%    \end{macrocode}
+
+%  \begin{function}[added = 2021-04-22]
+%   {
+%     \tag_mc_end_push:, \tag_mc_begin_pop:n
+%   }
+%   \begin{syntax}
+%     \cs{tag_mc_end_push:} \\
+%     \cs{tag_mc_begin_pop:n}\Arg{key-values}
+%   \end{syntax}
+% If there is an open mc chunk,
+% \cs{tag_mc_end_push:} ends it and pushes its tag of the stack. If there is no
+% open chunk, it puts -1 on the stack (for debugging)
+% \cs{tag_mc_begin_pop:n} removes a value from the stack. If it is different from
+% -1 it opens a tag with it.
+% The reopened mc chunk looses info like the alttext for now.
+%
+%    \begin{macrocode}
+\cs_new_protected:Npn \tag_mc_end_push:
+ {
+   \@@_mc_if_in:TF
+     {
+       \seq_gpush:Nx \g_@@_mc_stack_seq { \tag_get:n {mc_tag} }
+       \@@_check_mc_pushed_popped:nn {pushed}{\tag_get:n {mc_tag}}
+       \tag_mc_end:
+     }
+     {
+       \@@_check_mc_pushed_popped:nn {pushed}{-1}
+       \seq_gpush:Nn \g_@@_mc_stack_seq{ -1  }
+     }
+ }
+\cs_new_protected:Npn \tag_mc_begin_pop:n #1
+ {
+   \seq_gpop:NNTF \g_@@_mc_stack_seq \l_@@_tmpa_tl
+     {
+       \tl_if_eq:NnTF \l_@@_tmpa_tl {-1}
+         {
+           \@@_check_mc_pushed_popped:nn {popped}{-1}
+         }
+         {
+           \@@_check_mc_pushed_popped:nn {popped}{\l_@@_tmpa_tl}
+           \tag_mc_begin:n {tag=\l_@@_tmpa_tl,#1}
+         }
+     }
+     { \@@_check_mc_pushed_popped:nn {popped}{empty~stack,~nothing} } %message?
+ }
+
 %</shared>
 %    \end{macrocode}
 %    \begin{macrocode}
 %<*generic>
-\ProvidesExplPackage {tagpdf-mc-code-generic} {2021/02/23} {0.80}
+\ProvidesExplPackage {tagpdf-mc-code-generic} {2021/05/14} {0.81}
  {part of tagpdf - code related to marking chunks - generic mode}
 
 % for the label system
@@ -148,8 +198,6 @@
 
 \prg_new_eq_conditional:NNn \tag_mc_if_in: \@@_mc_if_in: {p,T,F,TF}
 
-%deprecated
-\prg_new_eq_conditional:NNn \uftag_mc_if_in: \@@_mc_if_in: {p,T,F,TF}
 
 
 % this are the low level mc command.
@@ -381,8 +429,6 @@
     \group_end:
   }
 
-%deprecated
-\cs_set_eq:NN \uftag_mc_begin:n \tag_mc_begin:n
 
 \cs_new_protected:Nn \tag_mc_end:
   {
@@ -392,7 +438,7 @@
     \@@_mc_emc:
   }
 
-\cs_set_eq:NN \uftag_mc_end: \tag_mc_end:
+
 
 \cs_new_protected:Nn \tag_mc_use:n %#1: label name
   {
@@ -420,16 +466,13 @@
        }
   }
 
-%deprecated
-\cs_set_eq:NN \uftag_mc_use:n \tag_mc_use:n
 
 \cs_new:Nn \@@_get_data_mc_tag: { \g_@@_mc_key_tag_tl }
-
 %</generic>
 %    \end{macrocode}
 %    \begin{macrocode}
 %<*luamode>
-\ProvidesExplPackage {tagpdf-mc-code-lua} {2021/02/23} {0.80}
+\ProvidesExplPackage {tagpdf-mc-code-lua} {2021/05/14} {0.81}
   {tagpdf - mc code only for the luamode }
 
 % the two attibutes are defined in the driver file.
@@ -500,8 +543,6 @@
 
 \prg_new_eq_conditional:NNn \tag_mc_if_in: \@@_mc_if_in: {p,T,F,TF}
 
-%deprecated
-\prg_new_eq_conditional:NNn \uftag_mc_if_in: \@@_mc_if_in: {p,T,F,TF}
 
 % the keys
 \tl_new:N \l_@@_mc_key_tag_tl
@@ -746,8 +787,6 @@
     %\group_end:
   }
 
-%deprecated
-\cs_set_eq:NN \uftag_mc_begin:n \tag_mc_begin:n
 
 \cs_new_protected:Nn \tag_mc_end:
   {
@@ -758,7 +797,7 @@
     \tl_set:Nn  \l_@@_mc_key_tag_tl { }
   }
 
-\cs_set_eq:NN \uftag_mc_end: \tag_mc_end:
+
 
 \cs_new_protected:Nn \tag_mc_use:n %#1: label name
   {
@@ -772,7 +811,7 @@
       }
   }
 
-\cs_set_eq:NN \uftag_mc_use:n \tag_mc_use:n
+
 
 \cs_new:Nn \@@_get_data_mc_tag: { \l_@@_mc_key_tag_tl }
 %</luamode>
-- 
cgit v1.2.3

