texlive[61600] Master/texmf-dist: tagpdf (13jan22)

commits+karl at tug.org commits+karl at tug.org
Thu Jan 13 22:05:40 CET 2022


Revision: 61600
          http://tug.org/svn/texlive?view=revision&revision=61600
Author:   karl
Date:     2022-01-13 22:05:40 +0100 (Thu, 13 Jan 2022)
Log Message:
-----------
tagpdf (13jan22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/tagpdf/README.md
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext-luatex.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute-luatex.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem-luatex.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list-luatex.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma-luatex.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-memoir.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-spaceglyph-listings.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-spaceglyph-listings.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf-code.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf-code.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-generic.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-luacode.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-shared.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-user.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.ins
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdfdocu-patches.sty

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split-obsolete.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split-obsolete.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list-obsolete.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure-obsolete.tex
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-debug-generic.sty
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-debug-lua.sty
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-debug.sty

Removed Paths:
-------------
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure-luatex.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/example-input-file.tex

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/README.md	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/README.md	2022-01-13 21:05:40 UTC (rev 61600)
@@ -1,6 +1,6 @@
 #tagpdf — A package to create tagged pdf
-Packageversion: 0.92 
-Packagedate: 2021/08/27
+Packageversion: 0.93 
+Packagedate: 2022/01/13
 Author: Ulrike Fischer
 
 ## License
@@ -10,29 +10,35 @@
 
 ## Contents
 
-- Readme (this file)
-- tagpdf.sty (the sty)
-- tagpdf-roles-code.sty  (internal code)
-- tagpdf-mc-code-shared.sty  (internal code)
-- tagpdf-mc-code-generic.sty  (internal code)
-- tagpdf-mc-code-lua.sty  (internal code)
-- tagpdf-struct-code.sty  (internal code)
-- tagpdf-tree-code.sty   (internal code)
-- tagpdf-space-code.sty  (internal code)
-- tagpdf-attr-code.sty   (internal code)
-- tagpdf-checks-code.sty (internal code)
-- tagpdf-user.sty        (user commands) 
-- tagpdf-pdftex.def      (pdftex specific code)
-- tagpdf-luatex.def      (luatex specific code)
-- tagpdf.lua             (lua code for luatex)
-- tagpdf.tex, tagpdf.pdf, tagpdf.bib, tagpdfdocu-patches.sty,
-  link-figure-input.tex, pac3.png (the docu)
-- various examples       (part of the documentation)   
+- README.md (this file)
+- code files:
+     - tagpdf.ins
+     - tagpdf.dtx 
+     - tagpdf-roles.dtx 
+     - tagpdf-mc-shared.dtx
+     - tagpdf-mc-generic.dtx
+     - tagpdf-mc-lua.dtx
+     - tagpdf-struct.dtx 
+     - tagpdf-tree.dtx
+     - tagpdf-space.dtx
+     - tagpdf-checks.dtx
+     - tagpdf-user.dtx        
+- documentation:
+     - tagpdf.pdf 
+     - various examples       (part of the documentation)   
+- source files for the documentation:
+     - tagpdf.tex
+     - tagpdf.bib
+     - tagpdfdocu-patches.sty,
+     - link-figure-input.tex
+     - pac3.png, global-ex.png 
 
 ## Installation
 
-Put the styles (with the exception of the tagpdfdocu-patches.sty), 
-the .def and the lua-files where it can be found.
+At best use the package manager of your texsystem to install tagpdf.
+For a manual installation run the .ins-file with latex and put the 
+created .sty, .def and .lua-files 
+where they can be found.
 
 
 ## Issues, comments, etc

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.tex	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.tex	2022-01-13 21:05:40 UTC (rev 61600)
@@ -1,19 +1,19 @@
 % !Mode:: "TeX:DE:UTF-8:Main"
-\RequirePackage{pdfmanagement-testphase}
-\DeclareDocumentMetadata{
-   pdfversion=2.0
-  ,lang=de-DE
-  ,uncompress}
+\IfFormatAtLeastTF{2022-06-01}{}
+  {\RequirePackage{pdfmanagement-testphase}}
+\DocumentMetadata
+ {
+   uncompress,
+   pdfversion=2.0,
+   lang=de-DE,
+   testphase=tagpdf %load and activate tagpdf
+ }
 \documentclass{article}
-\usepackage{tagpdf}
 
 \usepackage{iftex}
-\tagpdfsetup{tabsorder=structure,
-             activate,
-             interwordspace
-             }
+\tagpdfsetup{tabsorder=structure}
 
-\iftutex 
+\ifluatex
   \usepackage{fontspec}
   \usepackage{unicode-math}
   \usepackage{luacode}
@@ -20,7 +20,7 @@
   \newfontface\zerowidthfont{freeserif}
 \else
   \usepackage[T1]{fontenc}
-\fi  
+\fi
 
 \usepackage{graphicx}
 \begin{filecontents}{example-input-file.tex}
@@ -29,6 +29,7 @@
 
 \begin{document}
 \pagestyle{empty}
+\tagpdfparaOff %we don't want to nest paragraphs ...
 
 \ExplSyntaxOn
 

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext-luatex.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext.tex	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext.tex	2022-01-13 21:05:40 UTC (rev 61600)
@@ -8,7 +8,7 @@
 \usepackage{tagpdf}
 \tagpdfsetup{tabsorder=structure,
              activate}
-\usepackage{iftex}             
+\usepackage{iftex}
 \iftutex
   \usepackage{fontspec}
   \usepackage{unicode-math}
@@ -26,6 +26,7 @@
 % with pdflatex there is a encoding problem with the math
 
 \begin{document}
+\tagpdfparaOff
 \pagestyle{empty}
 
 
@@ -155,9 +156,9 @@
  actualtext=Ente,
  alttext=Dies ist eine Ente}
  %% a char is needed so that actualtext works,
- \tagpdfifluatexTF
+ \ifluatex
   {{\zerowidthfont^^^^200c}}%
-  {\makebox[0pt][l]{.}}%
+ \else {\makebox[0pt][l]{.}} \fi%
  %it seems not to be needed for alttext and voice software ....
  \includegraphics[width=1cm]{example-image-duck}
 \tagmcend

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute-luatex.pdf
===================================================================
(Binary files differ)

Deleted: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem-luatex.pdf
===================================================================
(Binary files differ)

Added: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split-obsolete.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split-obsolete.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split-obsolete.pdf	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split-obsolete.pdf	2022-01-13 21:05:40 UTC (rev 61600)

Property changes on: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split-obsolete.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split-obsolete.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split-obsolete.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split-obsolete.tex	2022-01-13 21:05:40 UTC (rev 61600)
@@ -0,0 +1,67 @@
+% !Mode:: "TeX:DE:UTF-8:Main"
+
+% !!!!!!!!!!!!!!!!!
+% Obsolete example!
+% !!!!!!!!!!!!!!!!
+% This test files shows how to add a manual page split.
+% It *only* handles the mc-step in the page stream.
+% Structure commands and all the related management are not
+% involved. So it also only uses activate-mc.
+
+% It is obsolete as the current tagpdf version now handles the
+% page split automatically. To keep the example working this is disabled
+% below with \csname __tag_mc_disable_marks:\endcsname
+
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{pdfversion=1.7,uncompress}
+\documentclass{book}
+\usepackage[english,ngerman]{babel}
+\usepackage{tagpdf}
+\usepackage{amsmath}
+\usepackage{graphicx}
+\usepackage{iftex}
+\iftutex
+   \usepackage{fontspec}
+  \usepackage{luacode}
+\else
+  \usepackage[T1]{fontenc}
+\fi
+
+\tagpdfsetup{tabsorder=structure,
+             activate-mc,
+            }
+\newsavebox\mybox
+
+\textheight3cm
+\usepackage{fancyhdr}
+\pagestyle{fancy}
+\fancyhf{}
+
+\begin{document}
+%disable the automatic page break handler:
+\csname __tag_mc_disable_marks:\endcsname
+
+\tagmcbegin{tag=P}
+Cras egestas ipsum a nisl. Vivamus varius dolor
+ut dolor. Fusce vel enim. Pellentesque accumsan ligula et eros. Cras
+id lacus non tortor facilisis facilisis. Etiam nisl elit, cursus
+sed, fringilla in, congue nec, urna. Cum sociis natoque penatibus et
+magnis dis parturient montes, nascetur ridiculus mus. Integer at
+turpis. Cum sociis natoque penatibus et magnis dis parturient
+montes, nascetur ridiculus mus. Duis fringilla, ligula sed porta
+fringilla, ligula wisi commodo felis, ut adipiscing felis dui in
+enim. Suspendisse malesuada ultrices ante.%
+\vadjust{\tagmcend\pagebreak\tagmcbegin{tag=P}}
+Pellentesque scelerisque
+augue sit amet urna. Nulla volutpat aliquet tortor. Cras aliquam,
+tellus at aliquet pellentesque, justo sapien commodo leo, id rhoncus
+sapien quam at erat. Nulla commodo, wisi eget sollicitudin pretium,
+orci orci aliquam orci, ut cursus turpis justo et lacus. Nulla vel
+tortor. Quisque erat elit, viverra sit amet, sagittis eget, porta
+sit amet, lacus.\tagmcend
+
+\end{document}
+
+Comment:
+
+manual tagging at a pagebreak 
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split-obsolete.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Deleted: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.pdf
===================================================================
(Binary files differ)

Deleted: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.tex	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.tex	2022-01-13 21:05:40 UTC (rev 61600)
@@ -1,59 +0,0 @@
-% !Mode:: "TeX:DE:UTF-8:Main"
-
-% !!!!!!!!!!!!!!!!!
-% This test files shows how to add a manual page split.
-% It *only* handles the mc-step in the page stream.
-% Structure commands and all the related management are not
-% involved. So it also only uses activate-mc.
-
-\RequirePackage{pdfmanagement-testphase}
-\DeclareDocumentMetadata{pdfversion=1.7,uncompress}
-\documentclass{book}
-\usepackage[english,ngerman]{babel}
-\usepackage{tagpdf}
-\usepackage{amsmath}
-\usepackage{graphicx}
-\usepackage{iftex}
-\iftutex
-   \usepackage{fontspec}
-  \usepackage{luacode}
-\else 
-  \usepackage[T1]{fontenc}
-\fi
-
-\tagpdfsetup{tabsorder=structure,
-             activate-mc,
-            }
-\newsavebox\mybox
-
-\textheight3cm
-\usepackage{fancyhdr}
-\pagestyle{fancy}
-\fancyhf{}
-
-\cfoot{\tagmcbegin{artifact=pagination}\thepage\tagmcend}
-\begin{document}
-\tagmcbegin{tag=P}
-Cras egestas ipsum a nisl. Vivamus varius dolor
-ut dolor. Fusce vel enim. Pellentesque accumsan ligula et eros. Cras
-id lacus non tortor facilisis facilisis. Etiam nisl elit, cursus
-sed, fringilla in, congue nec, urna. Cum sociis natoque penatibus et
-magnis dis parturient montes, nascetur ridiculus mus. Integer at
-turpis. Cum sociis natoque penatibus et magnis dis parturient
-montes, nascetur ridiculus mus. Duis fringilla, ligula sed porta
-fringilla, ligula wisi commodo felis, ut adipiscing felis dui in
-enim. Suspendisse malesuada ultrices ante.%
-\vadjust{\tagmcend\pagebreak\tagmcbegin{tag=P}}
-Pellentesque scelerisque
-augue sit amet urna. Nulla volutpat aliquet tortor. Cras aliquam,
-tellus at aliquet pellentesque, justo sapien commodo leo, id rhoncus
-sapien quam at erat. Nulla commodo, wisi eget sollicitudin pretium,
-orci orci aliquam orci, ut cursus turpis justo et lacus. Nulla vel
-tortor. Quisque erat elit, viverra sit amet, sagittis eget, porta
-sit amet, lacus.\tagmcend
-
-\end{document}
-
-Comment:
-
-manual tagging at a pagebreak 
\ No newline at end of file

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list-luatex.pdf
===================================================================
(Binary files differ)

Added: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list-obsolete.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list-obsolete.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list-obsolete.tex	2022-01-13 21:05:40 UTC (rev 61600)
@@ -0,0 +1,100 @@
+% !Mode:: "TeX:DE:UTF-8:Main"
+
+
+%!! Obsolete example as it uses manual tagging of paragraph. 
+% Check the newer version ex-patch-list for a simpler version!
+
+%This example shows how one can patch lists command
+%it is based on enumitem
+
+%It uses a command to end \item (\meti). It is perhaps possible to hide this command
+% inside \item/end{list}, but with nested list it is not so easy.
+
+% not really up-to-date, with paratagging one could simplify things.
+
+% Pay attention to casing. Li/LI, Lbody/Lbody are different.
+%no page break involved. So the example works in lua and generic mode
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{pdfversion=1.7,uncompress}
+
+\documentclass{scrbook}
+\usepackage[english]{babel}
+\usepackage{tagpdf}
+
+\usepackage{iftex}
+\iftutex
+  \usepackage{fontspec}
+  \usepackage{luacode}
+\else
+  \usepackage[T1]{fontenc}
+\fi
+
+
+
+\tagpdfsetup{tabsorder=structure,
+             activate,
+             }
+
+\usepackage{lipsum}%\textheight3cm
+
+\usepackage{enumitem,xpatch}
+
+\makeatletter
+
+\newcommand\tag at enit@format at preset[1]{%
+  \tagstructbegin{tag=LI}%
+  \tagstructbegin{tag=Lbl}%
+  \tagmcbegin{tag=Lbl}%
+  #1%
+  \tagmcend
+  \tagstructend %end Lbl
+  \tagstructbegin{tag=LBody}}
+
+\newcommand\meti{% end of \item
+ \tagstructend %end of LBody
+ \tagstructend %end of LI
+}
+
+\xpatchcmd\enit at preset{\@firstofone}{\tag at enit@format at preset}{}{\fail}
+
+\setlist{
+    before*=\tagstructbegin{tag=L},
+    after*={\tagstructend}}
+
+% keys that overwrite \enit at format must be patched, eg like the follow
+% the font key should be patched in a similar way
+\enitkv at key{enumitem}{format}{%
+  \def\enit at format{%
+   \tagstructbegin{tag=LI}%
+   \tagstructbegin{tag=Lbl}%
+   \tagmcbegin{tag=Lbl}%
+   #1\tagmcend}}
+\makeatother
+% marking of the text inside the list can not be handled automatically -- one doesn't know the type
+% we use simple P here
+\newcommand\TAGP{\tagstructbegin{tag=P}\tagmcbegin{tag=P}}
+\newcommand\PGAT{\tagmcend\tagstructend}
+
+\begin{document}
+%I don't want to handle pagestyles, so set everything to empty:
+\pagestyle{empty}\renewcommand\chapterpagestyle{empty}
+
+
+
+\begin{itemize}
+\item \TAGP Ducks say quack\PGAT\meti
+\item \TAGP Marmots say something Parmotlike\PGAT\meti
+\end{itemize}
+
+\begin{enumerate}
+\item \TAGP The highest pass is the Col de l'Iseran.\PGAT\meti
+\item \TAGP The second highest pass is the Passo dello Stelvio.\PGAT\meti
+\end{enumerate}
+
+\begin{description}
+\item[ducks] \TAGP yellow\PGAT\meti
+\item[marmots] \TAGP brown\PGAT\meti
+\end{description}
+
+
+\end{document} 
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list-obsolete.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list.tex	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list.tex	2022-01-13 21:05:40 UTC (rev 61600)
@@ -1,24 +1,25 @@
 % !Mode:: "TeX:DE:UTF-8:Main"
 
-%This example shows how one can patch lists command
-%it is based on enumitem
+% This example shows how one can patch lists command
+% it is based on enumitem
 
-%It uses a command to end \item (\meti). It is perhaps possible to hide this command
-% inside \item/end{list}, but with nested list it is not so easy.
+% Pay attention to casing. Li/LI, Lbody/Lbody are different.
 
-% not really up-to-date, with paratagging one could simplify things.
+% It doesn't test nesting!
 
-% Pay attention to casing. Li/LI, Lbody/Lbody are different.
-%no page break involved. So the example works in lua and generic mode
-\RequirePackage{pdfmanagement-testphase}
-\DeclareDocumentMetadata{pdfversion=1.7,uncompress}
+% We are using \DocumentMetadata
+% This requires a new pdfmanagement and/or latex-dev! 
+% Older systems should use \DeclareDocumentMetadata
+\IfFormatAtLeastTF{2022-06-01}{}
+  {\RequirePackage{pdfmanagement-testphase}}
+\DocumentMetadata{pdfversion=1.7,uncompress,testphase=tagpdf}
 
+
 \documentclass{scrbook}
 \usepackage[english]{babel}
-\usepackage{tagpdf}
 
 \usepackage{iftex}
-\iftutex
+\ifluatex
   \usepackage{fontspec}
   \usepackage{luacode}
 \else
@@ -27,50 +28,54 @@
 
 
 
-\tagpdfsetup{tabsorder=structure,
-             activate,
-             }
+\tagpdfsetup
+  {
+    tabsorder=structure,
+  }
 
 \usepackage{lipsum}%\textheight3cm
 
 \usepackage{enumitem,xpatch}
 
+% At first we add to the begin/end hooks the structure commands.
+% To avoid problems with nested paragraphs we force a new paragraph for now. 
+% Real code should avoid that!
+\AddToHook{env/itemize/begin}{\par\tagstructbegin{tag=L}}%\par is needed to close the paragraph before.
+\AddToHook{env/itemize/end}{\par\tagstructend\tagstructend\tagstructend}%LBody,LI,L
+\AddToHook{env/enumerate/begin}{\par\tagstructbegin{tag=L}}
+\AddToHook{env/enumerate/end}{\par\tagstructend\tagstructend\tagstructend}%LBody,LI,L
+\AddToHook{env/description/begin}{\par\tagstructbegin{tag=L}}
+\AddToHook{env/description/end}{\par\tagstructend\tagstructend\tagstructend}%LBody,LI,L
+
 \makeatletter
-
+\ExplSyntaxOn
+%We detect is this is the first or a follow up item where we have to end a structure first:  
 \newcommand\tag at enit@format at preset[1]{%
-  \tagstructbegin{tag=LI}%
-  \tagstructbegin{tag=Lbl}%
-  \tagmcbegin{tag=Lbl}%
-  #1%
+ \str_if_eq:eeTF { \prop_item:cn { g__tag_struct_\g__tag_struct_stack_current_tl _prop }{S} }{/L}
+  {
+   %\typeout{BEGIN~OF~LIST}
+  }
+  {%\typeout{NEXT ITEM}
+   \tagstructend\tagstructend} % for the LBody/LI
+  \tagstructbegin{tag=LI}
+  \tagstructbegin{tag=Lbl}
+  \tagmcbegin{tag=Lbl}
+    #1
   \tagmcend
-  \tagstructend %end Lbl
-  \tagstructbegin{tag=LBody}}
+  \tagstructend
+  \tagstructbegin{tag=LBody}
+  }
+  
+\ExplSyntaxOff
 
-\newcommand\meti{% end of \item
- \tagstructend %end of LBody
- \tagstructend %end of LI
-}
-
 \xpatchcmd\enit at preset{\@firstofone}{\tag at enit@format at preset}{}{\fail}
+%close mc from paratagging and reopen ...
+\xpatchcmd\@item{\box\@labels}{\tagmcend \box\@labels \tagmcbegin{tag=P}}{}{\fail}
 
-\setlist{
-    before*=\tagstructbegin{tag=L},
-    after*={\tagstructend}}
-
-% keys that overwrite \enit at format must be patched, eg like the follow
-% the font key should be patched in a similar way
-\enitkv at key{enumitem}{format}{%
-  \def\enit at format{%
-   \tagstructbegin{tag=LI}%
-   \tagstructbegin{tag=Lbl}%
-   \tagmcbegin{tag=Lbl}%
-   #1\tagmcend}}
 \makeatother
-% marking of the text inside the list can not be handled automatically -- one doesn't know the type
-% we use simple P here
-\newcommand\TAGP{\tagstructbegin{tag=P}\tagmcbegin{tag=P}}
-\newcommand\PGAT{\tagmcend\tagstructend}
 
+
+
 \begin{document}
 %I don't want to handle pagestyles, so set everything to empty:
 \pagestyle{empty}\renewcommand\chapterpagestyle{empty}
@@ -78,18 +83,18 @@
 
 
 \begin{itemize}
-\item \TAGP Ducks say quack\PGAT\meti
-\item \TAGP Marmots say something Parmotlike\PGAT\meti
+\item Ducks say quack
+\item Marmots say something Parmotlike
 \end{itemize}
 
 \begin{enumerate}
-\item \TAGP The highest pass is the Col de l'Iseran.\PGAT\meti
-\item \TAGP The second highest pass is the Passo dello Stelvio.\PGAT\meti
+\item The highest pass is the Col de l'Iseran.
+\item The second highest pass is the Passo dello Stelvio.
 \end{enumerate}
 
 \begin{description}
-\item[ducks] \TAGP yellow\PGAT\meti
-\item[marmots] \TAGP brown\PGAT\meti
+\item[ducks] yellow
+\item[marmots] brown
 \end{description}
 
 

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma-luatex.pdf
===================================================================
(Binary files differ)

Deleted: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-memoir.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-spaceglyph-listings.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-spaceglyph-listings.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-spaceglyph-listings.tex	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-spaceglyph-listings.tex	2022-01-13 21:05:40 UTC (rev 61600)
@@ -1,10 +1,11 @@
 % !Mode:: "TeX:DE:UTF-8:Main"
-\RequirePackage{pdfmanagement-testphase}
-\DeclareDocumentMetadata{uncompress,}
+\IfFormatAtLeastTF{2022-06-01}{}
+  {\RequirePackage{pdfmanagement-testphase}}
+\DocumentMetadata{uncompress,testphase=tagpdf}
 \documentclass{article}
 \usepackage{amsmath}
 \usepackage[ngerman]{babel}
-\usepackage{tagpdf,listings}
+\usepackage{listings}
 \makeatletter
 %\def\lst at outputspace{\pdffakespace\ } %not so good
 % this here works fine with luatex, if the font has a space glyph:
@@ -12,11 +13,11 @@
 \def\lst at visiblespace{\lst at ttfamily{\char32}{\char32}}
 % with pdftex this could work
 %\def\lst at visiblespace{\lst at ttfamily{\pdffakespace\ }{\pdffakespace\ }}
-\tagpdfsetup{activate,interwordspace=on,show-spaces,log=v}
+\tagpdfsetup{show-spaces,log=v}
 \begin{document}\pagestyle{empty}
-\tagmcbegin{tag=P}
+
 \begin{lstlisting}[showspaces]
 aaa aaa    xxxx
 \end{lstlisting}
-\tagmcend
+
 \end{document}  
\ No newline at end of file

Deleted: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure-luatex.pdf
===================================================================
(Binary files differ)

Added: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure-obsolete.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure-obsolete.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure-obsolete.tex	2022-01-13 21:05:40 UTC (rev 61600)
@@ -0,0 +1,79 @@
+% !Mode:: "TeX:DE:UTF-8:Main"
+
+%!!!!!!!
+% obsolete in part (paratagging will interfere)
+% don't expect a correct output!
+%
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{pdfversion=1.7,uncompress}
+
+\documentclass{book}
+\usepackage[english,ngerman]{babel}
+\usepackage{tagpdf}
+\usepackage{amsmath}
+\usepackage{graphicx}
+
+\usepackage{iftex}
+\iftutex
+  \usepackage{fontspec}
+  \usepackage{luacode}
+\else
+  \usepackage[T1]{fontenc}
+\fi
+
+
+\tagpdfsetup{tabsorder=structure,
+             activate
+             }
+\newsavebox\mybox
+
+% this works only as we have only one page. Footer/header must be handle in the output routine.
+\usepackage{fancyhdr}
+\pagestyle{fancy}
+\fancyhf{}
+
+\begin{document}
+
+ \tagstructbegin{tag=Sect}
+  \tagstructbegin{tag=H}
+   \tagmcbegin{tag=H}
+    \section{Section}
+   \tagmcend
+  \tagstructend
+  \tagstructbegin{tag=P}
+   \tagmcbegin{tag=P,raw=/Alt (x)}
+    a paragraph\par x
+   \tagmcend
+  \tagstructend
+
+ \tagstructbegin{tag=L} %List
+  \tagstructbegin{tag=LI}
+   \tagstructbegin{tag=Lbl}
+    \tagmcbegin{tag=Lbl}
+    1.
+    \tagmcend
+   \tagstructend
+   \tagstructbegin{tag=LBody}
+    \tagmcbegin{tag=P}
+    List item body
+    \tagmcend
+   \tagstructend %lbody
+  \tagstructend %Li
+
+  \tagstructbegin{tag=LI}
+   \tagstructbegin{tag=Lbl}
+    \tagmcbegin{tag=Lbl}
+    2.
+    \tagmcend
+   \tagstructend
+   \tagstructbegin{tag=LBody}
+    \tagmcbegin{tag=P}
+    another List item body
+    \tagmcend
+   \tagstructend %lbody
+  \tagstructend %Li
+  \tagstructend %L
+
+  \tagstructend  %Sect
+
+\end{document} 
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure-obsolete.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Deleted: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure.tex	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure.tex	2022-01-13 21:05:40 UTC (rev 61600)
@@ -1,75 +0,0 @@
-% !Mode:: "TeX:DE:UTF-8:Main"
-\RequirePackage{pdfmanagement-testphase}
-\DeclareDocumentMetadata{pdfversion=1.7,uncompress}
-
-\documentclass{book}
-\usepackage[english,ngerman]{babel}
-\usepackage{tagpdf}
-\usepackage{amsmath}
-\usepackage{graphicx}
-
-\usepackage{iftex}
-\iftutex
-  \usepackage{fontspec}
-  \usepackage{luacode}
-\else
-  \usepackage[T1]{fontenc}
-\fi
-
-
-\tagpdfsetup{tabsorder=structure,
-             activate
-             }
-\newsavebox\mybox
-
-% this works only as we have only one page. Footer/header must be handle in the output routine.
-\usepackage{fancyhdr}
-\pagestyle{fancy}
-\fancyhf{}
-
-\cfoot{\tagmcbegin{artifact=pagination}\thepage\tagmcend}
-\begin{document}
-
- \tagstructbegin{tag=Sect}
-  \tagstructbegin{tag=H}
-   \tagmcbegin{tag=H}
-    \section{Section}
-   \tagmcend
-  \tagstructend
-  \tagstructbegin{tag=P}
-   \tagmcbegin{tag=P,raw=/Alt (x)}
-    a paragraph\par x
-   \tagmcend
-  \tagstructend
-
- \tagstructbegin{tag=L} %List
-  \tagstructbegin{tag=LI}
-   \tagstructbegin{tag=Lbl}
-    \tagmcbegin{tag=Lbl}
-    1.
-    \tagmcend
-   \tagstructend
-   \tagstructbegin{tag=LBody}
-    \tagmcbegin{tag=P}
-    List item body
-    \tagmcend
-   \tagstructend %lbody
-  \tagstructend %Li
-
-  \tagstructbegin{tag=LI}
-   \tagstructbegin{tag=Lbl}
-    \tagmcbegin{tag=Lbl}
-    2.
-    \tagmcend
-   \tagstructend
-   \tagstructbegin{tag=LBody}
-    \tagmcbegin{tag=P}
-    another List item body
-    \tagmcend
-   \tagstructend %lbody
-  \tagstructend %Li
-  \tagstructend %L
-
-  \tagstructend  %Sect
-
-\end{document} 
\ No newline at end of file

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.tex	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.tex	2022-01-13 21:05:40 UTC (rev 61600)
@@ -2,15 +2,22 @@
 
 %this is more or less minimal template that can be used as starting point
 %it doesn't set everything that would be needed!
-\RequirePackage{pdfmanagement-testphase}
-\DeclareDocumentMetadata
- {
-  uncompress,
-  pdfversion=2.0
- }
+
+% \DocumentMetadata requires a new pdfmanagement-testphase version! Older versions
+% should use \DeclareDocumentMetadata
+
+% with a new LaTeX it will not longer be needed to load pdfmanagment-testphase!
+\IfFormatAtLeastTF{2022-06-01}{}
+  {\RequirePackage{pdfmanagement-testphase}}
+\DocumentMetadata
+ {uncompress,
+  pdfversion=2.0,
+  testphase=tagpdf %load and activate tagpdf
+  }
+
 \documentclass{scrartcl}
 \usepackage[english]{babel}
-\usepackage{tagpdf}
+
 \usepackage{iftex}
 \iftutex
   \usepackage{fontspec}
@@ -21,9 +28,6 @@
 \tagpdfsetup
     {
       tabsorder=structure,
-      activate, %adds Document structure
-      paratagging, %activates tagging of paragraphs.
-      interwordspace %actives interword spaces (lualatex, pdflatex)
     }
 \begin{document}
 \pagestyle{empty} %

Deleted: trunk/Master/texmf-dist/doc/latex/tagpdf/example-input-file.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/example-input-file.tex	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/example-input-file.tex	2022-01-13 21:05:40 UTC (rev 61600)
@@ -1,5 +0,0 @@
-%% LaTeX2e file `example-input-file.tex'
-%% generated by the `filecontents' environment
-%% from source `ex-AF-file' on 2021/02/23.
-%%
-Additional info!

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf-code.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf-code.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf-code.tex	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf-code.tex	2022-01-13 21:05:40 UTC (rev 61600)
@@ -34,8 +34,15 @@
 % version data.
 \usepackage{longtable}
 \usepackage{tagpdf}
-
-
+\makeatletter
+%\def\@setupverbvisiblespace{}
+%\def\verb{\relax\ifmmode\hbox\else\leavevmode\null\fi
+%  \bgroup
+%    \verb at eol@error \let\do\@makeother \dospecials
+%    \verbatim at font\@noligs
+%    \language\l at nohyphenation
+%    \@ifstar\@verb\@verb}
+\makeatother
 \begin{document}
 
 \GetFileInfo{tagpdf.sty}

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex	2022-01-13 21:05:40 UTC (rev 61600)
@@ -1,12 +1,11 @@
 % !Mode:: "TeX:DE:UTF-8:Main"
 %\PassOptionsToPackage{check-declarations,enable-debug}{expl3}
-\RequirePackage{pdfmanagement-testphase}
-\DeclareDocumentMetadata{pdfversion=2.0,lang=en-UK}
+%\RequirePackage{pdfmanagement-testphase}
+\DocumentMetadata{pdfversion=2.0,lang=en-UK,testphase=phase-II}
 
-
 \makeatletter
-\def\UlrikeFischer at package@version{0.92}
-\def\UlrikeFischer at package@date{2021-08-27}
+\def\UlrikeFischer at package@version{0.93}
+\def\UlrikeFischer at package@date{2022-01-13}
 \makeatother
 
 \documentclass[DIV=12,parskip=half-,bibliography=totoc]{scrartcl}
@@ -16,6 +15,10 @@
 \usepackage{unicode-math}
 \setmainfont{Heuristica}
 \usepackage{microtype}
+\makeatletter
+% see https://github.com/schlcht/microtype/issues/8
+\patchcmd{\MT at get@prot}{\noindent}{\RawNoindent}{}{\fail}
+\makeatother
 
 \usepackage{scrlayer-scrpage}
 
@@ -46,12 +49,9 @@
         commentstyle=\color{green!50!black}\bfseries}
 
 
-\usepackage{tagpdf}
+
 \tagpdfsetup{
- activate-all,
- uncompress,
  tabsorder=structure,
- interwordspace=true,
  %log=v
  %show-spaces
  }
@@ -150,6 +150,21 @@
 
 
 \tableofcontents
+\section{Preface to version 0.93}
+The main change in the package itself in this version is the support for structure destinations.
+This is a new type of destinations in \PDF~2.0.
+For pdftex and luatex this requires new binaries. They will be included
+in texlive 2022, miktex already has the new pdftex, the new luatex will probably follow soon.
+
+Beside this mostly some clean up and bug fixes has been done.
+
+A more important step will be done in \LaTeX{} itself in the next dev-release: The command \cs{DocumentMetadata} will be
+added to the format and will take over the role of \cs{DeclareDocumentMetadata} from \pkg{pdfmanagement-testphase} and additionally
+will also load the pdf management code. This will simplify the documents as it will no longer be needed to load
+a package.
+
+
+
 \section{Preface to version 0.92}
 
 In this version support for page breaks in pdftex has been added. As described in section~\ref{sec:splitpara},
@@ -318,7 +333,7 @@
 \item The keys |lang|, |ref| and |E| have been added for structures.
 
 \item The new hooks of LaTeX are used to tagged many paragraphs automatically. The small red numbers around paragraphs in the documentation show them in action. The main problem here is not to tag a paragraph, but to avoid to tag too many: paragraphs pop up in many places.
-\end{itemize}    
+\end{itemize}
 
 \subsection{Changes in version 0.81}
 
@@ -390,6 +405,25 @@
 
 \end{itemize}
 
+\subsection{Changes in version 0.93}
+
+\begin{itemize}
+\item Support for associated files in the root element (key \texttt{root-AF})
+has been added. This allow e.g. to add a css-file which is be used if the \PDF\ is converted to
+html.
+
+\item First steps have been done to adapt the package to planed changes in \LaTeX{}: The command \cs{DocumentMetadata} will be
+added to the format and will take over the role of \cs{DeclareDocumentMetadata} from \pkg{pdfmanagement-testphase}.
+
+\item The package has now support for \enquote{structure destinations}.
+This is a new type of destinations in \PDF~2.0.
+For pdftex and luatex this requires new binaries. They will be included
+in texlive 2022, miktex already has the new pdftex, the new luatex will probably follow soon.
+
+\item The commands \cs{tagpdfifluatexT}, \cs{tagpdfifluatexTF} has been removed \cs{tagpdfifpdftexT},
+
+\end{itemize}
+
 \subsection{Proof of concept: the tagging of the documentation itself}
 
 Starting with version 0.6 the documentation itself has been tagged. The tagging wasn't (and isn't) in no way perfect. The validator from Adobe didn't complain, but PAX3 wanted alternative text for all links (no idea why) and so I put everywhere simple text like \enquote{link} and \enquote{ref}. The links to footnotes gave warnings, so I disabled them. I used types from the \PDF{} version 1.7, mostly as I have no idea what should be used for code in 2.0. Margin notes were simply wrong \ldots
@@ -424,15 +458,27 @@
  }
 \documentclass{article}
 \begin{document}
-some text 
+some text
 \end{document}
 \end{lstlisting}
 
+With  \LaTeX{} 2022-06-01 (or a current \LaTeX-dev) the call will be simpler
 
+\begin{lstlisting}
+\DocumentMetadata
+ {
+  testphase = tagpdf, % load + activate
+ }
+\documentclass{article}
+\begin{document}
+some text
+\end{document}
+\end{lstlisting}
+
 \minisec{Activation needed!}
 
 
-When the package is loaded it will -- apart from loading more packages and defining a lot of things -- not do much. You will have to activate it with \verb+\tagpdfsetup+ or as shown above in \verb+\DeclareDocumentMetadata+. 
+When the package is loaded it will -- apart from loading more packages and defining a lot of things -- not do much. You will have to activate it with \verb+\tagpdfsetup+ or as shown above in \verb+\DeclareDocumentMetadata+/\verb+\DocumentMetadata+.
 
 Most commands do nothing if tagging is not activated, but in case a test is needed a command (with the usual p,T,F variants) is provided:
 
@@ -478,6 +524,9 @@
  Boolean, initially false. Activates the code related to marked content.
 \item[\PrintKeyName{activate-struct}]
  Boolean, initially false. Activates the code related to structures. Should be used only if \PrintKeyName{activate-mc} has been used too.
+\item[\PrintKeyName{no-struct-dest}]
+ Starting with version 0.93 \pkg{tagpdf} will create automatically structure destinations (see section~\ref{sec:struct-dest} if \pkg{hyperref} is used, if
+ the engine supports it and if the pdf version is 2.0. With this key this can be suppressed.
 \item[\PrintKeyName{activate-tree}]
 Boolean, initially false. Activates the code related to trees. Should be used only if the two other keys has been used too.
 \item[\PrintKeyName{add-new-tag}]
@@ -794,7 +843,7 @@
   This key sets a label by which you can call the marked content later in another structure (if it has been stashed with the previous key). Internally the label name will start with \texttt{tagpdf-}.
 
   \item[\PrintKeyName{alttext}]
-   This key inserts an \texttt{/Alt} value in the property dictionary of the BDC operator. See section~\ref{sec:alttext}. The value is handled as verbatim string, commands are not expanded but the value will be expanded first once (so works like the key \texttt{alttext-o} in previous versions which has been removed). 
+   This key inserts an \texttt{/Alt} value in the property dictionary of the BDC operator. See section~\ref{sec:alttext}. The value is handled as verbatim string, commands are not expanded but the value will be expanded first once (so works like the key \texttt{alttext-o} in previous versions which has been removed).
   That means that you can do something like in the following listing
   and it will insert \verb+\frac{a}{b}+  (hex encoded) in the \PDF{}.
 
@@ -809,14 +858,17 @@
   \item[\PrintKeyName{actualtext}]
   This key inserts an \texttt{/ActualText} value in the property dictionary of the BDC operator. See section~\ref{sec:alttext}. The value is handled as verbatim string, commands are not expanded but the value will be expanded first once (so works like the key \texttt{actualtext-o} in previous versions which has been removed).
 
-   That means that you can do something like in the following listing and and it will insert \verb+X+ (hex encoded)  in the \PDF{}.
+  That means that you can do something like in the following listing and and it will insert \verb+X+ (hex encoded)  in the \PDF{}.
 
 
   \begin{lstlisting}
    \newcommand\myactualtext{X}
-   \tagmcbegin{tag=P,actualtext=\myactualtext}
+   \tagmcbegin{tag=Span,actualtext=\myactualtext}
   \end{lstlisting}
 
+  According to the PDF reference, \texttt{/ActualText} should only be used on marked content sequence of type Span. This is not enforced by the code currently.
+
+
   \item[\PrintKeyName{raw}]
   This key allows you to add more entries to the properties dictionary. The value must be correct, low-level \PDF{}. E.g. \verb+raw=/Alt (Hello)+ will insert an alternative Text.
 \end{description}
@@ -1005,8 +1057,12 @@
 providing support for header and footers.
 
 For now tagpdf added some first support for automatically tagging:
-Starting with version 0.92 header and footer are automatically marked up as (simple) artifacts.
+Starting with version 0.92 header and footer are by default automatically marked up as (simple) artifacts.
 
+With the key \PrintKeyName{exclude-header-footer} the behaviour can be changed: The value \texttt{false} disables the
+automatic tagging, the value \texttt{pagination} add additionally an \texttt{/Artifact} structure with the attribute \texttt{/Pagination}.
+
+
 If some additional markup (or even a structure) is wanted, something like this should be used (here with
 the syntax of the \pkg{fancyhdr} package) to close the open mc-chunk and restart if after the content:
 
@@ -1299,8 +1355,10 @@
    For example:
 
    \begin{lstlisting}
+   \group_begin:
    \pdfdict_put:nnn {l_pdffile/Filespec} {AFRelationship}{/Supplement}
    \pdffile_embed_file:nnn{example-input-file.tex}{}{tag/AFtest}
+   \group_end:
    \tagstructbegin{tag=P,AF=tag/AFtest}
    \end{lstlisting}
 
@@ -1311,6 +1369,12 @@
    a concept new in PDF 2.0, but the code currently doesn't check the pdf version, it is your responsability
    to set it (this can be done with the \texttt{pdfversion} key in \verb+\DeclareDocumentMetadata+).
 
+   \item[\PrintKeyName{root-AF}]
+   This key allows to reference an associated file in the root structure element. Using the root
+   can be e.g. useful to add a css-file. When converting the pdf to a html with e.g. ngpdf this css-file is then
+   referenced in the head of the html.
+
+
    \item[\PrintKeyName{AFinline}]
     This key allows to embed an associated file with inline content. The value is some text,
     which is embedded in the PDF as a text file with mime type text/plain.
@@ -1586,10 +1650,10 @@
 \item[\PrintKeyName{tag}] This is the name of the new type as it should then be used in \cs{tagstructbegin}.
 \item[\PrintKeyName{namespace}] This is the namespace of the new type. The value should be a shorthand of a namespace. The allowed values are currently |pdf|, |pdf2|, |mathml| and |user|. The default value (and recommended value for a new tag) is |user|. The public name of the user namespace is |tag/NS/user|. This can be used to reference
     the namespace e.g. in attributes.
-\item[\PrintKeyName{role}] This is type the tag should be mapped too. In a PDF 1.7 or earlier this is normally a type from the |pdf| set, in PDF 2.0 from the |pdf|, |pdf2| and |mathml| set. It can also be a user type, or a still unknown type. The PDF format allows mapping to be done transitively. But you should be aware that tagpdf can't (or more precisely won't) check such unusual role mapping. It lies in the responsability of the author to ensure here that every type is correctly role mapped.
+\item[\PrintKeyName{role}] This is the type the tag should be mapped too. In a PDF 1.7 or earlier this is normally a type from the |pdf| set, in PDF 2.0 from the |pdf|, |pdf2| and |mathml| set. It can also be a user type, or a still unknown type. The PDF format allows mapping to be done transitively. But you should be aware that tagpdf can't (or more precisely won't) check such unusual role mapping. It lies in the responsability of the author to ensure here that every type is correctly role mapped.
 \item[\PrintKeyName{role-namespace}] If the role is a known type the default value is the default namespace: |pdf2| for all types in this set, |pdf| for the type which exist only in PDF 1.7,  |mathml| for the MathML types, and  for previously defined user types whatever namespace has been set there. If the role is unknown, |user| is used and the code hopes that the type will be defined later.
  \item[unknown key] An unknown key is interpreted as a |tag/role|, this preserves the old syntax. So this two calls are equivalent:
- 
+
    \begin{lstlisting}
     \tagpdfsetup{add-new-tag = section/H1}
     \tagpdfsetup{add-new-tag = {tag=section,role=H1}}
@@ -1623,8 +1687,45 @@
 
 This is in pdftex a primitive. It inserts the dummy space glyph. \pkg{tagpdf} defines this command also for luatex -- attention if can perhaps insert break points.
 
+\section{Structure destinations}\label{sec:struct-dest}
 
+ Standard destinations (anchors for internal links)
+ consist of a reference to a page in the pdf and instructions
+ how to display it---typically they will put a specific coordinate in the left top corner
+ of the viewer and so give the impression that a link jumped to the word in this place.
+ But in reality they are not connected to the content.
 
+ Starting with pdf~2.0 destinations can in a tagged PDF also point
+ to a structure (to a \texttt{/StructElem} object).
+ GoTo links can then additionally to the \texttt{/D} key which points to a
+ standard page destination also point to such a structure destination with an \texttt{/SD} key.
+ Programs that e.g. convert such a PDF to html can then create better links.
+ (According to the reference, PDF-viewer should prefer the structure destination
+ over the page destination, but as far as it is known this isn't done yet.)
+
+ Currently structure destinations (and GoTo links making use of it) could natively only
+ be created with the dvipdfmx backend. With pdftex and lualatex it was only possible to create
+ a restricted type which used only the \enquote{Fit} mode. Starting with
+ \TeX{}live 2022  (earlier in miktex) both engines will knew new keywords which allow
+ to create structure destination easily.
+
+ Support for this has been already added to the pdfmanagement and \pkg{tagpdf} will make
+ use of it if possible. In most cases it should simply work, but one should be aware
+ that as one now has a destination that is actually tied to the content it gets more
+ important to actually consider the context and the place where such destinations
+ are created. It now makes a difference if the destination is created before the
+ structure is opened or after so in some cases
+ code that place destinations should be changed to place them inside the structure they
+ belong too. .
+ One also has to consider the pages connected to the destinations: The structure destination
+ is bound to the page where the structure \emph{begins}, if this differ from the page of the page destination
+ (e.g. if the destination is created by a \verb+\phantomsection+  in the middle of a longer paragraph)
+ then be necessary to surround
+ destinations with a dummy structure (a Span or an Artifact) to
+ get the right page number.
+
+
+
 \section{Accessibility is not only tagging}
 
 

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx	2022-01-13 21:05:40 UTC (rev 61600)
@@ -2,7 +2,7 @@
 %
 %% File: tagpdf-backend.dtx
 %
-% Copyright (C) 2019-2021 Ulrike Fischer
+% Copyright (C) 2019-2022 Ulrike Fischer
 %
 % It may be distributed and/or modified under the conditions of the
 % LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -51,13 +51,13 @@
 %    }^^A
 % }
 %
-% \date{Version 0.92, released 2021-08-27}
+% \date{Version 0.93, released 2022-01-13}
 % \maketitle
 % \begin{implementation}
 %    \begin{macrocode}
 %<@@=tag>
 %<*luatex>
-\ProvidesExplFile {tagpdf-luatex.def} {2021-08-27} {0.92}
+\ProvidesExplFile {tagpdf-luatex.def} {2022-01-13} {0.93}
   {tagpdf~driver~for~luatex}
 %    \end{macrocode}
 % \section{Loading the lua}
@@ -161,8 +161,8 @@
 
 local ProvidesLuaModule = {
     name          = "tagpdf",
-    version       = "0.92",       --TAGVERSION
-    date          = "2021-08-27", --TAGDATE
+    version       = "0.93",       --TAGVERSION
+    date          = "2022-01-13", --TAGDATE
     description   = "tagpdf lua code",
     license       = "The LATEX Project Public License 1.3c"
 }
@@ -739,11 +739,6 @@
 ltx.@@.func.markspaceoff=@@_deactivate_mark_space
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}
-%  {
-%   default_space_char,
-%   default_fontid,
-%  }
 % We need two local variable to setup a default space char.
 %    \begin{macrocode}
 local default_space_char = node.new(GLYPH)
@@ -751,7 +746,6 @@
 default_space_char.char  = 32
 default_space_char.font  = default_fontid
 %    \end{macrocode}
-% \end{macro}
 % \begin{macro}
 %   {
 %    @@_space_chars_shipout,

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx	2022-01-13 21:05:40 UTC (rev 61600)
@@ -2,7 +2,7 @@
 %
 %% File: tagpdf-checks.dtx
 %
-% Copyright (C) 2019-2021 Ulrike Fischer
+% Copyright (C) 2019-2022 Ulrike Fischer
 %
 % It may be distributed and/or modified under the conditions of the
 % LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -52,7 +52,7 @@
 %    }^^A
 % }
 %
-% \date{Version 0.92, released 2021-08-27}
+% \date{Version 0.93, released 2022-01-13}
 % \maketitle
 % \begin{documentation}
 % \section{Commands}
@@ -245,13 +245,60 @@
 % INFO PARENTTREE-NUMENTRY & 3 \\
 % INFO PARENTTREE-STRUCT-OBJREF & 4
 % \end{longtable}
-
+%
+% \subsection{Debug mode messages and code}
+% If the package tagpdf-debug is loaded a number of commands are redefined and
+% enhanced with additional commands which can be used to output debug messages or
+% collect statistics. The commands are present but do nothing if the log-level is zero.
+% \begin{tabular}{llll}
+%   command             & name     & action   & remark\\\hline
+%   |\tag_mc_begin:n|   & mc-begin-insert & msg   \\
+%                       & mc-begin-ignore & msg     & if inactive \\
+% \end{tabular}
+%
+% \subsection{Messages}
+% \begin{function}{
+%  mc-nested,
+%  mc-tag-missing,
+%  mc-label-unknown,
+%  mc-used-twice,
+%  mc-used-twice,
+%  mc-not-open,
+%  mc-pushed,
+%  mc-popped,
+%  mc-current}
+%  Various messages related to mc-chunks. TODO document their meaning.
+% \end{function}
+% \begin{function}{struct-no-objnum,struct-faulty-nesting,
+%  struct-missing-tag,struct-used-twice,struct-label-unknown,struct-show-closing}
+% Various messages related to structure. TODO document their meaning.
+% \end{function}
+%
+% \begin{function}{attr-unknown}
+% Message if an attribute i sunknown.
+% \end{function}
+%
+% \begin{function}{role-missing,role-unknown,role-unknown-tag,role-tag,new-tag}
+% Messages related to role mapping.
+% \end{function}
+%
+% \begin{function}{tree-mcid-index-wrong}
+% Used in the tree code, typically indicates the document must be rerun.
+% \end{function}
+%
+% \begin{function}{sys-no-interwordspace}
+% Message if an engine doesn't support inter word spaces
+% \end{function}
+%
+% \begin{function}{para-hook-count-wrong}
+% Message if the number of begin paragraph and end paragraph differ. This normally means faulty structure.
+% \end{function}
 % \end{documentation}
 % \begin{implementation}
 %    \begin{macrocode}
 %<@@=tag>
 %<*header>
-\ProvidesExplPackage {tagpdf-checks-code} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdf-checks-code} {2022-01-13} {0.93}
  {part of tagpdf - code related to checks, conditionals, debugging and messages}
 %</header>
 %    \end{macrocode}
@@ -791,5 +838,88 @@
 %    \begin{macrocode}
 %</package>
 %    \end{macrocode}
+%    \begin{macrocode}
+%<*debug>
+%    \end{macrocode}
+% Code for tagpdf-debug. This will probably change over time.
+% At first something for the mc commands.
+%    \begin{macrocode}
+\msg_new:nnn { tag / debug } {mc-begin} { MC~begin~#1~with~options:~\tl_to_str:n{#2}~[\msg_line_context:] }
+\msg_new:nnn { tag / debug } {mc-end}   { MC~end~#1~[\msg_line_context:] }
+
+\cs_new_protected:Npn \@@_debug_mc_begin_insert:n #1
+ {
+   \int_compare:nNnT { \l_@@_loglevel_int } > {0}
+     {
+        \msg_note:nnnn { tag / debug } {mc-begin} {inserted} { #1 }
+     }
+ }
+\cs_new_protected:Npn \@@_debug_mc_begin_ignore:n #1
+ {
+   \int_compare:nNnT { \l_@@_loglevel_int } > {0}
+     {
+        \msg_note:nnnn { tag / debug } {mc-begin } {ignored} { #1 }
+     }
+ }
+\cs_new_protected:Npn \@@_debug_mc_end_insert:
+ {
+   \int_compare:nNnT { \l_@@_loglevel_int } > {0}
+     {
+        \msg_note:nnn { tag / debug } {mc-end} {inserted}
+     }
+ }
+\cs_new_protected:Npn \@@_debug_mc_end_ignore:
+ {
+   \int_compare:nNnT { \l_@@_loglevel_int } > {0}
+     {
+        \msg_note:nnn { tag / debug } {mc-end } {ignored}
+     }
+ }
+%    \end{macrocode}
+% And now something for the structures
+%    \begin{macrocode}
+\msg_new:nnn { tag / debug } {struct-begin}
+  {
+    Struct~begin~#1~with~options:~\tl_to_str:n{#2}~[\msg_line_context:]
+  }
+\msg_new:nnn { tag / debug } {struct-end}
+  {
+    Struct~end~#1~[\msg_line_context:]
+  }
+
+\cs_new_protected:Npn \@@_debug_struct_begin_insert:n #1
+ {
+   \int_compare:nNnT { \l_@@_loglevel_int } > {0}
+     {
+        \msg_note:nnnn { tag / debug } {struct-begin} {inserted} { #1 }
+        \seq_log:N \g_@@_struct_tag_stack_seq
+     }
+ }
+\cs_new_protected:Npn \@@_debug_struct_begin_ignore:n #1
+ {
+   \int_compare:nNnT { \l_@@_loglevel_int } > {0}
+     {
+        \msg_note:nnnn { tag / debug } {struct-begin } {ignored} { #1 }
+     }
+ }
+\cs_new_protected:Npn \@@_debug_struct_end_insert:
+ {
+   \int_compare:nNnT { \l_@@_loglevel_int } > {0}
+     {
+        \msg_note:nnn { tag / debug } {struct-end} {inserted}
+        \seq_log:N \g_@@_struct_tag_stack_seq
+     }
+ }
+\cs_new_protected:Npn \@@_debug_struct_end_ignore:
+ {
+   \int_compare:nNnT { \l_@@_loglevel_int } > {0}
+     {
+        \msg_note:nnn { tag / debug } {struct-end } {ignored}
+     }
+ }
+%    \end{macrocode}
+%    \begin{macrocode}
+%</debug>
+%    \end{macrocode}
 % \end{implementation}
 % \PrintIndex

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-generic.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-generic.dtx	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-generic.dtx	2022-01-13 21:05:40 UTC (rev 61600)
@@ -2,7 +2,7 @@
 %
 %% File: tagpdf-mc.dtx
 %
-% Copyright (C) 2019-2021 Ulrike Fischer
+% Copyright (C) 2019-2022 Ulrike Fischer
 %
 % It may be distributed and/or modified under the conditions of the
 % LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -50,7 +50,7 @@
 %    }^^A
 % }
 %
-% \date{Version 0.92, released 2021-08-27}
+% \date{Version 0.93, released 2022-01-13}
 % \maketitle
 % \begin{documentation}
 % \end{documentation}
@@ -59,9 +59,13 @@
 %    \begin{macrocode}
 %<@@=tag>
 %<*generic>
-\ProvidesExplPackage {tagpdf-mc-code-generic} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdf-mc-code-generic} {2022-01-13} {0.93}
  {part of tagpdf - code related to marking chunks - generic mode}
 %</generic>
+%<*debug>
+\ProvidesExplPackage {tagpdf-debug-generic} {2022-01-13} {0.93}
+ {part of tagpdf - debugging code related to marking chunks - generic mode}
+%</debug>
 %    \end{macrocode}
 %
 %\subsection{Variables}
@@ -653,6 +657,7 @@
 % It is use by the get command.
 %    \begin{macrocode}
 \cs_new:Nn \@@_get_data_mc_tag: { \g_@@_mc_key_tag_tl }
+%</generic>
 %    \end{macrocode}
 % \end{macro}
 %
@@ -663,10 +668,20 @@
 % the state is passed to the end command through a global var and
 % a global boolean.
 %    \begin{macrocode}
+%<*generic|debug>
+%<*generic>
 \cs_new_protected:Npn \tag_mc_begin:n #1 %#1 keyval
   {
     \@@_check_if_active_mc:T
       {
+%</generic>
+%<*debug>
+\cs_set_protected:Npn \tag_mc_begin:n #1 %#1 keyval
+  {
+    \@@_check_if_active_mc:TF
+      {
+        \@@_debug_mc_begin_insert:n { #1 }
+%</debug>
         \group_begin: %hm
         \@@_check_mc_if_nested:
         \bool_gset_true:N \g_@@_in_mc_bool
@@ -695,11 +710,25 @@
           }
         \group_end:
       }
+%<*debug>
+      {
+        \@@_debug_mc_begin_ignore:n { #1 }
+      }
+%</debug>
   }
+%<*generic>
 \cs_new_protected:Nn \tag_mc_end:
   {
     \@@_check_if_active_mc:T
       {
+%</generic>
+%<*debug>
+\cs_set_protected:Nn \tag_mc_end:
+  {
+    \@@_check_if_active_mc:TF
+      {
+        \@@_debug_mc_end_insert:
+%</debug>
         \@@_check_mc_if_open:
         \bool_gset_false:N \g_@@_in_mc_bool
         \tl_gset:Nn  \g_@@_mc_key_tag_tl { }
@@ -706,7 +735,13 @@
         \@@_mc_emc:
         \@@_mc_end_marks:
       }
+%<*debug>
+      {
+        \@@_debug_mc_end_ignore:
+      }
+%</debug>
   }
+%</generic|debug>
 %    \end{macrocode}
 % \end{macro}
 
@@ -717,12 +752,15 @@
 % we assume that their values are safe.
 % \begin{macro}
 %  {
-%   tag,raw,
-%   alttext,
-%   actualtext,
-%   label,artifact
+%   tag (mc-key),
+%   raw (mc-key),
+%   alttext (mc-key),
+%   actualtext (mc-key),
+%   label (mc-key),
+%   artifact (mc-key)
 %  }
 %    \begin{macrocode}
+%<*generic>
 \keys_define:nn { @@ / mc }
   {
     tag .code:n = % the name (H,P,Span) etc

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-luacode.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-luacode.dtx	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-luacode.dtx	2022-01-13 21:05:40 UTC (rev 61600)
@@ -2,7 +2,7 @@
 %
 %% File: tagpdf-mc.dtx
 %
-% Copyright (C) 2019-2021 Ulrike Fischer
+% Copyright (C) 2019-2022 Ulrike Fischer
 %
 % It may be distributed and/or modified under the conditions of the
 % LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -50,9 +50,8 @@
 %    }^^A
 % }
 %
-% \date{Version 0.92, released 2021-08-27}
+% \date{Version 0.93, released 2022-01-13}
 % \maketitle
-
 % \begin{implementation}
 % The code is splitted into three parts: code shared by all engines,
 % code specific to luamode and code not used by luamode.
@@ -91,7 +90,7 @@
 %    \begin{macrocode}
 %<@@=tag>
 %<*luamode>
-\ProvidesExplPackage {tagpdf-mc-code-lua} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdf-mc-code-lua} {2022-01-13} {0.93}
   {tagpdf - mc code only for the luamode }
 %</luamode>
 %    \end{macrocode}
@@ -159,7 +158,7 @@
 \cs_new_protected:Npn \@@_add_missing_mcs_to_stream:Nn #1#2 {}
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{\@@_mc_if_in:,\tag_mc_if_in:}
+% \begin{macro}[pTF]{\@@_mc_if_in:,\tag_mc_if_in:}
 % This tests, if we are in an mc, for attributes
 % this means to check against a number.
 %    \begin{macrocode}
@@ -358,10 +357,12 @@
 % \subsection{Key definitions}
 % \begin{macro}
 %   {
-%    tag,raw,
-%    alttext,
-%    actualtext,
-%    label,artifact
+%    tag (mc-key),
+%    raw (mc-key),
+%    alttext (mc-key),
+%    actualtext (mc-key),
+%    label (mc-key),
+%    artifact (mc-key)
 %   }
 %   TODO: check conversion, check if local/global setting is right.
 %    \begin{macrocode}

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-shared.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-shared.dtx	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-shared.dtx	2022-01-13 21:05:40 UTC (rev 61600)
@@ -2,7 +2,7 @@
 %
 %% File: tagpdf-mc.dtx
 %
-% Copyright (C) 2019-2021 Ulrike Fischer
+% Copyright (C) 2019-2022 Ulrike Fischer
 %
 % It may be distributed and/or modified under the conditions of the
 % LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -50,7 +50,7 @@
 %    }^^A
 % }
 %
-% \date{Version 0.92, released 2021-08-27}
+% \date{Version 0.93, released 2022-01-13}
 % \maketitle
 % \begin{documentation}
 % \section{Public Commands}
@@ -120,7 +120,7 @@
 % The following keys can be used with |\tag_mc_begin:n|, |\tagmcbegin|,
 % |\tag_mc_begin_pop:n|,
 %
-% \begin{function}{tag}
+% \begin{function}{tag (mc-key)}
 % This key is required, unless artifact is used.
 % The value is a tag like |P| or |H1| without a slash at the begin,
 % this is added by the code.
@@ -131,7 +131,7 @@
 % (some ascii with numbers like \texttt{H4} is fine).
 % \end{function}
 %
-% \begin{function}{artifact}
+% \begin{function}{artifact (mc-key)}
 %  This will setup the marked content as an artifact. The key should be used
 %  for content that should be ignored.
 %  The key can take one of the values |pagination|,
@@ -139,19 +139,19 @@
 %  (this is the default).
 % \end{function}
 %
-% \begin{function}{raw}
+% \begin{function}{raw (mc-key)}
 % This key allows  to add more entries to the properties dictionary.
 % The value must be correct, low-level PDF. E.g.
 % \verb+raw=/Alt (Hello)+ will insert an alternative Text.
 % \end{function}
 %
-% \begin{function}{alttext}
+% \begin{function}{alttext (mc-key)}
 %  This key inserts an \texttt{/Alt} value in the property dictionary of the BDC operator.
 %  The value is handled as verbatim string, commands are not expanded.
 %  The value will be expanded first once.
 % \end{function}
 %
-% \begin{function}{actualtext}
+% \begin{function}{actualtext (mc-key)}
 %  This key inserts an \texttt{/ActualText} value in the property dictionary
 %  of the BDC operator. The value is handled as verbatim string,
 %  commands are not expanded.
@@ -158,7 +158,7 @@
 %  The value will be expanded first once.
 % \end{function}
 %
-% \begin{function}{label}
+% \begin{function}{label (mc-key)}
 %  This key sets a label by which one can call the marked content
 %  later in another structure
 %  (if it has been stashed with the |stash| key).
@@ -165,7 +165,7 @@
 %  Internally the label name will start with \texttt{tagpdf-}.
 % \end{function}
 %
-% \begin{function}{stash}
+% \begin{function}{stash (mc-key)}
 % This \enquote{stashes} an mc-chunk: it is not inserted into the current structure.
 % It should be normally be used along with a label to be able to use the mc-chunk
 % in another place.
@@ -178,7 +178,7 @@
 %    \begin{macrocode}
 %<@@=tag>
 %<*header>
-\ProvidesExplPackage {tagpdf-mc-code-shared} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdf-mc-code-shared} {2022-01-13} {0.93}
   {part of tagpdf - code related to marking chunks -
    code shared by generic and luamode }
 %</header>
@@ -407,7 +407,7 @@
 % \subsection{Keys}
 % This are the keys where the code can be shared between the modes.
 %
-% \begin{macro}{stash,__artifact-bool,__artifact-type}
+% \begin{macro}{stash (mc-key),__artifact-bool,__artifact-type}
 % the two internal artifact keys are use to define the public |artifact|.
 % For now we add support for the subtypes Header and Footer.
 % Watermark,PageNum, LineNum,Redaction,Bates will be added if some use case

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx	2022-01-13 21:05:40 UTC (rev 61600)
@@ -2,7 +2,7 @@
 %
 %% File: tagpdf-roles.dtx
 %
-% Copyright (C) 2019-2021 Ulrike Fischer
+% Copyright (C) 2019-2022 Ulrike Fischer
 %
 % It may be distributed and/or modified under the conditions of the
 % LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -50,13 +50,48 @@
 %    }^^A
 % }
 %
-% \date{Version 0.92, released 2021-08-27}
+% \date{Version 0.93, released 2022-01-13}
 % \maketitle
+% \begin{documentation}
+% \begin{function}
+%  {
+%    add-new-tag (setup-key),
+%    tag (rolemap-key),
+%    namespace (rolemap-key),
+%    role (rolemap-key),
+%    role-namespace (rolemap-key)
+%  }
+% This key can be used in \cs{tagpdfsetup} to declare and rolemap new tags.
+% It takes as value a key-value list or a simple |new-tag/old-tag|.
+%
+% The key-value list knows the following keys:
+% \begin{description}
+% \item[\texttt{tag}] This is the name of the new type as it should then be used in \cs{tagstructbegin}.
+% \item[\texttt{namespace}] This is the namespace of the new type.
+%   The value should be a shorthand of a namespace.
+%   The allowed values are currently |pdf|, |pdf2|, |mathml| and |user|.
+%   The default value (and recommended value for a new tag) is |user|.
+%   The public name of the user namespace is |tag/NS/user|. This can be used to reference
+%   the namespace e.g. in attributes.
+% \item[\texttt{role}] This is the type the tag should be mapped too.
+%  In a PDF 1.7 or earlier this is normally a type from the |pdf| set,
+%  in PDF 2.0 from the |pdf|, |pdf2| and |mathml| set.
+%  It can also be a user type, or a still unknown type.
+%  The PDF format allows mapping to be done transitively.
+%  But tagpdf can't/won't check such unusual role mapping.
+% \item[\texttt{role-namespace}] If the role is a known type
+%  the default value is the default namespace of this type.
+%  If the role is unknown, |user| is used and
+%  the code hopes that the type will be defined later. With this key a specific
+%  namespace can be forced.
+% \end{description}
+% \end{function}
+% \end{documentation}
 % \begin{implementation}
 %    \begin{macrocode}
 %<@@=tag>
 %<*header>
-\ProvidesExplPackage {tagpdf-roles-code} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdf-roles-code} {2022-01-13} {0.93}
  {part of tagpdf - code related to roles and structure names}
 %</header>
 %    \end{macrocode}
@@ -631,9 +666,15 @@
 %    \end{macrocode}
 % \end{macro}
 % \subsection{Key-val user interface}
-%  The user interface use the key |add-new-tag|, which takes either a
+%  The user interface uses the key |add-new-tag|, which takes either a
 %  keyval list as argument, or a tag/role.
-%  \begin{macro}{tag,tag-namespace,role,role-namespace,add-new-tag}
+%  \begin{macro}
+%    {
+%     tag (rolemap-key),
+%     tag-namespace (rolemap-key),
+%     role (rolemap-key),
+%     role-namespace (rolemap-key),
+%     add-new-tag (setup-key)}
 %    \begin{macrocode}
 \keys_define:nn { @@ / tag-role }
   {

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx	2022-01-13 21:05:40 UTC (rev 61600)
@@ -2,7 +2,7 @@
 %
 %% File: tagpdf-space.dtx
 %
-% Copyright (C) 2019-2021 Ulrike Fischer
+% Copyright (C) 2019-2022 Ulrike Fischer
 %
 % It may be distributed and/or modified under the conditions of the
 % LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -50,13 +50,25 @@
 %    }^^A
 % }
 %
-% \date{Version 0.92, released 2021-08-27}
+% \date{Version 0.93, released 2022-01-13}
 % \maketitle
+% \begin{documentation}
+% \begin{function}{interwordspace (setup-key)}
+% This key allows to activate/deactivate the real space chars if the engine supports
+% it. The allowed values are |true|, |on|, |false|, |off|.
+% \end{function}
+% \begin{function}{show-spaces (setup-key)}
+% This key works only with luatex and shows with small red
+% bars where spaces have been inserted. This is only for debugging and
+% is not completly reliable (and change affect other literals and tagging), so it
+% should be used with care.
+% \end{function}
+% \end{documentation}
 % \begin{implementation}
 %    \begin{macrocode}
 %<@@=tag>
 %<*header>
-\ProvidesExplPackage {tagpdf-space-code} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdf-space-code} {2022-01-13} {0.93}
  {part of tagpdf - code related to real space chars}
 %</header>
 %    \end{macrocode}
@@ -65,7 +77,7 @@
 % support real space chars. Most of the code for luatex which uses attributes
 % is in the lua code, here are only the keys.
 %
-% \begin{macro}{interwordspace,show-spaces}
+% \begin{macro}{interwordspace (setup-key),show-spaces (setup-key)}
 %    \begin{macrocode}
 %<*package>
 \sys_if_engine_pdftex:T

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx	2022-01-13 21:05:40 UTC (rev 61600)
@@ -2,7 +2,7 @@
 %
 %% File: tagpdf-struct.dtx
 %
-% Copyright (C) 2019-2021 Ulrike Fischer
+% Copyright (C) 2019-2022 Ulrike Fischer
 %
 % It may be distributed and/or modified under the conditions of the
 % LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -50,7 +50,7 @@
 %    }^^A
 % }
 %
-% \date{Version 0.92, released 2021-08-27}
+% \date{Version 0.93, released 2022-01-13}
 % \maketitle
 % \begin{documentation}
 % \section{Public Commands}
@@ -94,9 +94,9 @@
 % \end{function}
 % \section{Public keys}
 % \subsection{Keys for the structure commands}
-% \begin{function}{tag}
+% \begin{function}{tag (struct-key)}
 % This is required. The value of the key is normally one of the
-% standard types listed in section \ref{sec:new-tag}.
+% standard types listed in the main tagpdf documentation.
 % It is possible to setup new tags/types.
 % The value can also be of the form |type/NS|, where |NS| is the
 % shorthand of a declared name space.
@@ -104,7 +104,7 @@
 % This allows to use a different name space than
 % the one connected by default to the tag. But normally this should not be needed.
 % \end{function}
-% \begin{function}{stash}
+% \begin{function}{stash (struct-key)}
 %  Normally a new structure inserts itself as a kid
 %  into the currently active structure. This key prohibits this.
 %  The structure is nevertheless from now on
@@ -111,12 +111,12 @@
 %  \enquote{the current active structure}
 %  and parent for following  marked content and structures.
 % \end{function}
-% \begin{function}{label}
+% \begin{function}{label (struct-key)}
 % This key sets a label by which
 % one can use the structure later in another structure.
 % Internally the label name will start with \texttt{tagpdfstruct-}.
 % \end{function}
-% \begin{function}{title,title-o}
+% \begin{function}{title (struct-key),title-o (struct-key)}
 % This keys allows to set the dictionary entry
 % \texttt{/Title} in the structure object.
 % The value is handled as verbatim string and hex encoded.
@@ -123,35 +123,35 @@
 % Commands are not expanded. |title-o| will expand the value once.
 % \end{function}
 %
-% \begin{function}{alttext}
+% \begin{function}{alttext (struct-key)}
 % This key inserts an \texttt{/Alt} value in the dictionary of structure object.
 % The value is handled as verbatim string and hex encoded.
 % The value will be expanded first once.
 % \end{function}
-% \begin{function}{actualtext}
+% \begin{function}{actualtext (struct-key)}
 % This key inserts an \texttt{/ActualText} value in the dictionary of structure object.
 % The value is handled as verbatim string and hex encoded.
 % The value will be expanded first once.
 % \end{function}
-% \begin{function}{lang}
+% \begin{function}{lang (struct-key)}
 % This key allows to set the language for a structure element. The value should be a bcp-identifier,
 % e.g. |de-De|.
 % \end{function}
-% \begin{function}{ref}
+% \begin{function}{ref (struct-key)}
 %  This key allows to add references to other structure elements,
 %  it adds the |/Ref| array to the structure.
 % The value should be a comma separated list of structure labels
 % set with the |label| key. e.g. |ref={label1,label2}|.
 % \end{function}
-% \begin{function}{E}
+% \begin{function}{E (struct-key)}
 %  This key sets the |/E| key, the expanded form of an
 %  abbreviation or an acronym
 %  (I couldn't think of a better name, so I sticked to E).
 % \end{function}
-% \begin{function}{AF,AFinline,AFinline-o}
+% \begin{function}{AF (struct-key),AFinline (struct-key),AFinline-o (struct-key)}
 % \begin{syntax}
 % AF = \meta{object name}\\
-% AF-inline = \meta{text content}
+% AF-inline = \meta{text content}\\
 % \end{syntax}
 % These keys allows to reference an associated file in the structure element.
 % The value \meta{object name} should be the name of an object pointing
@@ -165,9 +165,11 @@
 % Future versions will perhaps extend this to more mime types, but it is
 % still a research task to find out what is really needed.
 %
+% |AF| can be used more than once, to associate more than one file. The inline
+% keys can be used only once per structure. Additional calls are ignored.
 % \end{function}
 %
-% \begin{function}{attribute}
+% \begin{function}{attribute (struct-key)}
 %  This key takes as argument a comma list of attribute names
 %  (use braces to protect the commas from the external key-val parser)
 %  and allows to add one or more attribute dictionary entries in
@@ -179,7 +181,7 @@
 %
 %  \end{function}
 %
-% \begin{function}{attribute-class}
+% \begin{function}{attribute-class (struct-key)}
 %  This key takes as argument a comma list of attribute class names
 %  (use braces to protect the commas from the external key-val parser)
 %  and allows to add one or more attribute classes to the structure object.
@@ -188,7 +190,7 @@
 %  must be declared first in \cs{tagpdfsetup}.
 % \end{function}
 % \subsection{Setup keys}
-% \begin{function}{newattribute}
+% \begin{function}{newattribute (setup-key)}
 % \begin{syntax}
 % newattribute = \Arg{name}\Arg{Content}
 % \end{syntax}
@@ -206,12 +208,20 @@
 % \end{verbatim}
 %
 % \end{function}
+% \begin{function}{root-AF (setup-key)}
+% \begin{syntax}
+% root-AF = \meta{object name}
+% \end{syntax}
+% This key can be used in the setup command \cs{tagpdfsetup} and allows
+% to add associated files to the root structure. Like |AF| it can be used more than
+% once to add more than one file.
+% \end{function}
 % \end{documentation}
 % \begin{implementation}
 %    \begin{macrocode}
 %<@@=tag>
 %<*header>
-\ProvidesExplPackage {tagpdf-struct-code} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdf-struct-code} {2022-01-13} {0.93}
  {part of tagpdf - code related to storing structure}
 %</header>
 %    \end{macrocode}
@@ -313,7 +323,8 @@
     ParentTreeNextKey, % optional
     RoleMap,
     ClassMap,
-    Namespaces
+    Namespaces,
+    AF                 %pdf 2.0
   }
 
 \seq_const_from_clist:Nn \c_@@_struct_StructElem_entries_seq
@@ -742,11 +753,16 @@
 % at the begin.
 % \begin{macro}
 %  {
-%    label,stash,tag,
-%    title,title-o,
-%    alttext,
-%    actualtext,
-%    lang,ref,E
+%    label (struct-key),
+%    stash (struct-key),
+%    tag (struct-key),
+%    title (struct-key),
+%    title-o (struct-key),
+%    alttext (struct-key),
+%    actualtext (struct-key),
+%    lang (struct-key),
+%    ref (struct-key),
+%    E (struct-key)
 %  }
 %    \begin{macrocode}
 \keys_define:nn { @@ / struct }
@@ -854,12 +870,35 @@
   }
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{AF,AFinline,AFinline-o}
+% \begin{macro}{AF (struct-key),AFinline (struct-key),AFinline-o (struct-key)}
 % keys for the AF keys (associated files). They use commands from l3pdffile!
 % The stream variants use txt as extension to get the mimetype.
 % TODO: check if this should be configurable. For math we will perhaps need another
 % extension.
+% AF is an array and can be used more than once, so we store it in a tl.
+% which is expanded.
+% AFinline can be use only once (more quite probably doesn't make sense).
 %    \begin{macrocode}
+\cs_new_protected:Npn \@@_struct_add_AF:nn #1 #2 % #1 struct num #2 object name
+  {
+     \tl_if_exist:cTF
+       {
+         g_@@_struct_#1_AF_tl
+       }
+       {
+         \tl_gput_right:cx
+           { g_@@_struct_#1_AF_tl }
+           {  ~ \pdf_object_ref:n {#2} }
+       }
+       {
+          \tl_new:c
+            { g_@@_struct_#1_AF_tl }
+          \tl_gset:cx
+            { g_@@_struct_#1_AF_tl }
+            { \pdf_object_ref:n {#2} }
+       }
+  }
+\cs_generate_variant:Nn \@@_struct_add_AF:nn {en,ee}
 \keys_define:nn { @@ / struct }
  {
     AF .code:n        = % AF property
@@ -866,10 +905,16 @@
       {
         \pdf_object_if_exist:nTF {#1}
           {
+            \@@_struct_add_AF:en { \int_eval:n {\c at g_@@_struct_abs_int} }{#1}
             \@@_prop_gput:cnx
              { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
              { AF }
-             { \pdf_object_ref:n {#1} }
+             {
+               [
+                 \tl_use:c
+                   { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_AF_tl }
+               ]
+             }
           }
           {
 
@@ -879,16 +924,24 @@
      {
        \group_begin:
        \pdf_object_if_exist:eF {@@/fileobj\int_use:N\c at g_@@_struct_abs_int}
-        {
-          \pdffile_embed_stream:nxx
-            {#1}
-            {tag-AFfile\int_use:N\c at g_@@_struct_abs_int.txt}
-            {@@/fileobj\int_use:N\c at g_@@_struct_abs_int}
-        }
-       \@@_prop_gput:cnx
-         { g_@@_struct_\int_use:N\c at g_@@_struct_abs_int _prop }
-         { AF }
-         { \pdf_object_ref:e {@@/fileobj\int_use:N\c at g_@@_struct_abs_int } }
+         {
+           \pdffile_embed_stream:nxx
+             {#1}
+             {tag-AFfile\int_use:N\c at g_@@_struct_abs_int.txt}
+             {@@/fileobj\int_use:N\c at g_@@_struct_abs_int}
+           \@@_struct_add_AF:ee
+             { \int_eval:n {\c at g_@@_struct_abs_int} }
+             { @@/fileobj\int_use:N\c at g_@@_struct_abs_int }
+           \@@_prop_gput:cnx
+             { g_@@_struct_\int_use:N\c at g_@@_struct_abs_int _prop }
+             { AF }
+             {
+               [
+                 \tl_use:c
+                  { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_AF_tl }
+               ]
+             }
+         }
        \group_end:
      }
    ,AFinline-o .code:n =
@@ -900,24 +953,63 @@
             {#1}
             {tag-AFfile\int_use:N\c at g_@@_struct_abs_int.txt}
             {@@/fileobj\int_use:N\c at g_@@_struct_abs_int}
+          \@@_struct_add_AF:ee
+             { \int_eval:n {\c at g_@@_struct_abs_int} }
+             { @@/fileobj\int_use:N\c at g_@@_struct_abs_int }
+           \@@_prop_gput:cnx
+             { g_@@_struct_\int_use:N\c at g_@@_struct_abs_int _prop }
+             { AF }
+             {
+               [
+                 \tl_use:c
+                  { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_AF_tl }
+               ]
+             }
         }
-       \@@_prop_gput:cnx
-         { g_@@_struct_\int_use:N\c at g_@@_struct_abs_int _prop }
-         { AF }
-         { \pdf_object_ref:e {@@/fileobj\int_use:N\c at g_@@_struct_abs_int } }
        \group_end:
      }
  }
+%</package>
 %    \end{macrocode}
 % \end{macro}
-%
+% \begin{macro}{root-AF (setup-key)}
+% The root structure can take AF keys too, so we provide a key for it.
+% This key is used with |\tagpdfsetup|, not in a structure!
+%    \begin{macrocode}
+\keys_define:nn { @@ / setup }
+  {
+    root-AF .code:n =
+     {
+        \pdf_object_if_exist:nTF {#1}
+          {
+            \@@_struct_add_AF:en { 0 }{#1}
+            \@@_prop_gput:cnx
+             { g_@@_struct_0_prop }
+             { AF }
+             {
+               [
+                 \tl_use:c
+                   { g_@@_struct_0_AF_tl }
+               ]
+             }
+          }
+          {
+
+          }
+      },
+  }
+%    \end{macrocode}
+% \end{macro}
 % \section{User commands}
 %
 % \begin{macro}{\tag_struct_begin:n,\tag_struct_end:}
 %    \begin{macrocode}
-\cs_new_protected:Npn \tag_struct_begin:n #1 %#1 key-val
+%<*package|debug>
+%<package>\cs_new_protected:Npn \tag_struct_begin:n #1 %#1 key-val
+%<debug>\cs_set_protected:Npn \tag_struct_begin:n #1 %#1 key-val
   {
-    \@@_check_if_active_struct:T
+%<package>\@@_check_if_active_struct:T
+%<debug>\@@_check_if_active_struct:TF
       {
         \group_begin:
         \int_gincr:N \c at g_@@_struct_abs_int
@@ -970,16 +1062,18 @@
           }
         %\prop_show:c { g_@@_struct_\g_@@_struct_stack_current_tl _prop }
         %\seq_show:c {g_@@_struct_kids_\l_@@_struct_stack_parent_tmpa_tl _seq}
+%<debug> \@@_debug_struct_begin_insert:n { #1 }
         \group_end:
      }
+%<debug>{ \@@_debug_struct_begin_ignore:n { #1 }}
   }
-
-
-\cs_new_protected:Nn \tag_struct_end:
+%<package>\cs_new_protected:Nn \tag_struct_end:
+%<debug>\cs_set_protected:Nn \tag_struct_end:
   { %take the current structure num from the stack:
     %the objects are written later, lua mode hasn't all needed info yet
     %\seq_show:N \g_@@_struct_stack_seq
-    \@@_check_if_active_struct:T
+%<package>\@@_check_if_active_struct:T
+%<debug>\@@_check_if_active_struct:TF
       {
         \seq_gpop:NN   \g_@@_struct_tag_stack_seq \l_@@_tmpa_tl
         \seq_gpop:NNTF \g_@@_struct_stack_seq \l_@@_tmpa_tl
@@ -999,8 +1093,11 @@
           {
             \tl_gset:NV \g_@@_struct_tag_tl \l_@@_tmpa_tl
           }
+%<debug>\@@_debug_struct_end_insert:
       }
+%<debug>{\@@_debug_struct_end_ignore:}
   }
+%</package|debug>
 %    \end{macrocode}
 % \end{macro}
 % \begin{macro}{\tag_struct_use:n}
@@ -1007,6 +1104,7 @@
 % This command allows to use a stashed structure in another place.
 % TODO: decide how it should be guarded. Probably by the struct-check.
 %    \begin{macrocode}
+%<*package>
 \cs_new_protected:Nn \tag_struct_use:n %#1 is the label
   {
     \@@_check_if_active_struct:T
@@ -1073,7 +1171,7 @@
 % \section{Attributes and attribute classes}
 %    \begin{macrocode}
 %<*header>
-\ProvidesExplPackage {tagpdf-attr-code} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdf-attr-code} {2022-01-13} {0.93}
   {part of tagpdf - code related to attributes and attribute classes}
 %</header>
 %    \end{macrocode}
@@ -1101,7 +1199,7 @@
 %    \end{macrocode}
 % \end{variable}
 % \subsection{Commands and keys}
-% \begin{macro}{\@@_attr_new_entry:nn,newattribute}
+% \begin{macro}{\@@_attr_new_entry:nn,newattribute (setup-key)}
 % This allows to define attributes. Defined attributes
 % are stored in a global property. |newattribute| expects
 % two brace group, the name and the content. The content typically
@@ -1132,7 +1230,7 @@
   }
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{attribute-class}
+% \begin{macro}{attribute-class (struct-key)}
 % attribute-class has to store the used attribute names so that
 % they can be added to the ClassMap later.
 %    \begin{macrocode}
@@ -1172,7 +1270,7 @@
   }
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{attribute}
+% \begin{macro}{attribute (struct-key)}
 %    \begin{macrocode}
 \keys_define:nn { @@ / struct }
   {

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx	2022-01-13 21:05:40 UTC (rev 61600)
@@ -2,7 +2,7 @@
 %
 %% File: tagpdf-tree.dtx
 %
-% Copyright (C) 2019-2021 Ulrike Fischer
+% Copyright (C) 2019-2022 Ulrike Fischer
 %
 % It may be distributed and/or modified under the conditions of the
 % LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -51,13 +51,13 @@
 %    }^^A
 % }
 %
-% \date{Version 0.92, released 2021-08-27}
+% \date{Version 0.93, released 2022-01-13}
 % \maketitle
 % \begin{implementation}
 %    \begin{macrocode}
 %<@@=tag>
 %<*header>
-\ProvidesExplPackage {tagpdf-tree-code} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdf-tree-code} {2022-01-13} {0.93}
  {part of tagpdf - code related to writing trees and dictionaries to the pdf}
 %</header>
 %    \end{macrocode}

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-user.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-user.dtx	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-user.dtx	2022-01-13 21:05:40 UTC (rev 61600)
@@ -2,7 +2,7 @@
 %
 %% File: tagpdf-user.dtx
 %
-% Copyright (C) 2019-2021 Ulrike Fischer
+% Copyright (C) 2019-2022 Ulrike Fischer
 %
 % It may be distributed and/or modified under the conditions of the
 % LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -50,7 +50,7 @@
 %    }^^A
 % }
 %
-% \date{Version 0.92, released 2021-08-27}
+% \date{Version 0.93, released 2022-01-13}
 % \maketitle
 % \begin{documentation}
 % \section{Setup commands}
@@ -60,9 +60,20 @@
 % \end{syntax}
 % This is the main setup command to adapt the behaviour of tagpdf.
 % It can be used in the preamble and in the document (but not all keys make sense there).
+% \end{function}
 %
+% \begin{function}{activate (setup-key)}
+% And additional setup key which combine the other activate keys
+% |activate-mc|, |activate-tree|, |activate-struct| and additionally
+% add a document structure.
 % \end{function}
 %
+%
+% \begin{function}{\tagpdfifluatexTF,\tagpdfifluatexT,\tagpdfifpdftexT}
+% small wrappers around engine tests. This functions should not be used and will be removed
+% in one of the next versions.
+% \end{function}
+%
 % \section{Commands related to mc-chunks}
 % \begin{function}{\tagmcbegin, \tagmcend,\tagmcuse}
 % \begin{syntax}
@@ -76,7 +87,7 @@
 % and \cs{tagmcend} will issue in horizontal mode an \cs{unskip}.
 % \end{function}
 %
-% \begin{function}{\tagmcifin}
+% \begin{function}{\tagmcifinTF}
 % \begin{syntax}
 % \cs{tagmcifin} \Arg{true code}\Arg{false code}
 % \end{syntax}
@@ -112,7 +123,7 @@
 % necessarly stops the compilation. The keys and their function are described below.
 % \end{function}
 %
-% \begin{function}{mc-data}
+% \begin{function}{mc-data (show-key)}
 %  \begin{syntax}
 %    |mc-data| = \meta{number}
 %  \end{syntax}
@@ -123,7 +134,7 @@
 % newpage. The value is a positive integer and sets the first mc-shown. If no value
 % is given, 1 is used and so all mc-chunks created so far are shown.
 % \end{function}
-% \begin{function}{mc-current}
+% \begin{function}{mc-current (show-key)}
 %  \begin{syntax}
 %    |mc-current|
 %  \end{syntax}
@@ -131,8 +142,15 @@
 % chunk is open it shows only the state of the abs count. It works in all mode,
 % but the output in luamode looks different.
 % \end{function}
-% \begin{function}{struct-stack}
+% \begin{function}{mc-marks (show-key)}
 %  \begin{syntax}
+%    |mc-marks| = |show|\verb+|+|use|
+%  \end{syntax}
+% This key helps to debug the page marks. It should only be used at shipout in
+% header or footer.
+% \end{function}
+% \begin{function}{struct-stack (show-key)}
+%  \begin{syntax}
 %    |struct-stack| = |log|\verb+|+|show|
 %  \end{syntax}
 % This key shows the current structure stack. With |log| the info is only
@@ -163,7 +181,7 @@
 % faulty code, e.g. a missing |\par| at the end of a low-level vbox can highly
 % confuse the tagging. The tags should be carefully checked if this is used.
 %
-% \begin{function}{paratagging,paratagging-show}
+% \begin{function}{paratagging (setup-key),paratagging-show (setup-key)}
 %  \begin{syntax}
 %    |paratagging| = |true|\verb+|+|false|\\
 %    |paratagging-show| = |true|\verb+|+|false|\\
@@ -179,15 +197,34 @@
 % faster then |\tagpdfsetup|. But I'm not sure if the names are good.
 % \end{function}
 %
+% \begin{function}{\tagpdfsuppressmarks}
+%  This command allows to suppress the creation of the marks. It takes an argument
+%  which should normally be one of the mc-commands, puts a group around it and
+%  suppress the marks creation in this group. This command should be used if
+%  the begin and end command are at different boxing levels. E.g.
+%  \begin{verbatim}
+%  \@hangfrom
+%   {
+%    \tagstructbegin{tag=H1}%
+%    \tagmcbegin    {tag=H1}%
+%    #2
+%   }
+%   {#3\tagpdfsuppressmarks{\tagmcend}\tagstructend}%
+%  \end{verbatim}
+% \end{function}
+%
 % \subsection{Header and footer}
-% Header and footer are automatically excluded from tagging. This can for
-% now to allow debugging be disabled with the following key, but probably
-% this key will disappear again. If some real content is in the header and
+% Header and footer are automatically excluded from tagging. This can
+% be disabled with the following key.
+% If some real content is in the header and
 % footer, tagging must be restarted there explicitly.
+% The key accepts the values |true| which surrounds the header with an artifact
+% mc-chunk, |false| which disables the automatic tagging, and |pagination| which
+% additionally adds an artifact structure with an pagination attribute.
 %
-% \begin{function}{exclude-header-footer}
+% \begin{function}{exclude-header-footer (setup-key)}
 %  \begin{syntax}
-%    |exclude-header-footer| = |true|\verb+|+|false|
+%    |exclude-header-footer| = |true|\verb+|+|false|\verb+|+pagination
 %  \end{syntax}%
 % \end{function}
 
@@ -213,7 +250,7 @@
 %    \begin{macrocode}
 %<@@=tag>
 %<*header>
-\ProvidesExplPackage {tagpdf-user} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdf-user} {2022-01-13} {0.93}
   {tagpdf - user commands}
 %</header>
 %    \end{macrocode}
@@ -288,14 +325,6 @@
 % \end{macro}
 %
 %
-% \begin{macro}{\tagpdfifluatexTF,\tagpdfifluatexT,\tagpdfifpdftexTF}
-% I should deprecate them ...
-%    \begin{macrocode}
-\cs_set_eq:NN\tagpdfifluatexTF \sys_if_engine_luatex:TF
-\cs_set_eq:NN\tagpdfifluatexT  \sys_if_engine_luatex:T
-\cs_set_eq:NN\tagpdfifpdftexT  \sys_if_engine_pdftex:T
-%    \end{macrocode}
-% \end{macro}
 %
 % \section{Debugging}
 % \begin{macro}{\ShowTagging}
@@ -310,7 +339,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{mc-data}
+% \begin{macro}{mc-data (show-key)}
 % This key is (currently?) relevant for lua mode only.
 % It shows the data of all mc-chunks created so far.
 % It is accurate only after shipout, so typically should be issued after a
@@ -330,7 +359,7 @@
 
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{mc-current}
+% \begin{macro}{mc-current (show-key)}
 % This shows some info about the current mc-chunk. It works in generic and lua-mode.
 %    \begin{macrocode}
 \keys_define:nn { @@ / show }
@@ -397,7 +426,7 @@
   }
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{mc-marks}
+% \begin{macro}{mc-marks (show-key)}
 % It maps the mc-marks into the sequences and then shows them.
 % This allows to inspect the first and last mc-Mark on a page.
 % It should only be used in the shipout (header/footer).
@@ -447,7 +476,7 @@
   }
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{struct-stack}
+% \begin{macro}{struct-stack (show-key)}
 %    \begin{macrocode}
 \keys_define:nn { @@ / show }
   {
@@ -466,7 +495,7 @@
 % This part should be regularly revisited to check if the code should go to a
 % better place or can be improved.
 % \subsection{Document structure}
-% \begin{macro}{\@@_add_document_structure:n,activate}
+% \begin{macro}{\@@_add_document_structure:n,activate (setup-key)}
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_add_document_structure:n #1
  {
@@ -485,6 +514,28 @@
  }
 %    \end{macrocode}
 % \end{macro}
+% \subsection{Structure destinations}
+% In TeXlive 2022 pdftex and luatex will offer support for structure destinations.
+% The  pdfmanagement has already backend support. We activate them if the
+% prerequisites are there: The pdf version should be 2.0, structures should be activated,
+% the code in the pdfmanagement must be there.
+%    \begin{macrocode}
+\AddToHook{begindocument/before}
+  {
+    \bool_lazy_all:nT
+      {
+        { \g_@@_active_struct_dest_bool }
+        { \g_@@_active_struct_bool }
+        { \cs_if_exist_p:N \pdf_activate_structure_destination: }
+        { ! \pdf_version_compare_p:Nn < {2.0} }
+      }
+      {
+        \tl_set:Nn \l_pdf_current_structure_destination_tl { __tag/struct/\g__tag_struct_stack_current_tl }
+        \pdf_activate_structure_destination:
+      }
+   }
+%    \end{macrocode}
+
 % \subsection{Fake space}
 % \begin{macro}{\pdffakespace}
 % We need a luatex variant for |\pdffakespace|. This should probably go into
@@ -518,8 +569,8 @@
 %
 %\begin{macro}
 % {
-%  paratagging,
-%  paratagging-show,
+%  paratagging (setup-key),
+%  paratagging-show (setup-key),
 %  }
 % These keys enable/disable locally paratagging, and the debug modus.
 % It can affect the typesetting if |paratagging-show| is used. The small numbers
@@ -593,7 +644,7 @@
            \tl_put_right:Nn \@mult at ptagging@hook
              {
                \@@_check_typeout_v:n {====>~In~\string\page at sofar}
-               \process at cols\mult at gfirstbox
+               \process at cols\mult at firstbox
                 {
                   \@@_add_missing_mcs_to_stream:Nn \count@ {multicol}
                 }
@@ -686,7 +737,41 @@
        \bool_gset_eq:NN \g_@@_in_mc_bool\g_@@_saved_in_mc_bool
      }
  }
+%    \end{macrocode}
+% This version allows to use an Artifact structure
+%    \begin{macrocode}
+\@@_attr_new_entry:nn {@@/attr/pagination}{/O/Artifact/Type/Pagination}
+\cs_new_protected:Npn \@@_exclude_struct_headfoot_begin:n #1
+ {
+    \bool_set_false:N  \l_@@_para_bool
+    \bool_if:NTF \g_@@_mode_lua_bool
+     {
+      \tag_mc_end_push:
+     }
+     {
+       \bool_gset_eq:NN   \g_@@_saved_in_mc_bool \g_@@_in_mc_bool
+       \bool_gset_false:N \g_@@_in_mc_bool
+     }
+    \tag_struct_begin:n{tag=Artifact,attribute-class=@@/attr/#1}
+    \tag_mc_begin:n {artifact=#1}
+ }
 
+\cs_new_protected:Npn \@@_exclude_struct_headfoot_end:
+ {
+    \tag_mc_end:
+    \tag_struct_end:
+    \bool_if:NTF \g_@@_mode_lua_bool
+     {
+      \tag_mc_begin_pop:n{}
+     }
+     {
+       \bool_gset_eq:NN \g_@@_in_mc_bool\g_@@_saved_in_mc_bool
+     }
+ }
+%    \end{macrocode}
+% And now the keys
+% \begin{macro}{exclude-header-footer (setup-key)}
+%    \begin{macrocode}
 \keys_define:nn { @@ / setup }
   {
     exclude-header-footer .choice:,
@@ -697,6 +782,13 @@
        \cs_set_eq:NN \@@_hook_kernel_after_head:  \@@_exclude_headfoot_end:
        \cs_set_eq:NN \@@_hook_kernel_after_foot:  \@@_exclude_headfoot_end:
      },
+    exclude-header-footer / pagination .code:n =
+     {
+       \cs_set:Nn \@@_hook_kernel_before_head: { \@@_exclude_struct_headfoot_begin:n {pagination} }
+       \cs_set:Nn \@@_hook_kernel_before_foot: { \@@_exclude_struct_headfoot_begin:n {pagination} }
+       \cs_set_eq:NN \@@_hook_kernel_after_head:  \@@_exclude_struct_headfoot_end:
+       \cs_set_eq:NN \@@_hook_kernel_after_foot:  \@@_exclude_struct_headfoot_end:
+     },
     exclude-header-footer / false .code:n =
      {
        \cs_set_eq:NN \@@_hook_kernel_before_head: \prg_do_nothing:
@@ -708,7 +800,7 @@
    exclude-header-footer .initial:n = true
   }
 %    \end{macrocode}
-
+% \end{macro}
 % \subsection{Links}
 % We need to close and reopen mc-chunks around links.
 % Currently we handle URI and GoTo (internal) links.

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx	2022-01-13 21:05:40 UTC (rev 61600)
@@ -2,7 +2,7 @@
 %
 %% File: tagpdf.dtx
 %
-% Copyright (C) 2019-2021 Ulrike Fischer
+% Copyright (C) 2019-2022 Ulrike Fischer
 %
 % It may be distributed and/or modified under the conditions of the
 % LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -23,13 +23,64 @@
 % for those people who are interested.
 %
 % \fi
+% \begin{documentation}
+% \begin{function}{\ref_value:nnn}
+% This is a temporary definition which will have to
+% move to l3ref. It allows to locally set a default value if the label or the attribute
+% doesn't exist. See issue \#4 in Accessible-xref.
+% \begin{syntax}
+% \cs{ref_value:nnn}\Arg{label}\Arg{attribute}\Arg{fallback default}
+% \end{syntax}
+% \end{function}
 %
+% \begin{function}{ \tag_stop_group_begin:, \tag_stop_group_end: }
+% We need a command to stop tagging in some places.
+% This simply switches the two local booleans.
+% \end{function}
+%
+% \begin{function}{activate-space (setup-key)}
+%  |activate-space| activates the additional parsing needed for
+%  interword spaces. It is not documented, the parsing is currently
+%  implicitly activated by the known key |interwordspace|, as the code will
+%  perhaps move to some other place, now that it is better separated.
+% \end{function}
+%
+% \begin{function}{activate-mc (setup-key),
+%    activate-tree (setup-key),
+%    activate-struct (setup-key),
+%    activate-all (setup-key)}
+% Keys to activate the various tagging steps
+% \end{function}
+%\begin{function}{no-struct-dest (setup-key)}
+% The key allows to suppress the creation of structure destinations
+% \end{function}
+%
+% \begin{function}{log (setup-key)}
+% The |log| takes currently the values |none|, |v|, |vv|, |vvv|, |all|.
+% More details are in \texttt{tagpdf-checks}.
+% \end{function}
+%
+% \begin{function}{tagunmarked (setup-key)}
+% This key allows to set if (in luamode) unmarked text should be
+% marked up as artifact. The initial value is true.
+% \end{function}
+%
+% \begin{function}{tabsorder (setup-key)}
+% This sets the tabsorder on a page. The values are |row|, |column|, |structure| (default)
+% or |none|. Currently this is set more or less globally. More finer control can be
+% added if needed.
+% \end{function}
+%
+% \begin{function}{tagstruct,tagstructobj,tagabspage,tagmcabs,tagmcid}
+% These are attributes used by the label/ref system.
+% \end{function}
+% \end{documentation}
 % \begin{implementation}
 % \section{Initialization and test if pdfmanagement is active.}
 %    \begin{macrocode}
 %<@@=tag>
 %<*package>
-\ProvidesExplPackage {tagpdf} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdf} {2022-01-13} {0.93}
   { A package to experiment with pdf tagging }
 
 \bool_if:nF
@@ -51,18 +102,33 @@
        before~\string\documentclass
      }
   }
+%</package>
 %    \end{macrocode}
+%<*debug>
+%    \begin{macrocode}
+\ProvidesExplPackage {tagpdf-debug} {2022-01-13} {0.93}
+  { debug code for tagpdf }
+\@ifpackageloaded{tagpdf}{}{\PackageWarning{tagpdf-debug}{tagpdf~not~loaded,~quitting}\endinput}
+    \end{macrocode}
+%</debug>
 % We map the internal module name \enquote{tag} to \enquote{tagpdf} in messages.
 %    \begin{macrocode}
-\prop_if_exist:NT \g_msg_module_name_prop
-  {
-    \prop_gput:Nnn \g_msg_module_name_prop { tag }{ tagpdf }
-  }
+%<*package>
+\prop_gput:Nnn \g_msg_module_name_prop { tag }{ tagpdf }
+%</package>
 %    \end{macrocode}
+% Debug mode has its special mapping:
+%    \begin{macrocode}
+%<*debug>
+\prop_gput:Nnn \g_msg_module_type_prop { tag / debug} {}
+\prop_gput:Nnn \g_msg_module_name_prop { tag / debug }{tagpdf~DEBUG}
+%</debug>
+%    \end{macrocode}
 %\section{Package options}
 % There are only two options to switch for luatex between generic and luamode,
 % TODO try to get rid of them.
 %    \begin{macrocode}
+%<*package>
 \bool_new:N\g_@@_mode_lua_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 }
@@ -105,10 +171,6 @@
 % \begin{macro}{\ref_value:nnn}
 % This allows to locally set a default value if the label or the attribute
 % doesn't exist.
-% See issue \#4 in Accessible-xref.
-% \begin{syntax}
-% \cs{ref_value:nnn}\Arg{label}\Arg{attribute}\Arg{Fallback default}
-% \end{syntax}
 %    \begin{macrocode}
  \cs_if_exist:NF \ref_value:nnn
    {
@@ -180,7 +242,8 @@
 %    \g_@@_active_space_bool,
 %    \g_@@_active_mc_bool,
 %    \g_@@_active_tree_bool,
-%    \g_@@_active_struct_bool
+%    \g_@@_active_struct_bool,
+%    \g_@@_active_struct_dest_bool
 %  }
 % These booleans should help to control the global behaviour of tagpdf.
 % Ideally it should more or less do nothing if all are false.
@@ -190,6 +253,8 @@
 % commands, the struct-boolean activates the storing of the structure data.
 % In a normal document all should be active, the split is only there for
 % debugging purpose.
+% Structure destination will be activated automatically if pdf version 2.0 is detected,
+% but with the boolean struct-dest-boolean one can suppress them.
 % Also we assume currently that they are set only at begin document. But
 % if some control passing over groups are needed they could be perhaps
 % used in a document too.
@@ -199,6 +264,8 @@
 \bool_new:N \g_@@_active_mc_bool
 \bool_new:N \g_@@_active_tree_bool
 \bool_new:N \g_@@_active_struct_bool
+\bool_new:N \g_@@_active_struct_dest_bool
+\bool_gset_true:N \g_@@_active_struct_dest_bool
 %    \end{macrocode}
 % \end{variable}
 
@@ -369,11 +436,12 @@
 %
 % \begin{macro}
 %  {
-%    activate-space,
-%    activate-mc,
-%    activate-tree,
-%    activate-struct,
-%    activate-all,
+%    activate-space (setup-key),
+%    activate-mc (setup-key),
+%    activate-tree (setup-key),
+%    activate-struct (setup-key),
+%    activate-all (setup-key),
+%    no-struct-dest (setup-key)
 %  }
 %  Keys to (globally) activate tagging.
 %  |activate-space| activates the additional parsing needed for
@@ -380,6 +448,7 @@
 %  interword spaces. It is not documented, the parsing is currently
 %  implicitly activated by the known key |interwordspace|, as the code will
 %  perhaps move to some other place, now that it is better separated.
+%  |no-struct-dest| allows to suppress structure destinations.
 %    \begin{macrocode}
 \keys_define:nn { @@ / setup }
   {
@@ -388,10 +457,12 @@
     activate-tree   .bool_gset:N = \g_@@_active_tree_bool,
     activate-struct .bool_gset:N = \g_@@_active_struct_bool,
     activate-all    .meta:n =
-      {activate-mc,activate-tree,activate-struct},
+      {activate-mc={#1},activate-tree={#1},activate-struct={#1}},
+    activate-all  .default:n = true,
+    no-struct-dest .bool_gset_inverse:N = \g_@@_active_struct_dest_bool,
  %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{log}
+% \begin{macro}{log (setup-key)}
 % The |log| takes currently the values |none|, |v|, |vv|, |vvv|, |all|.
 % The description of the log levels is in tagpdf-checks.
 %    \begin{macrocode}
@@ -407,7 +478,7 @@
     log / all       .code:n = {\int_set:Nn \l_@@_loglevel_int { 10 }},
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{tagunmarked}
+% \begin{macro}{tagunmarked (setup-key)}
 % This key allows to set if (in luamode) unmarked text should be
 % marked up as artifact. The initial value is true.
 %    \begin{macrocode}
@@ -415,9 +486,9 @@
     tagunmarked     .initial:n  = true,
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{tabsorder}
-% This sets the tabsorder one a page. The values are |row|, |column|, |structure| (default)
-% or |none|. Currently this is set more or less globally. More finer controll can be
+% \begin{macro}{tabsorder (setup-key)}
+% This sets the tabsorder on a page. The values are |row|, |column|, |structure| (default)
+% or |none|. Currently this is set more or less globally. More finer control can be
 % added if needed.
 %    \begin{macrocode}
     tabsorder       .choice:,
@@ -452,6 +523,15 @@
    \RequirePackage {tagpdf-mc-code-generic} %
   }
 %</mcloading>
+%<*debug>
+\bool_if:NTF \g_@@_mode_lua_bool
+  {
+   \RequirePackage {tagpdf-debug-lua}
+  }
+  {
+   \RequirePackage {tagpdf-debug-generic} %
+  }
+%</debug>
 %    \end{macrocode}
 % \end{implementation}
 % \PrintIndex

Modified: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.ins	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.ins	2022-01-13 21:05:40 UTC (rev 61600)
@@ -2,7 +2,7 @@
 
 File: tagpdf.ins
 
-Copyright (C) 2019-2021 Ulrike Fischer
+Copyright (C) 2019-2022 Ulrike Fischer
 
 It may be distributed and/or modified under the conditions of the
 LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -34,7 +34,7 @@
 \let\MetaPrefix\relax
 \preamble
 
-Copyright (C) 2019-2021 Ulrike Fischer
+Copyright (C) 2019-2022 Ulrike Fischer
 
 It may be distributed and/or modified under the conditions of
 the LaTeX Project Public License (LPPL), either version 1.3c of
@@ -59,7 +59,6 @@
       {
         \from{tagpdf.dtx}{package}
         \from{tagpdf-checks.dtx}{package}
-        \from{tagpdf-user.dtx}{package}
         \from{tagpdf-mc-shared.dtx}{shared}
         \from{tagpdf.dtx}{mcloading}
         \from{tagpdf-tree.dtx}{package}
@@ -66,6 +65,7 @@
         \from{tagpdf-roles.dtx}{package}
         \from{tagpdf-struct.dtx}{package}%contains also the attr code.
         \from{tagpdf-space.dtx}{package}
+        \from{tagpdf-user.dtx}{package}
       }
   }
 
@@ -76,7 +76,27 @@
 \generate
   {\file{tagpdf-mc-code-lua.sty}{\from{tagpdf-mc-luacode.dtx}{luamode}}}
 
+% check later if the mc-code uses debug guards too.
+\generate
+  {\file{tagpdf-debug.sty}
+      {
+        \from{tagpdf.dtx}{debug}
+        \from{tagpdf-checks.dtx}{debug}
+        \from{tagpdf-user.dtx}{debug}
+        \from{tagpdf-mc-shared.dtx}{debug}
+        \from{tagpdf-tree.dtx}{debug}
+        \from{tagpdf-roles.dtx}{debug}
+        \from{tagpdf-struct.dtx}{debug}%
+        \from{tagpdf-space.dtx}{debug}
+      }
+  }
 
+\generate
+  {\file{tagpdf-debug-generic.sty}{\from{tagpdf-mc-generic.dtx}{debug}}}
+
+\generate
+  {\file{tagpdf-debug-lua.sty}{\from{tagpdf-mc-luacode.dtx}{debug}}}
+
 \def\MetaPrefix{-- }
 \def\defaultpostamble{%
   \MetaPrefix^^J%

Added: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-debug-generic.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-debug-generic.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-debug-generic.sty	2022-01-13 21:05:40 UTC (rev 61600)
@@ -0,0 +1,79 @@
+%%
+%% This is file `tagpdf-debug-generic.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tagpdf-mc-generic.dtx  (with options: `debug')
+%% 
+%% Copyright (C) 2019-2022 Ulrike Fischer
+%% 
+%% It may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License (LPPL), either version 1.3c of
+%% this license or (at your option) any later version.  The latest
+%% version of this license is in the file:
+%% 
+%%    https://www.latex-project.org/lppl.txt
+%% 
+%% This file is part of the "tagpdf bundle" (The Work in LPPL)
+%% and all files in that bundle must be distributed together.
+%% 
+%% File: tagpdf-mc.dtx
+\ProvidesExplPackage {tagpdf-debug-generic} {2022-01-13} {0.93}
+ {part of tagpdf - debugging code related to marking chunks - generic mode}
+\cs_set_protected:Npn \tag_mc_begin:n #1 %#1 keyval
+  {
+    \__tag_check_if_active_mc:TF
+      {
+        \__tag_debug_mc_begin_insert:n { #1 }
+        \group_begin: %hm
+        \__tag_check_mc_if_nested:
+        \bool_gset_true:N \g__tag_in_mc_bool
+        \keys_set:nn { __tag / mc } {#1}
+        \bool_if:NTF \l__tag_mc_artifact_bool
+          { %handle artifact
+            \__tag_mc_handle_artifact:N \l__tag_mc_artifact_type_tl
+            \exp_args:NV
+            \__tag_mc_artifact_begin_marks:n \l__tag_mc_artifact_type_tl
+          }
+          { %handle mcid type
+            \__tag_check_mc_tag:N  \l__tag_mc_key_tag_tl
+            \__tag_mc_handle_mcid:VV
+               \l__tag_mc_key_tag_tl
+               \l__tag_mc_key_properties_tl
+            \__tag_mc_begin_marks:oo{\l__tag_mc_key_tag_tl}{\l__tag_mc_key_label_tl}
+            \tl_if_empty:NF {\l__tag_mc_key_label_tl}
+              {
+                \exp_args:NV
+                \__tag_mc_handle_mc_label:n \l__tag_mc_key_label_tl
+              }
+            \bool_if:NF \l__tag_mc_key_stash_bool
+              {
+                \__tag_mc_handle_stash:x { \int_use:N \c at g__tag_MCID_abs_int }
+              }
+          }
+        \group_end:
+      }
+      {
+        \__tag_debug_mc_begin_ignore:n { #1 }
+      }
+  }
+\cs_set_protected:Nn \tag_mc_end:
+  {
+    \__tag_check_if_active_mc:TF
+      {
+        \__tag_debug_mc_end_insert:
+        \__tag_check_mc_if_open:
+        \bool_gset_false:N \g__tag_in_mc_bool
+        \tl_gset:Nn  \g__tag_mc_key_tag_tl { }
+        \__tag_mc_emc:
+        \__tag_mc_end_marks:
+      }
+      {
+        \__tag_debug_mc_end_ignore:
+      }
+  }
+
+%% 
+%%
+%% End of file `tagpdf-debug-generic.sty'.


Property changes on: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-debug-generic.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-debug-lua.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-debug-lua.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-debug-lua.sty	2022-01-13 21:05:40 UTC (rev 61600)
@@ -0,0 +1,24 @@
+%%
+%% This is file `tagpdf-debug-lua.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tagpdf-mc-luacode.dtx  (with options: `debug')
+%% 
+%% Copyright (C) 2019-2022 Ulrike Fischer
+%% 
+%% It may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License (LPPL), either version 1.3c of
+%% this license or (at your option) any later version.  The latest
+%% version of this license is in the file:
+%% 
+%%    https://www.latex-project.org/lppl.txt
+%% 
+%% This file is part of the "tagpdf bundle" (The Work in LPPL)
+%% and all files in that bundle must be distributed together.
+%% 
+%% File: tagpdf-mc.dtx
+%% 
+%%
+%% End of file `tagpdf-debug-lua.sty'.


Property changes on: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-debug-lua.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-debug.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-debug.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-debug.sty	2022-01-13 21:05:40 UTC (rev 61600)
@@ -0,0 +1,235 @@
+%%
+%% This is file `tagpdf-debug.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tagpdf.dtx  (with options: `debug')
+%% tagpdf-checks.dtx  (with options: `debug')
+%% tagpdf-user.dtx  (with options: `debug')
+%% tagpdf-mc-shared.dtx  (with options: `debug')
+%% tagpdf-tree.dtx  (with options: `debug')
+%% tagpdf-roles.dtx  (with options: `debug')
+%% tagpdf-struct.dtx  (with options: `debug')
+%% tagpdf-space.dtx  (with options: `debug')
+%% 
+%% Copyright (C) 2019-2022 Ulrike Fischer
+%% 
+%% It may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License (LPPL), either version 1.3c of
+%% this license or (at your option) any later version.  The latest
+%% version of this license is in the file:
+%% 
+%%    https://www.latex-project.org/lppl.txt
+%% 
+%% This file is part of the "tagpdf bundle" (The Work in LPPL)
+%% and all files in that bundle must be distributed together.
+%% 
+%% File: tagpdf.dtx
+\ProvidesExplPackage {tagpdf-debug} {2022-01-13} {0.93}
+  { debug code for tagpdf }
+\@ifpackageloaded{tagpdf}{}{\PackageWarning{tagpdf-debug}{tagpdf~not~loaded,~quitting}\endinput}
+    \end{macrocode}
+\prop_gput:Nnn \g_msg_module_type_prop { tag / debug} {}
+\prop_gput:Nnn \g_msg_module_name_prop { tag / debug }{tagpdf~DEBUG}
+\bool_if:NTF \g__tag_mode_lua_bool
+  {
+   \RequirePackage {tagpdf-debug-lua}
+  }
+  {
+   \RequirePackage {tagpdf-debug-generic} %
+  }
+%% File: tagpdf-checks.dtx
+\msg_new:nnn { tag / debug } {mc-begin} { MC~begin~#1~with~options:~\tl_to_str:n{#2}~[\msg_line_context:] }
+\msg_new:nnn { tag / debug } {mc-end}   { MC~end~#1~[\msg_line_context:] }
+
+\cs_new_protected:Npn \__tag_debug_mc_begin_insert:n #1
+ {
+   \int_compare:nNnT { \l__tag_loglevel_int } > {0}
+     {
+        \msg_note:nnnn { tag / debug } {mc-begin} {inserted} { #1 }
+     }
+ }
+\cs_new_protected:Npn \__tag_debug_mc_begin_ignore:n #1
+ {
+   \int_compare:nNnT { \l__tag_loglevel_int } > {0}
+     {
+        \msg_note:nnnn { tag / debug } {mc-begin } {ignored} { #1 }
+     }
+ }
+\cs_new_protected:Npn \__tag_debug_mc_end_insert:
+ {
+   \int_compare:nNnT { \l__tag_loglevel_int } > {0}
+     {
+        \msg_note:nnn { tag / debug } {mc-end} {inserted}
+     }
+ }
+\cs_new_protected:Npn \__tag_debug_mc_end_ignore:
+ {
+   \int_compare:nNnT { \l__tag_loglevel_int } > {0}
+     {
+        \msg_note:nnn { tag / debug } {mc-end } {ignored}
+     }
+ }
+\msg_new:nnn { tag / debug } {struct-begin}
+  {
+    Struct~begin~#1~with~options:~\tl_to_str:n{#2}~[\msg_line_context:]
+  }
+\msg_new:nnn { tag / debug } {struct-end}
+  {
+    Struct~end~#1~[\msg_line_context:]
+  }
+
+\cs_new_protected:Npn \__tag_debug_struct_begin_insert:n #1
+ {
+   \int_compare:nNnT { \l__tag_loglevel_int } > {0}
+     {
+        \msg_note:nnnn { tag / debug } {struct-begin} {inserted} { #1 }
+        \seq_log:N \g__tag_struct_tag_stack_seq
+     }
+ }
+\cs_new_protected:Npn \__tag_debug_struct_begin_ignore:n #1
+ {
+   \int_compare:nNnT { \l__tag_loglevel_int } > {0}
+     {
+        \msg_note:nnnn { tag / debug } {struct-begin } {ignored} { #1 }
+     }
+ }
+\cs_new_protected:Npn \__tag_debug_struct_end_insert:
+ {
+   \int_compare:nNnT { \l__tag_loglevel_int } > {0}
+     {
+        \msg_note:nnn { tag / debug } {struct-end} {inserted}
+        \seq_log:N \g__tag_struct_tag_stack_seq
+     }
+ }
+\cs_new_protected:Npn \__tag_debug_struct_end_ignore:
+ {
+   \int_compare:nNnT { \l__tag_loglevel_int } > {0}
+     {
+        \msg_note:nnn { tag / debug } {struct-end } {ignored}
+     }
+ }
+%% File: tagpdf-user.dtx
+
+
+%% File: tagpdf-mc.dtx
+
+%% File: tagpdf-tree.dtx
+%% File: tagpdf-roles.dtx
+%% File: tagpdf-struct.dtx
+\keys_define:nn { __tag / setup }
+  {
+    root-AF .code:n =
+     {
+        \pdf_object_if_exist:nTF {#1}
+          {
+            \__tag_struct_add_AF:en { 0 }{#1}
+            \__tag_prop_gput:cnx
+             { g__tag_struct_0_prop }
+             { AF }
+             {
+               [
+                 \tl_use:c
+                   { g__tag_struct_0_AF_tl }
+               ]
+             }
+          }
+          {
+
+          }
+      },
+  }
+\cs_set_protected:Npn \tag_struct_begin:n #1 %#1 key-val
+  {
+\__tag_check_if_active_struct:TF
+      {
+        \group_begin:
+        \int_gincr:N \c at g__tag_struct_abs_int
+        \__tag_prop_new:c  { g__tag_struct_\int_eval:n { \c at g__tag_struct_abs_int }_prop }
+        \__tag_new_output_prop_handler:n {\int_eval:n { \c at g__tag_struct_abs_int }}
+        \__tag_seq_new:c  { g__tag_struct_kids_\int_eval:n { \c at g__tag_struct_abs_int }_seq}
+        \exp_args:Ne
+          \pdf_object_new:nn
+            { __tag/struct/\int_eval:n { \c at g__tag_struct_abs_int } }
+            { dict }
+        \__tag_prop_gput:cno
+          { g__tag_struct_\int_eval:n { \c at g__tag_struct_abs_int }_prop }
+          { Type }
+          { /StructElem }
+        \keys_set:nn { __tag / struct} { #1 }
+        \__tag_check_structure_has_tag:n { \int_eval:n {\c at g__tag_struct_abs_int} }
+        \tl_if_empty:NF
+          \l__tag_struct_key_label_tl
+          {
+            \__tag_ref_label:en{tagpdfstruct-\l__tag_struct_key_label_tl}{struct}
+          }
+        %get the potential parent from the stack:
+        \seq_get:NNF
+          \g__tag_struct_stack_seq
+          \l__tag_struct_stack_parent_tmpa_tl
+          {
+            \msg_error:nn { tag } { struct-faulty-nesting }
+          }
+        \seq_gpush:NV \g__tag_struct_stack_seq        \c at g__tag_struct_abs_int
+        \seq_gpush:NV \g__tag_struct_tag_stack_seq    \g__tag_struct_tag_tl
+        \tl_gset:NV   \g__tag_struct_stack_current_tl \c at g__tag_struct_abs_int
+        %\seq_show:N   \g__tag_struct_stack_seq
+        \bool_if:NF
+          \l__tag_struct_elem_stash_bool
+          {%set the  parent
+            \__tag_prop_gput:cnx
+              { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
+              { P }
+              {
+                \pdf_object_ref:e { __tag/struct/\l__tag_struct_stack_parent_tmpa_tl }
+              }
+            %record this structure as kid:
+            %\tl_show:N \g__tag_struct_stack_current_tl
+            %\tl_show:N \l__tag_struct_stack_parent_tmpa_tl
+            \__tag_struct_kid_struct_gput_right:xx
+               { \l__tag_struct_stack_parent_tmpa_tl }
+               { \g__tag_struct_stack_current_tl }
+            %\prop_show:c { g__tag_struct_\g__tag_struct_stack_current_tl _prop }
+            %\seq_show:c {g__tag_struct_kids_\l__tag_struct_stack_parent_tmpa_tl _seq}
+          }
+        %\prop_show:c { g__tag_struct_\g__tag_struct_stack_current_tl _prop }
+        %\seq_show:c {g__tag_struct_kids_\l__tag_struct_stack_parent_tmpa_tl _seq}
+ \__tag_debug_struct_begin_insert:n { #1 }
+        \group_end:
+     }
+{ \__tag_debug_struct_begin_ignore:n { #1 }}
+  }
+\cs_set_protected:Nn \tag_struct_end:
+  { %take the current structure num from the stack:
+    %the objects are written later, lua mode hasn't all needed info yet
+    %\seq_show:N \g__tag_struct_stack_seq
+\__tag_check_if_active_struct:TF
+      {
+        \seq_gpop:NN   \g__tag_struct_tag_stack_seq \l__tag_tmpa_tl
+        \seq_gpop:NNTF \g__tag_struct_stack_seq \l__tag_tmpa_tl
+          {
+            \__tag_check_info_closing_struct:o { \g__tag_struct_stack_current_tl }
+          }
+          { \__tag_check_no_open_struct: }
+        % get the previous one, shouldn't be empty as the root should be there
+        \seq_get:NNTF \g__tag_struct_stack_seq \l__tag_tmpa_tl
+          {
+            \tl_gset:NV   \g__tag_struct_stack_current_tl \l__tag_tmpa_tl
+          }
+          {
+            \__tag_check_no_open_struct:
+          }
+       \seq_get:NNT \g__tag_struct_tag_stack_seq \l__tag_tmpa_tl
+          {
+            \tl_gset:NV \g__tag_struct_tag_tl \l__tag_tmpa_tl
+          }
+\__tag_debug_struct_end_insert:
+      }
+{\__tag_debug_struct_end_ignore:}
+  }
+
+%% File: tagpdf-space.dtx
+%% 
+%%
+%% End of file `tagpdf-debug.sty'.


Property changes on: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-debug.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def	2022-01-13 21:05:40 UTC (rev 61600)
@@ -6,7 +6,7 @@
 %%
 %% tagpdf-backend.dtx  (with options: `luatex')
 %% 
-%% Copyright (C) 2019-2021 Ulrike Fischer
+%% Copyright (C) 2019-2022 Ulrike Fischer
 %% 
 %% It may be distributed and/or modified under the conditions of
 %% the LaTeX Project Public License (LPPL), either version 1.3c of
@@ -19,7 +19,7 @@
 %% and all files in that bundle must be distributed together.
 %% 
 %% File: tagpdf-backend.dtx
-\ProvidesExplFile {tagpdf-luatex.def} {2021-08-27} {0.92}
+\ProvidesExplFile {tagpdf-luatex.def} {2022-01-13} {0.93}
   {tagpdf~driver~for~luatex}
 {
   \fontencoding{TU}\fontfamily{lmr}\fontseries{m}\fontshape{n}\fontsize{10pt}{10pt}\selectfont

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty	2022-01-13 21:05:40 UTC (rev 61600)
@@ -6,7 +6,7 @@
 %%
 %% tagpdf-mc-generic.dtx  (with options: `generic')
 %% 
-%% Copyright (C) 2019-2021 Ulrike Fischer
+%% Copyright (C) 2019-2022 Ulrike Fischer
 %% 
 %% It may be distributed and/or modified under the conditions of
 %% the LaTeX Project Public License (LPPL), either version 1.3c of
@@ -19,7 +19,7 @@
 %% and all files in that bundle must be distributed together.
 %% 
 %% File: tagpdf-mc.dtx
-\ProvidesExplPackage {tagpdf-mc-code-generic} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdf-mc-code-generic} {2022-01-13} {0.93}
  {part of tagpdf - code related to marking chunks - generic mode}
 \__tag_prop_new:N \g__tag_MCID_byabspage_prop
 

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty	2022-01-13 21:05:40 UTC (rev 61600)
@@ -6,7 +6,7 @@
 %%
 %% tagpdf-mc-luacode.dtx  (with options: `luamode')
 %% 
-%% Copyright (C) 2019-2021 Ulrike Fischer
+%% Copyright (C) 2019-2022 Ulrike Fischer
 %% 
 %% It may be distributed and/or modified under the conditions of
 %% the LaTeX Project Public License (LPPL), either version 1.3c of
@@ -19,8 +19,7 @@
 %% and all files in that bundle must be distributed together.
 %% 
 %% File: tagpdf-mc.dtx
-
-\ProvidesExplPackage {tagpdf-mc-code-lua} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdf-mc-code-lua} {2022-01-13} {0.93}
   {tagpdf - mc code only for the luamode }
 \hook_gput_code:nnn{begindocument}{tagpdf/mc}
   {

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua	2022-01-13 21:05:40 UTC (rev 61600)
@@ -6,7 +6,7 @@
 -- 
 --  tagpdf-backend.dtx  (with options: `lua')
 --  
---  Copyright (C) 2019-2021 Ulrike Fischer
+--  Copyright (C) 2019-2022 Ulrike Fischer
 --  
 --  It may be distributed and/or modified under the conditions of
 --  the LaTeX Project Public License (LPPL), either version 1.3c of
@@ -24,8 +24,8 @@
 
 local ProvidesLuaModule = {
     name          = "tagpdf",
-    version       = "0.92",       --TAGVERSION
-    date          = "2021-08-27", --TAGDATE
+    version       = "0.93",       --TAGVERSION
+    date          = "2022-01-13", --TAGDATE
     description   = "tagpdf lua code",
     license       = "The LATEX Project Public License 1.3c"
 }

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty	2022-01-13 21:05:40 UTC (rev 61600)
@@ -6,7 +6,6 @@
 %%
 %% tagpdf.dtx  (with options: `package')
 %% tagpdf-checks.dtx  (with options: `package')
-%% tagpdf-user.dtx  (with options: `package')
 %% tagpdf-mc-shared.dtx  (with options: `shared')
 %% tagpdf.dtx  (with options: `mcloading')
 %% tagpdf-tree.dtx  (with options: `package')
@@ -13,8 +12,9 @@
 %% tagpdf-roles.dtx  (with options: `package')
 %% tagpdf-struct.dtx  (with options: `package')
 %% tagpdf-space.dtx  (with options: `package')
+%% tagpdf-user.dtx  (with options: `package')
 %% 
-%% Copyright (C) 2019-2021 Ulrike Fischer
+%% Copyright (C) 2019-2022 Ulrike Fischer
 %% 
 %% It may be distributed and/or modified under the conditions of
 %% the LaTeX Project Public License (LPPL), either version 1.3c of
@@ -27,7 +27,7 @@
 %% and all files in that bundle must be distributed together.
 %% 
 %% File: tagpdf.dtx
-\ProvidesExplPackage {tagpdf} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdf} {2022-01-13} {0.93}
   { A package to experiment with pdf tagging }
 
 \bool_if:nF
@@ -49,10 +49,7 @@
        before~\string\documentclass
      }
   }
-\prop_if_exist:NT \g_msg_module_name_prop
-  {
-    \prop_gput:Nnn \g_msg_module_name_prop { tag }{ tagpdf }
-  }
+\prop_gput:Nnn \g_msg_module_name_prop { tag }{ tagpdf }
 \bool_new:N\g__tag_mode_lua_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 }
@@ -111,6 +108,8 @@
 \bool_new:N \g__tag_active_mc_bool
 \bool_new:N \g__tag_active_tree_bool
 \bool_new:N \g__tag_active_struct_bool
+\bool_new:N \g__tag_active_struct_dest_bool
+\bool_gset_true:N \g__tag_active_struct_dest_bool
 
 \bool_new:N \l__tag_active_mc_bool
 \bool_set_true:N \l__tag_active_mc_bool
@@ -190,7 +189,9 @@
     activate-tree   .bool_gset:N = \g__tag_active_tree_bool,
     activate-struct .bool_gset:N = \g__tag_active_struct_bool,
     activate-all    .meta:n =
-      {activate-mc,activate-tree,activate-struct},
+      {activate-mc={#1},activate-tree={#1},activate-struct={#1}},
+    activate-all  .default:n = true,
+    no-struct-dest .bool_gset_inverse:N = \g__tag_active_struct_dest_bool,
  %    \end{macrocode}
     log             .choice:,
     log / none      .code:n = {\int_set:Nn \l__tag_loglevel_int { 0 }},
@@ -221,7 +222,6 @@
     \file_input:n {tagpdf-luatex.def}
   }
 %% File: tagpdf-checks.dtx
-
 \msg_new:nnn { tag } {mc-nested} { nested~marked~content~found~-~mcid~#1 }
 \msg_new:nnn { tag } {mc-tag-missing} { required~tag~missing~-~mcid~#1 }
 \msg_new:nnn { tag } {mc-label-unknown}
@@ -490,401 +490,6 @@
     { \prg_return_true: }
     { \prg_return_false: }
  }
-%% File: tagpdf-user.dtx
-
-
-\NewDocumentCommand \tagpdfsetup { m }
-  {
-    \keys_set:nn { __tag / setup } { #1 }
-  }
-
-\NewDocumentCommand \tagmcbegin { m }
-  {
-    \tag_mc_begin:n {#1}%\ignorespaces
-  }
-
-\NewDocumentCommand \tagmcend {  }
-  {
-    %\if_mode_horizontal: \unskip \fi: %
-    \tag_mc_end:
-  }
-
-\NewDocumentCommand \tagmcuse { m }
-  {
-    \tag_mc_use:n {#1}
-  }
-
-
-\NewDocumentCommand \tagmcifinTF { m m }
-  {
-    \tag_mc_if_in:TF { #1 } { #2 }
-  }
-\NewDocumentCommand \tagstructbegin { m }
-  {
-    \tag_struct_begin:n {#1}
-  }
-
-\NewDocumentCommand \tagstructend {  }
-  {
-   \tag_struct_end:
-  }
-
-\NewDocumentCommand \tagstructuse { m }
-  {
-    \tag_struct_use:n {#1}
-  }
-\cs_set_eq:NN\tagpdfifluatexTF \sys_if_engine_luatex:TF
-\cs_set_eq:NN\tagpdfifluatexT  \sys_if_engine_luatex:T
-\cs_set_eq:NN\tagpdfifpdftexT  \sys_if_engine_pdftex:T
-\NewDocumentCommand\ShowTagging { m }
-  {
-    \keys_set:nn { __tag / show }{ #1}
-
-  }
-\keys_define:nn { __tag / show }
-  {
-    mc-data .code:n =
-      {
-        \sys_if_engine_luatex:T
-          {
-            \lua_now:e{ltx.__tag.trace.show_all_mc_data(#1,\__tag_get_mc_abs_cnt:,0)}
-          }
-      }
-    ,mc-data .default:n = 1
-  }
-
-\keys_define:nn { __tag / show }
-  { mc-current .code:n =
-     {
-       \bool_if:NTF \g__tag_mode_lua_bool
-         {
-           \sys_if_engine_luatex:T
-             {
-               \int_compare:nNnTF
-                 { -2147483647 }
-                  =
-                 {
-                   \lua_now:e
-                     {
-                        tex.print
-                         (tex.getattribute
-                           (luatexbase.attributes.g__tag_mc_cnt_attr))
-                     }
-                 }
-                 {
-                   \lua_now:e
-                     {
-                       ltx.__tag.trace.log
-                        (
-                          "mc-current:~no~MC~open,~current~abscnt
-                           =\__tag_get_mc_abs_cnt:"
-                          ,0
-                        )
-                       texio.write_nl("")
-                     }
-                 }
-                 {
-                   \lua_now:e
-                     {
-                       ltx.__tag.trace.log
-                        (
-                          "mc-current:~abscnt=\__tag_get_mc_abs_cnt:=="
-                           ..
-                           tex.getattribute(luatexbase.attributes.g__tag_mc_cnt_attr)
-                           ..
-                           "~=>tag="
-                           ..
-                           tostring
-                             (ltx.__tag.func.get_tag_from
-                               (tex.getattribute
-                                 (luatexbase.attributes.g__tag_mc_type_attr)))
-                           ..
-                           "="
-                           ..
-                           tex.getattribute
-                            (luatexbase.attributes.g__tag_mc_type_attr)
-                           ,0
-                        )
-                       texio.write_nl("")
-                     }
-                 }
-             }
-         }
-         {
-          \msg_note:nn{ tag }{ mc-current }
-         }
-     }
-  }
-\keys_define:nn { __tag / show }
-  {
-    mc-marks .choice: ,
-    mc-marks / show .code:n =
-      {
-        \__tag_mc_get_marks:
-        \__tag_check_if_mc_in_galley:TF
-         {
-          \iow_term:n {Marks~from~this~page:~}
-         }
-         {
-           \iow_term:n {Marks~from~a~previous~page:~}
-         }
-        \seq_show:N \l__tag_mc_firstmarks_seq
-        \seq_show:N \l__tag_mc_botmarks_seq
-        \__tag_check_if_mc_tmb_missing:T
-         {
-           \iow_term:n {BDC~missing~on~this~page!}
-         }
-        \__tag_check_if_mc_tme_missing:T
-         {
-           \iow_term:n {EMC~missing~on~this~page!}
-         }
-      },
-    mc-marks / use .code:n =
-      {
-        \__tag_mc_get_marks:
-        \__tag_check_if_mc_in_galley:TF
-         { Marks~from~this~page:~}
-         { Marks~from~a~previous~page:~}
-        \seq_use:Nn \l__tag_mc_firstmarks_seq {,~}\quad
-        \seq_use:Nn \l__tag_mc_botmarks_seq {,~}\quad
-        \__tag_check_if_mc_tmb_missing:T
-         {
-           BDC~missing~
-         }
-        \__tag_check_if_mc_tme_missing:T
-         {
-           EMC~missing
-         }
-      },
-   mc-marks .default:n = show
-  }
-\keys_define:nn { __tag / show }
-  {
-     struct-stack .choice:
-    ,struct-stack / log .code:n = \seq_log:N \g__tag_struct_tag_stack_seq
-    ,struct-stack / show .code:n = \seq_show:N \g__tag_struct_tag_stack_seq
-    ,struct-stack .default:n = show
-  }
-\cs_new_protected:Npn \__tag_add_document_structure:n #1
- {
-   \hook_gput_code:nnn{begindocument}{tagpdf}{\tagstructbegin{tag=#1}}
-   \hook_gput_code:nnn{tagpdf/finish/before}{tagpdf}{\tagstructend}
- }
-\keys_define:nn { __tag / setup}
- {
-   activate   .code:n =
-    {
-      \keys_set:nn { __tag / setup }
-        { activate-mc,activate-tree,activate-struct }
-      \__tag_add_document_structure:n {#1}
-    },
-  activate .default:n = Document
- }
-\sys_if_engine_luatex:T
-  {
-    \NewDocumentCommand\pdffakespace { }
-     {
-       \__tag_fakespace:
-     }
-  }
-\bool_new:N \l__tag_para_bool
-\bool_new:N \l__tag_para_show_bool
-\int_new:N  \g__tag_para_begin_int
-\int_new:N  \g__tag_para_end_int
-\keys_define:nn { __tag / setup }
-  {
-    paratagging      .bool_set:N = \l__tag_para_bool,
-    paratagging-show .bool_set:N = \l__tag_para_show_bool,
-  }
-
-\AddToHook{para/begin}
-  {
-   \bool_if:NT \l__tag_para_bool
-     {
-       \int_gincr:N \g__tag_para_begin_int
-       \tag_struct_begin:n {tag=P}
-       \bool_if:NT \l__tag_para_show_bool
-        { \tag_mc_begin:n{artifact}
-          \llap{\color_select:n{red}\tiny\int_use:N\g__tag_para_begin_int\ }
-          \tag_mc_end:
-        }
-       \tag_mc_begin:n {tag=P}
-     }
-  }
-\AddToHook{para/end}
-  {
-    \bool_if:NT \l__tag_para_bool
-      {
-        \int_gincr:N \g__tag_para_end_int
-        \tag_mc_end:
-        \bool_if:NT \l__tag_para_show_bool
-          { \tag_mc_begin:n{artifact}
-            \rlap{\color_select:n{red}\tiny\ \int_use:N\g__tag_para_end_int}
-            \tag_mc_end:
-          }
-        \tag_struct_end:
-      }
-  }
-\AddToHook{enddocument/info}
-  {
-    \int_compare:nNnF {\g__tag_para_begin_int}={\g__tag_para_end_int}
-      {
-        \msg_error:nnxx
-          {tag}
-          {para-hook-count-wrong}
-          {\int_use:N\g__tag_para_begin_int}
-          {\int_use:N\g__tag_para_end_int}
-      }
-  }
-\AddToHook{begindocument/before}
- {
-   \bool_if:NF \g__tag_mode_lua_bool
-     {
-        \cs_if_exist:NT \@kernel at before@footins
-         {
-           \tl_put_right:Nn \@kernel at before@footins
-             { \__tag_add_missing_mcs_to_stream:Nn \footins {footnote} }
-           \tl_put_right:Nn \@kernel at before@cclv
-             {
-               \__tag_check_typeout_v:n {====>~In~\token_to_str:N \@makecol\c_space_tl\the\c at page}
-               \__tag_add_missing_mcs_to_stream:Nn \@cclv {main}
-             }
-           \tl_put_right:Nn \@mult at ptagging@hook
-             {
-               \__tag_check_typeout_v:n {====>~In~\string\page at sofar}
-               \process at cols\mult at gfirstbox
-                {
-                  \__tag_add_missing_mcs_to_stream:Nn \count@ {multicol}
-                }
-               \__tag_add_missing_mcs_to_stream:Nn \mult at rightbox {multicol}
-             }
-         }
-     }
-  }
-\newcommand\tagpdfparaOn {\bool_set_true:N \l__tag_para_bool}
-\newcommand\tagpdfparaOff{\bool_set_false:N \l__tag_para_bool}
-\NewDocumentCommand\tagpdfsuppressmarks{m}
-  {{\use:c{__tag_mc_disable_marks:} #1}}
-\cs_new_protected:Npn\__tag_hook_kernel_before_head:{}
-\cs_new_protected:Npn\__tag_hook_kernel_after_head:{}
-\cs_new_protected:Npn\__tag_hook_kernel_before_foot:{}
-\cs_new_protected:Npn\__tag_hook_kernel_after_foot:{}
-
-\AddToHook{begindocument}
- {
-  \cs_if_exist:NT \@kernel at before@head
-   {
-     \tl_put_right:Nn \@kernel at before@head {\__tag_hook_kernel_before_head:}
-     \tl_put_left:Nn  \@kernel at after@head  {\__tag_hook_kernel_after_head:}
-     \tl_put_right:Nn \@kernel at before@foot {\__tag_hook_kernel_before_foot:}
-     \tl_put_left:Nn  \@kernel at after@foot  {\__tag_hook_kernel_after_foot:}
-   }
- }
-
-\bool_new:N \g__tag_saved_in_mc_bool
-\cs_new_protected:Npn \__tag_exclude_headfoot_begin:
- {
-    \bool_set_false:N  \l__tag_para_bool
-    \bool_if:NTF \g__tag_mode_lua_bool
-     {
-      \tag_mc_end_push:
-     }
-     {
-       \bool_gset_eq:NN   \g__tag_saved_in_mc_bool \g__tag_in_mc_bool
-       \bool_gset_false:N \g__tag_in_mc_bool
-     }
-    \tag_mc_begin:n {artifact}
- }
-\cs_new_protected:Npn \__tag_exclude_headfoot_end:
- {
-    \tag_mc_end:
-    \bool_if:NTF \g__tag_mode_lua_bool
-     {
-      \tag_mc_begin_pop:n{}
-     }
-     {
-       \bool_gset_eq:NN \g__tag_in_mc_bool\g__tag_saved_in_mc_bool
-     }
- }
-
-\keys_define:nn { __tag / setup }
-  {
-    exclude-header-footer .choice:,
-    exclude-header-footer / true .code:n =
-     {
-       \cs_set_eq:NN \__tag_hook_kernel_before_head: \__tag_exclude_headfoot_begin:
-       \cs_set_eq:NN \__tag_hook_kernel_before_foot: \__tag_exclude_headfoot_begin:
-       \cs_set_eq:NN \__tag_hook_kernel_after_head:  \__tag_exclude_headfoot_end:
-       \cs_set_eq:NN \__tag_hook_kernel_after_foot:  \__tag_exclude_headfoot_end:
-     },
-    exclude-header-footer / false .code:n =
-     {
-       \cs_set_eq:NN \__tag_hook_kernel_before_head: \prg_do_nothing:
-       \cs_set_eq:NN \__tag_hook_kernel_before_foot: \prg_do_nothing:
-       \cs_set_eq:NN \__tag_hook_kernel_after_head:  \prg_do_nothing:
-       \cs_set_eq:NN \__tag_hook_kernel_after_foot:  \prg_do_nothing:
-     },
-   exclude-header-footer .default:n = true,
-   exclude-header-footer .initial:n = true
-  }
-
-\hook_gput_code:nnn
-  {pdfannot/link/URI/before}
-  {tagpdf}
-  {
-    \tag_mc_end_push:
-    \tag_struct_begin:n { tag=Link }
-    \tag_mc_begin:n { tag=Link }
-    \pdfannot_dict_put:nnx
-      { link/URI }
-      { StructParent }
-      { \tag_struct_parent_int: }
-  }
-
-\hook_gput_code:nnn
-  {pdfannot/link/URI/after}
-  {tagpdf}
-  {
-     \tag_struct_insert_annot:xx {\pdfannot_link_ref_last:}{\tag_struct_parent_int:}
-     \tag_mc_end:
-     \tag_struct_end:
-     \tag_mc_begin_pop:n{}
-  }
-
-\hook_gput_code:nnn
-  {pdfannot/link/GoTo/before}
-  {tagpdf}
-  {
-     \tag_mc_end_push:
-     \tag_struct_begin:n{tag=Link}
-     \tag_mc_begin:n{tag=Link}
-     \pdfannot_dict_put:nnx
-       { link/GoTo }
-       { StructParent }
-       { \tag_struct_parent_int: }
-  }
-
-\hook_gput_code:nnn
-  {pdfannot/link/GoTo/after}
-  {tagpdf}
-  {
-    \tag_struct_insert_annot:xx {\pdfannot_link_ref_last:}{\tag_struct_parent_int:}
-    \tag_mc_end:
-    \tag_struct_end:
-    \tag_mc_begin_pop:n{}
-
-  }
-
-\pdfannot_dict_put:nnn
- { link/URI }
- { Contents }
- { (url) }
-
-\pdfannot_dict_put:nnn
- { link/GoTo }
- { Contents }
- { (ref) }
-
 %% File: tagpdf-mc.dtx
 
 \newcounter { g__tag_MCID_abs_int }
@@ -1775,7 +1380,8 @@
     ParentTreeNextKey, % optional
     RoleMap,
     ClassMap,
-    Namespaces
+    Namespaces,
+    AF                 %pdf 2.0
   }
 
 \seq_const_from_clist:Nn \c__tag_struct_StructElem_entries_seq
@@ -2144,6 +1750,26 @@
           { <\l__tag_tmpa_str> }
       },
   }
+\cs_new_protected:Npn \__tag_struct_add_AF:nn #1 #2 % #1 struct num #2 object name
+  {
+     \tl_if_exist:cTF
+       {
+         g__tag_struct_#1_AF_tl
+       }
+       {
+         \tl_gput_right:cx
+           { g__tag_struct_#1_AF_tl }
+           {  ~ \pdf_object_ref:n {#2} }
+       }
+       {
+          \tl_new:c
+            { g__tag_struct_#1_AF_tl }
+          \tl_gset:cx
+            { g__tag_struct_#1_AF_tl }
+            { \pdf_object_ref:n {#2} }
+       }
+  }
+\cs_generate_variant:Nn \__tag_struct_add_AF:nn {en,ee}
 \keys_define:nn { __tag / struct }
  {
     AF .code:n        = % AF property
@@ -2150,10 +1776,16 @@
       {
         \pdf_object_if_exist:nTF {#1}
           {
+            \__tag_struct_add_AF:en { \int_eval:n {\c at g__tag_struct_abs_int} }{#1}
             \__tag_prop_gput:cnx
              { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
              { AF }
-             { \pdf_object_ref:n {#1} }
+             {
+               [
+                 \tl_use:c
+                   { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_AF_tl }
+               ]
+             }
           }
           {
 
@@ -2163,16 +1795,24 @@
      {
        \group_begin:
        \pdf_object_if_exist:eF {__tag/fileobj\int_use:N\c at g__tag_struct_abs_int}
-        {
-          \pdffile_embed_stream:nxx
-            {#1}
-            {tag-AFfile\int_use:N\c at g__tag_struct_abs_int.txt}
-            {__tag/fileobj\int_use:N\c at g__tag_struct_abs_int}
-        }
-       \__tag_prop_gput:cnx
-         { g__tag_struct_\int_use:N\c at g__tag_struct_abs_int _prop }
-         { AF }
-         { \pdf_object_ref:e {__tag/fileobj\int_use:N\c at g__tag_struct_abs_int } }
+         {
+           \pdffile_embed_stream:nxx
+             {#1}
+             {tag-AFfile\int_use:N\c at g__tag_struct_abs_int.txt}
+             {__tag/fileobj\int_use:N\c at g__tag_struct_abs_int}
+           \__tag_struct_add_AF:ee
+             { \int_eval:n {\c at g__tag_struct_abs_int} }
+             { __tag/fileobj\int_use:N\c at g__tag_struct_abs_int }
+           \__tag_prop_gput:cnx
+             { g__tag_struct_\int_use:N\c at g__tag_struct_abs_int _prop }
+             { AF }
+             {
+               [
+                 \tl_use:c
+                  { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_AF_tl }
+               ]
+             }
+         }
        \group_end:
      }
    ,AFinline-o .code:n =
@@ -2184,17 +1824,47 @@
             {#1}
             {tag-AFfile\int_use:N\c at g__tag_struct_abs_int.txt}
             {__tag/fileobj\int_use:N\c at g__tag_struct_abs_int}
+          \__tag_struct_add_AF:ee
+             { \int_eval:n {\c at g__tag_struct_abs_int} }
+             { __tag/fileobj\int_use:N\c at g__tag_struct_abs_int }
+           \__tag_prop_gput:cnx
+             { g__tag_struct_\int_use:N\c at g__tag_struct_abs_int _prop }
+             { AF }
+             {
+               [
+                 \tl_use:c
+                  { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_AF_tl }
+               ]
+             }
         }
-       \__tag_prop_gput:cnx
-         { g__tag_struct_\int_use:N\c at g__tag_struct_abs_int _prop }
-         { AF }
-         { \pdf_object_ref:e {__tag/fileobj\int_use:N\c at g__tag_struct_abs_int } }
        \group_end:
      }
  }
+\keys_define:nn { __tag / setup }
+  {
+    root-AF .code:n =
+     {
+        \pdf_object_if_exist:nTF {#1}
+          {
+            \__tag_struct_add_AF:en { 0 }{#1}
+            \__tag_prop_gput:cnx
+             { g__tag_struct_0_prop }
+             { AF }
+             {
+               [
+                 \tl_use:c
+                   { g__tag_struct_0_AF_tl }
+               ]
+             }
+          }
+          {
+
+          }
+      },
+  }
 \cs_new_protected:Npn \tag_struct_begin:n #1 %#1 key-val
   {
-    \__tag_check_if_active_struct:T
+\__tag_check_if_active_struct:T
       {
         \group_begin:
         \int_gincr:N \c at g__tag_struct_abs_int
@@ -2250,12 +1920,11 @@
         \group_end:
      }
   }
-
 \cs_new_protected:Nn \tag_struct_end:
   { %take the current structure num from the stack:
     %the objects are written later, lua mode hasn't all needed info yet
     %\seq_show:N \g__tag_struct_stack_seq
-    \__tag_check_if_active_struct:T
+\__tag_check_if_active_struct:T
       {
         \seq_gpop:NN   \g__tag_struct_tag_stack_seq \l__tag_tmpa_tl
         \seq_gpop:NNTF \g__tag_struct_stack_seq \l__tag_tmpa_tl
@@ -2482,6 +2151,446 @@
         \group_end:
       }
   }
+%% File: tagpdf-user.dtx
+
+
+\NewDocumentCommand \tagpdfsetup { m }
+  {
+    \keys_set:nn { __tag / setup } { #1 }
+  }
+
+\NewDocumentCommand \tagmcbegin { m }
+  {
+    \tag_mc_begin:n {#1}%\ignorespaces
+  }
+
+\NewDocumentCommand \tagmcend {  }
+  {
+    %\if_mode_horizontal: \unskip \fi: %
+    \tag_mc_end:
+  }
+
+\NewDocumentCommand \tagmcuse { m }
+  {
+    \tag_mc_use:n {#1}
+  }
+
+
+\NewDocumentCommand \tagmcifinTF { m m }
+  {
+    \tag_mc_if_in:TF { #1 } { #2 }
+  }
+\NewDocumentCommand \tagstructbegin { m }
+  {
+    \tag_struct_begin:n {#1}
+  }
+
+\NewDocumentCommand \tagstructend {  }
+  {
+   \tag_struct_end:
+  }
+
+\NewDocumentCommand \tagstructuse { m }
+  {
+    \tag_struct_use:n {#1}
+  }
+\NewDocumentCommand\ShowTagging { m }
+  {
+    \keys_set:nn { __tag / show }{ #1}
+
+  }
+\keys_define:nn { __tag / show }
+  {
+    mc-data .code:n =
+      {
+        \sys_if_engine_luatex:T
+          {
+            \lua_now:e{ltx.__tag.trace.show_all_mc_data(#1,\__tag_get_mc_abs_cnt:,0)}
+          }
+      }
+    ,mc-data .default:n = 1
+  }
+
+\keys_define:nn { __tag / show }
+  { mc-current .code:n =
+     {
+       \bool_if:NTF \g__tag_mode_lua_bool
+         {
+           \sys_if_engine_luatex:T
+             {
+               \int_compare:nNnTF
+                 { -2147483647 }
+                  =
+                 {
+                   \lua_now:e
+                     {
+                        tex.print
+                         (tex.getattribute
+                           (luatexbase.attributes.g__tag_mc_cnt_attr))
+                     }
+                 }
+                 {
+                   \lua_now:e
+                     {
+                       ltx.__tag.trace.log
+                        (
+                          "mc-current:~no~MC~open,~current~abscnt
+                           =\__tag_get_mc_abs_cnt:"
+                          ,0
+                        )
+                       texio.write_nl("")
+                     }
+                 }
+                 {
+                   \lua_now:e
+                     {
+                       ltx.__tag.trace.log
+                        (
+                          "mc-current:~abscnt=\__tag_get_mc_abs_cnt:=="
+                           ..
+                           tex.getattribute(luatexbase.attributes.g__tag_mc_cnt_attr)
+                           ..
+                           "~=>tag="
+                           ..
+                           tostring
+                             (ltx.__tag.func.get_tag_from
+                               (tex.getattribute
+                                 (luatexbase.attributes.g__tag_mc_type_attr)))
+                           ..
+                           "="
+                           ..
+                           tex.getattribute
+                            (luatexbase.attributes.g__tag_mc_type_attr)
+                           ,0
+                        )
+                       texio.write_nl("")
+                     }
+                 }
+             }
+         }
+         {
+          \msg_note:nn{ tag }{ mc-current }
+         }
+     }
+  }
+\keys_define:nn { __tag / show }
+  {
+    mc-marks .choice: ,
+    mc-marks / show .code:n =
+      {
+        \__tag_mc_get_marks:
+        \__tag_check_if_mc_in_galley:TF
+         {
+          \iow_term:n {Marks~from~this~page:~}
+         }
+         {
+           \iow_term:n {Marks~from~a~previous~page:~}
+         }
+        \seq_show:N \l__tag_mc_firstmarks_seq
+        \seq_show:N \l__tag_mc_botmarks_seq
+        \__tag_check_if_mc_tmb_missing:T
+         {
+           \iow_term:n {BDC~missing~on~this~page!}
+         }
+        \__tag_check_if_mc_tme_missing:T
+         {
+           \iow_term:n {EMC~missing~on~this~page!}
+         }
+      },
+    mc-marks / use .code:n =
+      {
+        \__tag_mc_get_marks:
+        \__tag_check_if_mc_in_galley:TF
+         { Marks~from~this~page:~}
+         { Marks~from~a~previous~page:~}
+        \seq_use:Nn \l__tag_mc_firstmarks_seq {,~}\quad
+        \seq_use:Nn \l__tag_mc_botmarks_seq {,~}\quad
+        \__tag_check_if_mc_tmb_missing:T
+         {
+           BDC~missing~
+         }
+        \__tag_check_if_mc_tme_missing:T
+         {
+           EMC~missing
+         }
+      },
+   mc-marks .default:n = show
+  }
+\keys_define:nn { __tag / show }
+  {
+     struct-stack .choice:
+    ,struct-stack / log .code:n = \seq_log:N \g__tag_struct_tag_stack_seq
+    ,struct-stack / show .code:n = \seq_show:N \g__tag_struct_tag_stack_seq
+    ,struct-stack .default:n = show
+  }
+\cs_new_protected:Npn \__tag_add_document_structure:n #1
+ {
+   \hook_gput_code:nnn{begindocument}{tagpdf}{\tagstructbegin{tag=#1}}
+   \hook_gput_code:nnn{tagpdf/finish/before}{tagpdf}{\tagstructend}
+ }
+\keys_define:nn { __tag / setup}
+ {
+   activate   .code:n =
+    {
+      \keys_set:nn { __tag / setup }
+        { activate-mc,activate-tree,activate-struct }
+      \__tag_add_document_structure:n {#1}
+    },
+  activate .default:n = Document
+ }
+\AddToHook{begindocument/before}
+  {
+    \bool_lazy_all:nT
+      {
+        { \g__tag_active_struct_dest_bool }
+        { \g__tag_active_struct_bool }
+        { \cs_if_exist_p:N \pdf_activate_structure_destination: }
+        { ! \pdf_version_compare_p:Nn < {2.0} }
+      }
+      {
+        \tl_set:Nn \l_pdf_current_structure_destination_tl { __tag/struct/\g__tag_struct_stack_current_tl }
+        \pdf_activate_structure_destination:
+      }
+   }
+
+\sys_if_engine_luatex:T
+  {
+    \NewDocumentCommand\pdffakespace { }
+     {
+       \__tag_fakespace:
+     }
+  }
+\bool_new:N \l__tag_para_bool
+\bool_new:N \l__tag_para_show_bool
+\int_new:N  \g__tag_para_begin_int
+\int_new:N  \g__tag_para_end_int
+\keys_define:nn { __tag / setup }
+  {
+    paratagging      .bool_set:N = \l__tag_para_bool,
+    paratagging-show .bool_set:N = \l__tag_para_show_bool,
+  }
+
+\AddToHook{para/begin}
+  {
+   \bool_if:NT \l__tag_para_bool
+     {
+       \int_gincr:N \g__tag_para_begin_int
+       \tag_struct_begin:n {tag=P}
+       \bool_if:NT \l__tag_para_show_bool
+        { \tag_mc_begin:n{artifact}
+          \llap{\color_select:n{red}\tiny\int_use:N\g__tag_para_begin_int\ }
+          \tag_mc_end:
+        }
+       \tag_mc_begin:n {tag=P}
+     }
+  }
+\AddToHook{para/end}
+  {
+    \bool_if:NT \l__tag_para_bool
+      {
+        \int_gincr:N \g__tag_para_end_int
+        \tag_mc_end:
+        \bool_if:NT \l__tag_para_show_bool
+          { \tag_mc_begin:n{artifact}
+            \rlap{\color_select:n{red}\tiny\ \int_use:N\g__tag_para_end_int}
+            \tag_mc_end:
+          }
+        \tag_struct_end:
+      }
+  }
+\AddToHook{enddocument/info}
+  {
+    \int_compare:nNnF {\g__tag_para_begin_int}={\g__tag_para_end_int}
+      {
+        \msg_error:nnxx
+          {tag}
+          {para-hook-count-wrong}
+          {\int_use:N\g__tag_para_begin_int}
+          {\int_use:N\g__tag_para_end_int}
+      }
+  }
+\AddToHook{begindocument/before}
+ {
+   \bool_if:NF \g__tag_mode_lua_bool
+     {
+        \cs_if_exist:NT \@kernel at before@footins
+         {
+           \tl_put_right:Nn \@kernel at before@footins
+             { \__tag_add_missing_mcs_to_stream:Nn \footins {footnote} }
+           \tl_put_right:Nn \@kernel at before@cclv
+             {
+               \__tag_check_typeout_v:n {====>~In~\token_to_str:N \@makecol\c_space_tl\the\c at page}
+               \__tag_add_missing_mcs_to_stream:Nn \@cclv {main}
+             }
+           \tl_put_right:Nn \@mult at ptagging@hook
+             {
+               \__tag_check_typeout_v:n {====>~In~\string\page at sofar}
+               \process at cols\mult at firstbox
+                {
+                  \__tag_add_missing_mcs_to_stream:Nn \count@ {multicol}
+                }
+               \__tag_add_missing_mcs_to_stream:Nn \mult at rightbox {multicol}
+             }
+         }
+     }
+  }
+\newcommand\tagpdfparaOn {\bool_set_true:N \l__tag_para_bool}
+\newcommand\tagpdfparaOff{\bool_set_false:N \l__tag_para_bool}
+\NewDocumentCommand\tagpdfsuppressmarks{m}
+  {{\use:c{__tag_mc_disable_marks:} #1}}
+\cs_new_protected:Npn\__tag_hook_kernel_before_head:{}
+\cs_new_protected:Npn\__tag_hook_kernel_after_head:{}
+\cs_new_protected:Npn\__tag_hook_kernel_before_foot:{}
+\cs_new_protected:Npn\__tag_hook_kernel_after_foot:{}
+
+\AddToHook{begindocument}
+ {
+  \cs_if_exist:NT \@kernel at before@head
+   {
+     \tl_put_right:Nn \@kernel at before@head {\__tag_hook_kernel_before_head:}
+     \tl_put_left:Nn  \@kernel at after@head  {\__tag_hook_kernel_after_head:}
+     \tl_put_right:Nn \@kernel at before@foot {\__tag_hook_kernel_before_foot:}
+     \tl_put_left:Nn  \@kernel at after@foot  {\__tag_hook_kernel_after_foot:}
+   }
+ }
+
+\bool_new:N \g__tag_saved_in_mc_bool
+\cs_new_protected:Npn \__tag_exclude_headfoot_begin:
+ {
+    \bool_set_false:N  \l__tag_para_bool
+    \bool_if:NTF \g__tag_mode_lua_bool
+     {
+      \tag_mc_end_push:
+     }
+     {
+       \bool_gset_eq:NN   \g__tag_saved_in_mc_bool \g__tag_in_mc_bool
+       \bool_gset_false:N \g__tag_in_mc_bool
+     }
+    \tag_mc_begin:n {artifact}
+ }
+\cs_new_protected:Npn \__tag_exclude_headfoot_end:
+ {
+    \tag_mc_end:
+    \bool_if:NTF \g__tag_mode_lua_bool
+     {
+      \tag_mc_begin_pop:n{}
+     }
+     {
+       \bool_gset_eq:NN \g__tag_in_mc_bool\g__tag_saved_in_mc_bool
+     }
+ }
+\__tag_attr_new_entry:nn {__tag/attr/pagination}{/O/Artifact/Type/Pagination}
+\cs_new_protected:Npn \__tag_exclude_struct_headfoot_begin:n #1
+ {
+    \bool_set_false:N  \l__tag_para_bool
+    \bool_if:NTF \g__tag_mode_lua_bool
+     {
+      \tag_mc_end_push:
+     }
+     {
+       \bool_gset_eq:NN   \g__tag_saved_in_mc_bool \g__tag_in_mc_bool
+       \bool_gset_false:N \g__tag_in_mc_bool
+     }
+    \tag_struct_begin:n{tag=Artifact,attribute-class=__tag/attr/#1}
+    \tag_mc_begin:n {artifact=#1}
+ }
+
+\cs_new_protected:Npn \__tag_exclude_struct_headfoot_end:
+ {
+    \tag_mc_end:
+    \tag_struct_end:
+    \bool_if:NTF \g__tag_mode_lua_bool
+     {
+      \tag_mc_begin_pop:n{}
+     }
+     {
+       \bool_gset_eq:NN \g__tag_in_mc_bool\g__tag_saved_in_mc_bool
+     }
+ }
+\keys_define:nn { __tag / setup }
+  {
+    exclude-header-footer .choice:,
+    exclude-header-footer / true .code:n =
+     {
+       \cs_set_eq:NN \__tag_hook_kernel_before_head: \__tag_exclude_headfoot_begin:
+       \cs_set_eq:NN \__tag_hook_kernel_before_foot: \__tag_exclude_headfoot_begin:
+       \cs_set_eq:NN \__tag_hook_kernel_after_head:  \__tag_exclude_headfoot_end:
+       \cs_set_eq:NN \__tag_hook_kernel_after_foot:  \__tag_exclude_headfoot_end:
+     },
+    exclude-header-footer / pagination .code:n =
+     {
+       \cs_set:Nn \__tag_hook_kernel_before_head: { \__tag_exclude_struct_headfoot_begin:n {pagination} }
+       \cs_set:Nn \__tag_hook_kernel_before_foot: { \__tag_exclude_struct_headfoot_begin:n {pagination} }
+       \cs_set_eq:NN \__tag_hook_kernel_after_head:  \__tag_exclude_struct_headfoot_end:
+       \cs_set_eq:NN \__tag_hook_kernel_after_foot:  \__tag_exclude_struct_headfoot_end:
+     },
+    exclude-header-footer / false .code:n =
+     {
+       \cs_set_eq:NN \__tag_hook_kernel_before_head: \prg_do_nothing:
+       \cs_set_eq:NN \__tag_hook_kernel_before_foot: \prg_do_nothing:
+       \cs_set_eq:NN \__tag_hook_kernel_after_head:  \prg_do_nothing:
+       \cs_set_eq:NN \__tag_hook_kernel_after_foot:  \prg_do_nothing:
+     },
+   exclude-header-footer .default:n = true,
+   exclude-header-footer .initial:n = true
+  }
+\hook_gput_code:nnn
+  {pdfannot/link/URI/before}
+  {tagpdf}
+  {
+    \tag_mc_end_push:
+    \tag_struct_begin:n { tag=Link }
+    \tag_mc_begin:n { tag=Link }
+    \pdfannot_dict_put:nnx
+      { link/URI }
+      { StructParent }
+      { \tag_struct_parent_int: }
+  }
+
+\hook_gput_code:nnn
+  {pdfannot/link/URI/after}
+  {tagpdf}
+  {
+     \tag_struct_insert_annot:xx {\pdfannot_link_ref_last:}{\tag_struct_parent_int:}
+     \tag_mc_end:
+     \tag_struct_end:
+     \tag_mc_begin_pop:n{}
+  }
+
+\hook_gput_code:nnn
+  {pdfannot/link/GoTo/before}
+  {tagpdf}
+  {
+     \tag_mc_end_push:
+     \tag_struct_begin:n{tag=Link}
+     \tag_mc_begin:n{tag=Link}
+     \pdfannot_dict_put:nnx
+       { link/GoTo }
+       { StructParent }
+       { \tag_struct_parent_int: }
+  }
+
+\hook_gput_code:nnn
+  {pdfannot/link/GoTo/after}
+  {tagpdf}
+  {
+    \tag_struct_insert_annot:xx {\pdfannot_link_ref_last:}{\tag_struct_parent_int:}
+    \tag_mc_end:
+    \tag_struct_end:
+    \tag_mc_begin_pop:n{}
+
+  }
+
+\pdfannot_dict_put:nnn
+ { link/URI }
+ { Contents }
+ { (url) }
+
+\pdfannot_dict_put:nnn
+ { link/GoTo }
+ { Contents }
+ { (ref) }
+
 %% 
 %%
 %% End of file `tagpdf.sty'.

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdfdocu-patches.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdfdocu-patches.sty	2022-01-13 21:05:04 UTC (rev 61599)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdfdocu-patches.sty	2022-01-13 21:05:40 UTC (rev 61600)
@@ -1,55 +1,7 @@
 %\RequirePackage[enable-debug]{expl3}[2018/06/14]
-\ProvidesExplPackage {tagpdfdocu-patches} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdfdocu-patches} {2022-01-13} {0.93}
  {patches/commands for the tagpdf documentation}
 \RequirePackage{etoolbox}
-%%%%
-% header and footer (now needed as attributes are global again)
-%%%%
-%% patching \@oddfoot/\@oddhead is nonsense, that is redefined all the time.
-%% Using the scrlayer interfaces would probably work
-%% but we will need a core latex solution anyway
-%% so let's test it here and patch \@outputpage
-%% we also disable paratagging, not for the tagging but to avoid that the small
-%% numbers gives overfull vbox messages ...
-\bool_new:N \g__tag_docu_saved_in_mc_bool
-\patchcmd\@outputpage
- {\hb at xt@\textwidth{\@thehead}}
- {
-  \hb at xt@\textwidth
-   {
-    \bool_set_false:N \l__tag_para_bool
-    \bool_gset_eq:NN  \g__tag_docu_saved_in_mc_bool \g__tag_in_mc_bool
-    \bool_gset_false:N \g__tag_in_mc_bool
-    \hfil
-    \tag_mc_begin:n {artifact=pagination}
-    \tag_stop_group_begin:
-    \@thehead
-    \tag_stop_group_end:
-    \tag_mc_end:
-    \bool_gset_eq:NN \g__tag_in_mc_bool\g__tag_docu_saved_in_mc_bool
-    \hfil
-   }
- }
- {}{\fail}
-\patchcmd\@outputpage
- {\hb at xt@\textwidth{\@thefoot}}
- {
-  \hb at xt@\textwidth
-   {
-    \bool_set_false:N \l__tag_para_bool
-    \bool_gset_eq:NN   \g__tag_docu_saved_in_mc_bool \g__tag_in_mc_bool
-    \bool_gset_false:N \g__tag_in_mc_bool
-    \hfil
-    \tag_mc_begin:n {artifact=pagination}
-    \tag_stop_group_begin:
-    \@thefoot
-    \tag_stop_group_end:
-    \tag_mc_end:
-    \bool_gset_eq:NN \g__tag_in_mc_bool\g__tag_docu_saved_in_mc_bool
-    \hfil
-   }
- }
- {}{\fail}
 
 %%%%%
 % tableofcontents



More information about the tex-live-commits mailing list.