texlive[57857] Master/texmf-dist: tagpdf (23feb21)

commits+karl at tug.org commits+karl at tug.org
Tue Feb 23 23:24:07 CET 2021


Revision: 57857
          http://tug.org/svn/texlive?view=revision&revision=57857
Author:   karl
Date:     2021-02-23 23:24:07 +0100 (Tue, 23 Feb 2021)
Log Message:
-----------
tagpdf (23feb21)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/tagpdf/README.md
    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.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem-luatex.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem.tex
    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-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-koma.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.tex
    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-structure-luatex.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure.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.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-attr-code.sty
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty
    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-mc-code-shared.sty
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-roles-code.sty
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-space-code.sty
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-struct-code.sty
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-tree-code.sty
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.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-AF-file.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.tex
    trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute-luatex.pdf
    trunk/Master/texmf-dist/doc/latex/tagpdf/example-input-file.tex
    trunk/Master/texmf-dist/source/latex/tagpdf/
    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.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.dtx
    trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.ins
    trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-deprecated.def

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/README.md	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/README.md	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,6 +1,6 @@
 #tagpdf — A package to create tagged pdf
-Packageversion: 0.61 
-Packagedate: 2019/07/02
+Packageversion: 0.80 
+Packagedate: 2021/02/23
 Author: Ulrike Fischer
 
 ## License

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

Index: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.pdf	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.pdf	2021-02-23 22:24:07 UTC (rev 57857)

Property changes on: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.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-AF-file.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.tex	2021-02-23 22:24:07 UTC (rev 57857)
@@ -0,0 +1,63 @@
+% !Mode:: "TeX:DE:UTF-8:Main"
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{
+   pdfversion=1.7
+  ,lang=de-DE
+  ,uncompress}
+\documentclass{article}
+\usepackage{tagpdf}
+
+\tagpdfsetup{tabsorder=structure,
+             activate-all}
+\tagpdfifpdftexT
+ {
+  \usepackage[T1]{fontenc}
+ }
+
+\tagpdfifluatexT
+ {
+  \usepackage{fontspec}
+  \usepackage{unicode-math}
+  \usepackage{luacode}
+  \newfontface\zerowidthfont{freeserif}
+ }
+
+\usepackage{graphicx}
+\begin{filecontents}{example-input-file.tex}
+Additional info!
+\end{filecontents}
+
+\begin{document}
+\pagestyle{empty}
+
+\tagstructbegin{tag=Document}
+
+\ExplSyntaxOn
+
+\pdffile_embed_file:nnn{example-input-file.tex}{}{tag/AFtest}
+
+%change AFRelationship
+\pdfdict_put:nnn {l_pdffile/FileSpec} {AFRelationship}{/Supplement}
+
+\ExplSyntaxOff
+\def\testtext{Bär with teh shirt}
+\tagstructbegin{tag=P,AFinline-o=\testtext}
+  \tagmcbegin{tag=P}
+   Ein Satz ohne Umlaute.
+  \tagmcend
+\tagstructend
+
+\tagstructbegin{tag=P,AFinline=Duck}
+  \tagmcbegin{tag=P}
+   Ein Satz ohne Umlaute.
+  \tagmcend
+\tagstructend
+
+\tagstructbegin{tag=P,AF=tag/AFtest}
+  \tagmcbegin{tag=P}
+   Ein Satz ohne Umlaute.
+  \tagmcend
+\tagstructend
+
+\tagstructend
+\end{document} 
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-AF-file.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
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	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext.tex	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,22 +1,20 @@
 % !Mode:: "TeX:DE:UTF-8:Main"
-%\input{regression-test}
+
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{pdfversion=1.7,lang=de-DE}
+
 \documentclass{article}
+
 \usepackage{tagpdf}
 \tagpdfsetup{tabsorder=structure,
              uncompress,activate-all}
 \tagpdfifpdftexT
  {
-  %set language / can also be done with hyperref
-  \pdfcatalog{/Lang (de-DE)}
   \usepackage[T1]{fontenc}
-  \input glyphtounicode
-  \pdfgentounicode=1
  }
 
 \tagpdfifluatexT
  {
-  %set language / can also be done with hyperref
-  \pdfextension catalog{/Lang (de-DE)}
   \usepackage{fontspec}
   \usepackage{unicode-math}
   \usepackage{luacode}
@@ -34,7 +32,7 @@
 \tagstructbegin{tag=Document}
 
 %This isn't read by voice software
-Etwas unmarkierter Text. 
+Etwas unmarkierter Text.
 
 %This read ok by voice software
 \tagstructbegin{tag=P}
@@ -46,12 +44,12 @@
 %This read ok by  nvda, but adobe has difficulties with the umlauts
 \tagstructbegin{tag=P}
   \tagmcbegin{tag=P}
-   Grüße an die Welt und die öde Wüste. 
+   Grüße an die Welt und die öde Wüste.
   \tagmcend
 \tagstructend
 
-\newpage 
-% alttext is read, 
+\newpage
+% alttext is read,
 % actualtext copy & pasted
 \tagstructbegin{tag=P,alttext=Dies ist ein Text,actualtext=Copy}
   \tagmcbegin{tag=P}
@@ -59,7 +57,7 @@
   \tagmcend
 \tagstructend
 
-%alttext is read, 
+%alttext is read,
 %actualtext copy & pasted
 \tagstructbegin{tag=P}
  \tagmcbegin{tag=P,alttext=Dies ist ein zweiter Text,actualtext=Copy}
@@ -68,7 +66,7 @@
 \tagstructend
 
 
-%nvda: alttext of structure is read 
+%nvda: alttext of structure is read
 %adobe: alttext of inner mc is read
 % result of copy & paste of this page in adobe reader:
 % why twice??????
@@ -89,7 +87,7 @@
 % content is more or less ignored. This is not against the documentation:
 % Formula is explicitly describes as an "illustration", something with a content
 % which can not be read directly.
-% But it is a problem that nvda ignores it even with an alt text. 
+% But it is a problem that nvda ignores it even with an alt text.
 
 %test of Formula tag + alttext in the mc
 %pdflatex
@@ -96,7 +94,7 @@
 %nvda: content is ignored
 %adobe: reads the alt text but without {} and ()
 
-%luatex (unicode-math): 
+%luatex (unicode-math):
 % nvda: doesn't read
 %adobe: doesn't read  (warning "empty page")
 
@@ -142,8 +140,8 @@
  \tagmcend
 \tagstructend
 
-%pdftex 
-% sum is read as "pi" 
+%pdftex
+% sum is read as "pi"
 %luatex
 %adobe: almost nothing read (only 1 and =)
 %nvda: similar, obviously both have problems with the unicode math symbols

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

Index: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute-luatex.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute-luatex.pdf	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute-luatex.pdf	2021-02-23 22:24:07 UTC (rev 57857)

Property changes on: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute-luatex.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute.tex	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-attribute.tex	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,14 +1,16 @@
 % !Mode:: "TeX:DE:UTF-8:Main"
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{uncompress,lang=de_DE}
 \documentclass{scrartcl}
 \usepackage[english]{babel}
 \usepackage{tagpdf}
-\tagpdfsetup{activate-all,uncompress}
+\tagpdfsetup{activate-all}
 
-\ifluatex\else
-\pdfcatalog{/Lang (en-UK)}
-\pdfinfo {/Title (Title)}
-\fi
+\ExplSyntaxOn
+\pdfmanagement_add:nnn{Info}{Title}{(Title)}
+\ExplSyntaxOff
 
+
 \tagpdfsetup
 {
  newattribute = {TH-col} { <</Owner /Table /Scope /Column>> },

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

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem.tex	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem.tex	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,21 +1,21 @@
 % !Mode:: "TeX:DE:UTF-8:Main"
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{
+   pdfversion=1.7
+  ,lang=de-DE
+  ,uncompress}
 \documentclass{article}
 \usepackage{tagpdf}
+
 \tagpdfsetup{tabsorder=structure,
-             uncompress,activate-all}
+             activate-all}
 \tagpdfifpdftexT
  {
-  %set language / can also be done with hyperref
-  \pdfcatalog{/Lang (de-DE)}
   \usepackage[T1]{fontenc}
-  \input glyphtounicode
-  \pdfgentounicode=1
  }
 
 \tagpdfifluatexT
  {
-  %set language / can also be done with hyperref
-  \pdfextension catalog{/Lang (de-DE)}
   \usepackage{fontspec}
   \usepackage{unicode-math}
   \usepackage{luacode}
@@ -56,4 +56,4 @@
 \tagstructend
 
 \tagstructend
-\end{document}
\ No newline at end of file
+\end{document} 
\ No newline at end of file

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

Modified: 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	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.tex	2021-02-23 22:24:07 UTC (rev 57857)
@@ -3,9 +3,11 @@
 % !!!!!!!!!!!!!!!!!
 % 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 
+% 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}
@@ -30,7 +32,7 @@
             }
 \newsavebox\mybox
 
-\usepackage{lipsum}\textheight3cm
+\textheight3cm
 \usepackage{fancyhdr}
 \pagestyle{fancy}
 \fancyhf{}

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

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list.tex	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-list.tex	2021-02-23 22:24:07 UTC (rev 57857)
@@ -6,8 +6,10 @@
 %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. 
+% 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,lang=en-UK,uncompress}
 
 \documentclass{scrbook}
 \usepackage[english]{babel}
@@ -27,7 +29,6 @@
 
 \tagpdfsetup{tabsorder=structure,
              activate-all,
-             uncompress
              }
 
 \usepackage{lipsum}%\textheight3cm
@@ -36,7 +37,7 @@
 
 \makeatletter
 
-\newcommand\uftag at enit@format at preset[1]{%
+\newcommand\tag at enit@format at preset[1]{%
   \tagstructbegin{tag=LI}%
   \tagstructbegin{tag=Lbl}%
   \tagmcbegin{tag=Lbl}%
@@ -48,9 +49,9 @@
 \newcommand\meti{% end of \item
  \tagstructend %end of LBody
  \tagstructend %end of LI
-}  
+}
 
-\xpatchcmd\enit at preset{\@firstofone}{\uftag at enit@format at preset}{}{\fail}
+\xpatchcmd\enit at preset{\@firstofone}{\tag at enit@format at preset}{}{\fail}
 
 \setlist{
     before*=\tagstructbegin{tag=L},
@@ -64,12 +65,12 @@
    \tagstructbegin{tag=Lbl}%
    \tagmcbegin{tag=Lbl}%
    #1\tagmcend}}
-\makeatother   
+\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}   
-   
+\newcommand\PGAT{\tagmcend\tagstructend}
+
 \begin{document}
 %I don't want to handle pagestyles, so set everything to empty:
 \pagestyle{empty}\renewcommand\chapterpagestyle{empty}

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

Modified: 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-koma.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex	2021-02-23 22:24:07 UTC (rev 57857)
@@ -8,6 +8,9 @@
 
 %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}
 
@@ -15,15 +18,11 @@
 
 \tagpdfifpdftexT
  {
-  %set language / can also be done with hyperref
-  \pdfcatalog{/Lang (en-US)}
   \usepackage[T1]{fontenc}
  }
 
 \tagpdfifluatexT
  {
-  %set language / can also be done with hyperref
-  \pdfextension catalog{/Lang (en-US)}
   \usepackage{fontspec}
   \usepackage{luacode}
  }
@@ -31,10 +30,8 @@
 
 \tagpdfsetup{tabsorder=structure,
              activate-all,
-             uncompress
              }
 
-\usepackage{lipsum}%\textheight3cm
 
 %%%%%%%%%%%%%%%
 %Marking the toc entries
@@ -68,9 +65,9 @@
 
 
 \renewcommand{\addtocentrydefault}[3]{%
- \ifstr{#3}{}{}
+ \Ifstr{#3}{}{}
    {%\
-   \ifstr{#2}{}
+   \Ifstr{#2}{}
     {%
      \addcontentsline{toc}{#1}
       {%
@@ -151,7 +148,7 @@
     #4
     \tagmcend\tagstructend}%
  }
- 
+
 \ExplSyntaxOff
 \AfterTOCHead{\tagstructbegin{tag=TOC}}
 \AfterStartingTOC{\tagstructend} %end TOC

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

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.tex	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.tex	2021-02-23 22:24:07 UTC (rev 57857)
@@ -7,6 +7,8 @@
 % open problem: line ends are not copy&pasted as spaces.
 % see also pull request #1, branch fake-space
 
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{pdfversion=1.7,uncompress}
 \documentclass{book}
 
 \usepackage[ngerman]{babel} %to get some hyphenation
@@ -13,9 +15,8 @@
 \usepackage{tagpdf}
 \tagpdfsetup{tabsorder=structure,
              activate-all, %deactivate to see the difference
-             uncompress
              }
-\usepackage{lipsum}%
+
 \usepackage{fontspec}
 
 \prehyphenchar`\^^ad
@@ -36,5 +37,5 @@
    \tagmcend
   \tagstructend
 \tagstructend
-\end{document} 
+\end{document}
 

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	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-spaceglyph-listings.tex	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,4 +1,6 @@
 % !Mode:: "TeX:DE:UTF-8:Main"
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{uncompress,}
 \documentclass{article}
 \usepackage{amsmath}
 \usepackage[ngerman]{babel}
@@ -9,7 +11,7 @@
 \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-all,uncompress,interwordspace=on,show-spaces,log=v}
+\tagpdfsetup{activate-all,interwordspace=on,show-spaces,log=v}
 \begin{document}\pagestyle{empty}
 \tagstructbegin{tag=Document}
 \tagmcbegin{tag=P}
@@ -18,4 +20,4 @@
 \end{lstlisting}
 \tagmcend
 \tagstructend
-\end{document}
\ No newline at end of file
+\end{document} 
\ No newline at end of file

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

Modified: trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure.tex	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-structure.tex	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,4 +1,7 @@
 % !Mode:: "TeX:DE:UTF-8:Main"
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{pdfversion=1.7,uncompress}
+
 \documentclass{book}
 \usepackage[english,ngerman]{babel}
 \usepackage{tagpdf}
@@ -22,7 +25,6 @@
              }
 \newsavebox\mybox
 
-\usepackage{lipsum}%\textheight3cm
 \usepackage{fancyhdr}
 \pagestyle{fancy}
 \fancyhf{}

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	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.tex	2021-02-23 22:24:07 UTC (rev 57857)
@@ -2,6 +2,8 @@
 
 %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{lang=en-UK, uncompress}
 \documentclass{scrartcl}
 \usepackage[english]{babel}
 \usepackage{tagpdf}
@@ -8,13 +10,11 @@
 
 \tagpdfifpdftexT
  {
-  \pdfcatalog{/Lang (en-UK)}
   \usepackage[T1]{fontenc}
  }
 
 \tagpdfifluatexT
  {
-  \pdfextension catalog{/Lang (en-UK)}
   \usepackage{fontspec}
  }
 
@@ -22,7 +22,6 @@
     {
       tabsorder=structure,
       activate-all,
-      uncompress
     }
 \begin{document}
 \pagestyle{empty} %

Added: trunk/Master/texmf-dist/doc/latex/tagpdf/example-input-file.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tagpdf/example-input-file.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/example-input-file.tex	2021-02-23 22:24:07 UTC (rev 57857)
@@ -0,0 +1,5 @@
+%% LaTeX2e file `example-input-file.tex'
+%% generated by the `filecontents' environment
+%% from source `ex-AF-file' on 2021/02/23.
+%%
+Additional info!


Property changes on: trunk/Master/texmf-dist/doc/latex/tagpdf/example-input-file.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
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	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,10 +1,10 @@
 % !Mode:: "TeX:DE:UTF-8:Main"
 \makeatletter
-\def\UlrikeFischer at package@version{0.61}
-\def\UlrikeFischer at package@date{2019-07-02}
+\def\UlrikeFischer at package@version{0.80}
+\def\UlrikeFischer at package@date{2021-02-23}
 \makeatother
-\pdfvariable majorversion = 1
-\pdfvariable minorversion = 7
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{pdfversion=1.7,lang=en-UK}
 \documentclass[DIV=12,parskip=half-,bibliography=totoc]{scrartcl}
 \usepackage{scrlayer-scrpage}
 \usepackage{fontspec}
@@ -56,16 +56,14 @@
  %log=v
  %show-spaces
  }
-%metadata
-\pdfextension catalog{/Lang (en-UK)}
-
-\IfFileExists{pdfresources.sty}
-{
- \usepackage{pdfresources}
- \usepackage[customdriver=hluatex-experimental,
-             pdfdisplaydoctitle=true,pdfusetitle,hyperfootnotes=false,
+\usepackage{hyperxmp}
+ \usepackage[pdfdisplaydoctitle=true,hyperfootnotes=false,
             ]{hyperref}
-}{}
+ \hypersetup{
+  pdftitle={The \pkg{tagpdf} package, v\csname UlrikeFischer at package@version\endcsname},
+  pdfauthor=Ulrike Fischer,
+  pdfaconformance=a,
+  pdfuapart=1}
 %\usepackage[ocgcolorlinks]{ocgx2}
 \usepackage{ydoc-desc} %hm hyperref ist ein Problem ...
 \usepackage{tagpdfdocu-patches}
@@ -72,6 +70,35 @@
 \hypersetup{colorlinks,}
 
 \cfoot*{\leavevmode\tagmcbegin{artifact=pagination}\pagemark\tagmcend}
+\newcommand\PDF{PDF}
+
+\ExplSyntaxOn
+\newcounter{paracnt}
+\bool_new:N \l__tag_paratagging_bool
+\AddToHook{para/begin}
+  {
+   \stepcounter{paracnt}
+   \bool_if:NT \l__tag_paratagging_bool
+    {
+      \tagstructbegin{tag=P}\tagmcbegin{tag=P}
+      \llap{\color{red}\tiny\arabic{paracnt}\ }
+    }
+  }
+\AddToHook{para/end}
+  {
+    \bool_if:NT \l__tag_paratagging_bool
+    {
+     \rlap{\color{red}\tiny\ \arabic{paracnt}}
+     \tagmcend\tagstructend}
+  }
+\newcommand\parataggingON {\bool_set_true:N \l__tag_paratagging_bool}
+\newcommand\parataggingOff{\bool_set_false:N \l__tag_paratagging_bool}
+
+\ExplSyntaxOff
+
+\makeatletter
+\patchcmd\@oddfoot{\begingroup}{\begingroup\parataggingOff}{}{}
+\patchcmd\@oddhead{\begingroup}{\begingroup\parataggingOff}{}{}
 \begin{document}
 \tagstructbegin{tag=Document}
 
@@ -82,15 +109,20 @@
 \tagstructend
 
 \begin{tcolorbox}[colframe=red]
-\tagstructbegin{tag=Div}
+\tagstructbegin{tag=Div} %\booltrue{paratagging}
 \TagP^ This package is not meant for normal document production.
 
-\TagP You need a current expl3 version to use it, you even need the (experimental) \texttt{l3str-convert}.
+\TagP You need a very current \LaTeX{} format.
+      You need a very current L3 programming layer.
+      You need the new \LaTeX{} PDF management bundle.
 
 \TagP This package is incomplete, experimental and quite probably contains bugs.
+      At some time it will disappear when the code has been integrated into the \LaTeX{} format.
 
-\TagP You need some knowledge about \TeX, pdf and perhaps even lua to use it.
+\TagP This package can change in an incompatible way.
 
+\TagP You need some knowledge about \TeX, \PDF{} and perhaps even lua to use it.
+
 \medskip
 
 \TagP Issues, comments, suggestions should be added as issues to the github tracker:\TagPend
@@ -107,18 +139,38 @@
 \tableofcontents
 \end{NoHyper}
 
+\section{Preface to version 0.8}
+
+\parataggingON
+
+%\TagP^
+With this version one major step towards integration of the code into the \LaTeX{} has been done:
+The code now relies on the new \LaTeX{} PDF management. This management, which is for a testphase provided
+as an external package, \texttt{pdfmanagement-testphase},
+prepares the ground for better support for tagged PDF in \LaTeX{}.
+It is part of a larger project to automatically generate tagged PDF \url{https://www.latex-project.org/news/2020/11/30/tagged-pdf-FS-study/}
+%\TagPend
+
+While this is a major improvement---it will for example allow to use tagpdf with more engines as the new PDF management supports all major engines and allowed to add support for associated files---it also means that this version requires a special setup of the document and is incompatible with a number of packages,
+see the documentation of \texttt{pdfmanagement-testphase} for details.
+
+Another important step are the new hook management in \LaTeX: the newest development version has hooks for paragraphs which should at the end allow to tag many paragraphs automatically. The small red numbers in this section 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.
+
+
+\parataggingOff
+
 \section{Introduction}
 
 
-\TagP^ Since many year the creation of accessible pdf-files with \LaTeX\ which conform to the PDF/UA standard has been on the agenda of \TeX-meetings. Many people agree that this is important and Ross Moore has done quite some work on it. There is also a TUG-mailing list and a webpage \parencite{tugaccess} dedicated to this theme.
+\TagP^ Since many year the creation of accessible \PDF{}-files with \LaTeX\ which conform to the PDF/UA standard has been on the agenda of \TeX-meetings. Many people agree that this is important and Ross Moore has done quite some work on it. There is also a TUG-mailing list and a webpage \parencite{tugaccess} dedicated to this theme.
 
-\TagP But in my opinion missing are means to \emph{experiment} with tagging and accessibility. Means to try out, how difficult it is to tag some structures, means to try out, how much tagging is really needed (standards and validators don't need to be right \ldots), means to test what else is needed so that a pdf works e.g. with a screen reader. Without such experiments it is imho quite difficult to get a feeling about what has to be done, which kernel changes are needed, how packages should be adapted.
+\TagP But in my opinion missing are means to \emph{experiment} with tagging and accessibility. Means to try out, how difficult it is to tag some structures, means to try out, how much tagging is really needed (standards and validators don't need to be right \ldots), means to test what else is needed so that a \PDF{} works e.g. with a screen reader. Without such experiments it is imho quite difficult to get a feeling about what has to be done, which kernel changes are needed, how packages should be adapted.
 
-\TagP This package tries to close this gap by offering \emph{core} commands to tag a pdf.\footnote{In case you don't know what this means: there will be some explanations later on.}
+\TagP This package tries to close this gap by offering \emph{core} commands to tag a \PDF{}.\footnote{In case you don't know what this means: there will be some explanations later on.}
 
 \TagP My hope is that the knowledge gained by the use of this package will at the end allow to decide if and how code to do tagging should be part of the \LaTeX\ kernel.
 
-\TagP The package does not patch commands from other packages. It is also not an aim of the package to develop such patches. While at the end changes to various commands in many classes and packages will be needed to get tagged pdf files -- and the examples accompaigning the package try (or will try) to show various strategies -- these changes should in my opinion be done by the class, package and document writers themselves using a sensible API provided by the kernel and not by some external package that adds patches everywhere and would need constant maintenance -- one only need to look at packages like tex4ht or bidi or hyperref to see how difficult and sometimes fragile this is.
+\TagP The package does not patch commands from other packages. It is also not an aim of the package to develop such patches. While at the end changes to various commands in many classes and packages will be needed to get tagged \PDF{} files -- and the examples accompanying the package try (or will try) to show various strategies -- these changes should in my opinion be done by the class, package and document writers themselves using a sensible API provided by the kernel and not by some external package that adds patches everywhere and would need constant maintenance -- one only need to look at packages like tex4ht or bidi or hyperref to see how difficult and sometimes fragile this is.
 
 \TagP So this package deliberately concentrates on the basics -- and this already quite a lot, there are much more details involved as I expected when I started.
 
@@ -129,7 +181,7 @@
 
 \subsection{Tagging and accessibility}
 
-\TagP^ While the package is named \texttt{tagpdf} the goal is actually \emph{accessible} pdf-files. Tagging is \emph{one} requirement for accessibility but there are others. I will mention some later on in this documentation, and -- if sensible -- I will also try to add code, keys or tips for them.
+\TagP^ While the package is named \texttt{tagpdf} the goal is actually \emph{accessible} \PDF{}-files. Tagging is \emph{one} requirement for accessibility but there are others. I will mention some later on in this documentation, and -- if sensible -- I will also try to add code, keys or tips for them.
 
 \TagP So the name of the package is a bit wrong. As excuse I can only say that it is shorter and easier to pronounce.
 \TagPend
@@ -136,7 +188,7 @@
 
 \subsection{Engines and modes}
 
-\TagP^ The package works currently with pdflatex and lualatex.
+\TagP^ The package works currently with pdflatex and lualatex. First steps have been done to also enable support for xelatex and the latex-dvips-route; but this isn't yet much tested.
 
 \TagP The package has two modes: the \emph{generic mode} which should work in theory with every engine and the \emph{lua mode} which works only with lualatex.
 
@@ -143,7 +195,7 @@
 
 \TagP I implemented the generic mode first. Mostly because my tex skills are much better than my lua skills and I wanted to get the tex side right before starting to fight with attributes and node traversing.
 
-\TagP While the generic mode is not bad and I spent quite some time to get it working I nevertheless think that the lua mode is the future and the only one that will be usable for larger documents. pdf is a page orientated format and so the ability of luatex to manipulate pages and nodes after the \TeX-processing is really useful here. Also with luatex characters are normally already given as unicode. The main problem with luatex is how to insert \enquote{fake spaces} between words.%
+\TagP While the generic mode is not bad and I spent quite some time to get it working I nevertheless think that the lua mode is the future and the only one that will be usable for larger documents. \PDF{} is a page orientated format and so the ability of luatex to manipulate pages and nodes after the \TeX-processing is really useful here. Also with luatex characters are normally already given as unicode. The main problem with luatex is how to insert \enquote{fake spaces} between words.%
 \TagPend
 
 
@@ -150,19 +202,19 @@
 
 \subsection{References}
 
-\TagP^ My main reference was the free reference for pdf 1.7. \parencite{pdfreference}. This document is from 2006.
+\TagP^ My main reference was the free reference for \PDF{} 1.7. \parencite{pdfreference}. This document is from 2006.
 
-\TagP In the meantime pdf 2.0. has been released. I know that it contains also for accessibility relevant changes. As I got now the specification and luatex can set with \verb+\pdfmajorversion+ the version to 2.0 I will start to check to look into it too.%
+\TagP In the meantime \PDF{} 2.0. has been released. I know that it contains also for accessibility relevant changes. As I got now the specification and luatex can set with \verb+\pdfmajorversion+ the version to 2.0 I will start to check to look into it too.%
 \TagPend
 
 \subsection{Validation}
 
-\TagP^ pdf's created with the commands of this package must be validated:\TagPend
+\TagP^ \PDF{}'s created with the commands of this package must be validated:\TagPend
 
 
 \begin{itemize}
 \item
-\TagP^ One must check that the pdf is \emph{syntactically} correct. It is rather easy to create broken pdf: e.g. if a chunk is opened on one page but closed on the next page.
+\TagP^ One must check that the \PDF{} is \emph{syntactically} correct. It is rather easy to create broken \PDF{}: e.g. if a chunk is opened on one page but closed on the next page.
     \Pmeti
 \item
 \TagP^ One must check how good the requirements of the PDF/UA standard are followed \emph{formally}.
@@ -173,14 +225,14 @@
 
 \TagP^
 Syntax validation and formal standard validation can be done with preflight of the (non-free) adobe acrobat.
-It can also be done also with the free PDF Accessibility Checker (PAC~3) \parencite{pac3}.
+It can also be done also with the free \PDF{} Accessibility Checker (PAC~3) \parencite{pac3}.
 
 \TagP
 Syntax validation and formal standard validation can be done with preflight of the (non-free) adobe acrobat.
-It can also be done also with the free PDF Accessibility Checker (PAC~3) \parencite{pac3}.
+It can also be done also with the free \PDF{} Accessibility Checker (PAC~3) \parencite{pac3}.
 There is also the validator veraPDF \parencite{verapdf}. But I didn't try it yet and have no idea if it is useful here.
 
-\TagP Practical validation is naturally the more complicated part. It needs screen reader, users which actually knows how to handle them, can test documents and can report where a pdf has real accessibility problems.\TagPend
+\TagP Practical validation is naturally the more complicated part. It needs screen reader, users which actually knows how to handle them, can test documents and can report where a \PDF{} has real accessibility problems.\TagPend
 
 
 
@@ -197,7 +249,7 @@
 \TagP^ Feedback, contribuations and corrections are welcome!\TagPend
 \end{tcolorbox}
 
-\TagP^ All examples should use the tagpdfsetup key \PrintKeyName{uncompress} described in the next section so that uncompressed pdf are created and the internal objects and structures can be inspected and -- hopefully soon -- be compared by the l3build checks.%
+\TagP^ All examples should use the tagpdfsetup key \PrintKeyName{uncompress} described in the next section so that uncompressed \PDF{} are created and the internal objects and structures can be inspected and -- hopefully soon -- be compared by the l3build checks.%
 \TagPend
 
 
@@ -212,7 +264,7 @@
 \subsection{Changes in 0.5}
 \TagP^I added code to handle attributes and attribute classes, see section~\ref{sec:attributes} and corrected a small number of code errors.
 
-\TagP I added code to add \enquote{real} space glyphs to the pdf, see section \ref{sec:spacechars}.\TagPend
+\TagP I added code to add \enquote{real} space glyphs to the \PDF{}, see section \ref{sec:spacechars}.\TagPend
 
 
 \subsection{Changes in 0.6}
@@ -220,7 +272,7 @@
 \TagP^\textbf{Breaking change!} The attributes used in luamode to mark the MC-chunks are no longer set globally. I thought that global attribute would make it easier to tag, but it only leads to problem when e.g. header and footer are inserted. So from this version on the attributes are set locally and the effect of a \verb+\tagmcbegin+ ends with the current group. This means that in some cases more \verb+\tagmcbegin+ are needed and  this affected some of the examples, e.g. the patching commands for sections with KOMA. On the other side it means that quite often one can omit the \verb+\tagmcend+ command.\TagPend
 
 \subsection{Proof of concept: the tagging of the documentation itself}
-\TagP^With version 0.6 the documentation itself has been tagged. The tagging is in no way perfect. The validator from Adobe doesn'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 footnote 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 are probably simply wrong \ldots\TagPend
+\TagP^With version 0.6 the documentation itself has been tagged. The tagging is in no way perfect. The validator from Adobe doesn'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 footnote 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 are probably simply wrong \ldots\TagPend
 
 \TagP^But even if the documentation passed the tests of the validators:  as mentioned above passing a formal test doesn't mean that the content is really good and usable. I have a lot doubts that the code parts are really readable. The bibliography and the references must be improved. The user commands used for the tagging and also some of the patches used are rather crude. So there is lot space for improvement.\TagPend
 
@@ -238,6 +290,23 @@
 \item \TagP^dropped the compresslevel key  -- probably not needed\Pmeti
 \end{itemize}
 
+\subsection{Changes in version 0.8}
+
+
+\TagP^As a first step to include the code proper in the \LaTeX\ kernel the module name has changed from \texttt{uftag} to \texttt{tag}. The commands starting with \verb|\uftag| will stay valid for some time but then be deprecated.\TagPend
+
+\TagP^\textbf{Breaking change!} The argument of \texttt{newattribute} option should no longer add the dictionary bracket \verb+<<..>>+, they are added by the code.\TagPend
+
+
+\TagP^\textbf{Breaking change!} The package now requires the new PDF management as provided for now by the package \texttt{pdfmanagement-testphase}\TagPend
+
+\TagP^Support to add associated files to structures has been added with new keys \texttt{AF}, \texttt{AFinline} and \texttt{AFinline-o}.\TagPend
+
+\TagP^\textbf{Breaking change!} The support for other 8-bit input encodings has been removed.
+utf8 is now the required encoding. \TagPend
+
+\TagP^The keys |lang|, |ref| and |E| have been added for structures.\TagPend
+
 \section{Setup}
 
 \minisec{Activation needed!}
@@ -282,9 +351,6 @@
  \TagP^Allows to define new tag names, see section \ref{sec:new-tag} for a description.\Pmeti
 \item[\PrintKeyName{check-tags}]
  \TagP^Boolean, initially true. Activates some safety checks (but doesn't do very much currently. It will perhaps be merged with the log-level key).\Pmeti
-\item[\PrintKeyName{inputencoding}]
- \TagP^Some keys convert their value and so need to know the encoding of the file. The default encoding is utf8.  When using pdflatex you can switch to another encoding with this key. The value should be one of names allowed by \texttt{l3str}. There is no checking that the name is valid (I don't think that it sensible to use something else than utf8).
- \Pmeti
 \item[\PrintKeyName{interwordspace}]
  \TagP^Choice key, possible values are \PrintKeyName{true}/""\PrintKeyName{on} and \PrintKeyName{false}/\PrintKeyName{off}. The key activates/deactivates the insertion of space glyphs, see section~\ref{sec:spacechars}. In the luamode it only works if at least \PrintKeyName{activate-mc} has been used.\Pmeti
 \item[\PrintKeyName{log}]
@@ -298,7 +364,7 @@
 \item[\PrintKeyName{tagunmarked}]
  \TagP^Boolean,\marginnote{luamode} initially true. When this boolean is true, the lua code will try to mark everything that has not been marked yet as an artifact. The benefit is that one doesn't have to mark up every deco rule oneself. The danger is that it perhaps marks things that shouldn't be marked -- it hasn't been tested yet with complicated documents containing annotations etc. See also section~\ref{sec:lazy} for a discussion about automatic tagging.\Pmeti
 \item[\PrintKeyName{uncompress}]
- \TagP^Sets both the pdf compresslevel and the pdf objcompresslevel to 0 and so allows to inspect the pdf.\Pmeti
+ \TagP^Sets both the \PDF{} compresslevel and the \PDF{} objcompresslevel to 0 and so allows to inspect the \PDF{}.\Pmeti
 
 
 \end{description}
@@ -306,7 +372,7 @@
 
 \section{Tagging}
 
-\TagP^pdf is a page orientated graphic format. It simply puts ink and glyphs at various coordinates on a page. A simple stream of a page can look like this\footnote{The appendix contains some remarks about the syntax of a pdf file}:
+\TagP^pdf is a page orientated graphic format. It simply puts ink and glyphs at various coordinates on a page. A simple stream of a page can look like this\footnote{The appendix contains some remarks about the syntax of a \PDF{} file}:
 \TagPend
 
 \tagstructbegin{tag=Code}\tagmcbegin{tag=Code}
@@ -328,13 +394,13 @@
 
 \TagP^From this stream one can extract the characters and their placement on the page but not their semantic meaning  (the first line is actually a section heading, the last the page number). And while in the example the order is correct there is actually no guaranty that the stream contains the text in the order it should be read.
 
-\TagP Tagging means to enrich the pdf with information about the \emph{semantic} meaning and the \emph{reading order}. (Tagging can do more, one can also store all sorts of layout information like font properties and indentation with tags. But as I already wrote this package concentrates on the part of tagging that is needed to improve accessibility.)\TagPend
+\TagP Tagging means to enrich the \PDF{} with information about the \emph{semantic} meaning and the \emph{reading order}. (Tagging can do more, one can also store all sorts of layout information like font properties and indentation with tags. But as I already wrote this package concentrates on the part of tagging that is needed to improve accessibility.)\TagPend
 
 
 
 
 \subsection{Three tasks}
-\TagP^To tag a pdf three tasks must be  carried out:\TagPend
+\TagP^To tag a \PDF{} three tasks must be  carried out:\TagPend
 
 \begin{enumerate}
 \item
@@ -341,11 +407,11 @@
   \TagP^\textbf{The mark-content-task}:\marginnote{mc-task} The document must add \enquote{labels} to the page stream which allows to identify and reference the various chunks of text and other content.  This is the most difficult part of tagging -- both for the document writer but also for the package code. At first there can be quite many chunks as every one is a leaf node of the structure and so often a rather small unit.  At second the chunks must be defined page-wise -- and this is not easy when you don't know where the page breaks are. Also in a standard document a lot text is created automatically, e.g. the toc, references, citations, list numbers etc and it is not always easy to mark them correctly.\Pmeti
 
 \item
-  \TagP^\textbf{The structure-task}:\marginnote{struct-task}  The document must declare the structure. This means marking the start and end of semantically connected portions of the document (correctly nested as a tree). This too means some work for the document writer, but less than for the mc-task: at first quite often the mc-task and the structure-task can be combined, e.g. when you mark up a list number or a tabular cell or a section header; at second one doesn't have to worry about page breaks so quite often one can patch standard environments to declare the structure. On the other side a number of structures end in \LaTeX\ only implicitly -- e.g. an item ends at the next item, so getting the pdf structure right still means that additional mark up must be added.
+  \TagP^\textbf{The structure-task}:\marginnote{struct-task}  The document must declare the structure. This means marking the start and end of semantically connected portions of the document (correctly nested as a tree). This too means some work for the document writer, but less than for the mc-task: at first quite often the mc-task and the structure-task can be combined, e.g. when you mark up a list number or a tabular cell or a section header; at second one doesn't have to worry about page breaks so quite often one can patch standard environments to declare the structure. On the other side a number of structures end in \LaTeX\ only implicitly -- e.g. an item ends at the next item, so getting the \PDF{} structure right still means that additional mark up must be added.
   \Pmeti
 
 \item
- \TagP^\textbf{The tree management}:\marginnote{tree-task} At last the structure must be written into the pdf. For every structure an object of type \texttt{StructElem} must be  created and flushed with keys for the parents and the kids. A parenttree must be created to get a reference from the mc-chunks to the parent structure. A rolemap must be written. And a number of dictionary entries. All this is hopefully done automatically and correctly by the package \ldots.
+ \TagP^\textbf{The tree management}:\marginnote{tree-task} At last the structure must be written into the \PDF{}. For every structure an object of type \texttt{StructElem} must be  created and flushed with keys for the parents and the kids. A parenttree must be created to get a reference from the mc-chunks to the parent structure. A rolemap must be written. And a number of dictionary entries. All this is hopefully done automatically and correctly by the package \ldots.
  \Pmeti
 \end{enumerate}
 
@@ -404,7 +470,7 @@
 
 \subsection{Task 1: Marking the chunks: the mark-content-step}
 
-\TagP^To be able to refer to parts of the text in the structure, the text in the page stream must get \enquote{labels}. In the pdf reference they are called \enquote{marked content}. The three main variants needed here are:\TagPend
+\TagP^To be able to refer to parts of the text in the structure, the text in the page stream must get \enquote{labels}. In the \PDF{} reference they are called \enquote{marked content}. The three main variants needed here are:\TagPend
 
 \begin{description}
 \item[Artifacts] \TagP^They are marked with of a pair of keywords, \texttt{BMC} and \texttt{EMC} which surrounds the text. \texttt{BMC} has a single prefix argument, the fix tag name \texttt{/Artifact}. Artifacts should be used for irrelevant text and page content that should be ignored in the structure. Sadly it is often not possible to leave such text simply unmarked -- the accessibility tests in Acrobat and other validators complain.\TagPend
@@ -445,7 +511,7 @@
 
 \TagP^This integer is used to identify the chunk when building the structure tree. The chunks are numbered by page starting with 0. As the numbers are also used as an index in an array they shouldn't be \enquote{holes} in the numbering system
 %\footnote{
-(It is perhaps possible to handle a numbering scheme not starting by 0 and having holes, but it will enlarge the pdf as one would need dummy objects.).
+(It is perhaps possible to handle a numbering scheme not starting by 0 and having holes, but it will enlarge the \PDF{} as one would need dummy objects.).
 
 \TagP It is possible to add more entries to the property dictionary, e.g. a title, alternative text or a local language setting.\Pmeti
 \end{description}
@@ -464,7 +530,7 @@
 \TagP^This sounds easy. But there are quite a number of traps.\TagPend
 
 \begin{enumerate}[beginpenalty=10000]
-  \item \TagP^Pdf is a page oriented format. And this means that the start \texttt{BDC}/\texttt{BMC}  and the corresponding end \texttt{EMC} must be on the same page.
+  \item \TagP^\PDF{} is a page oriented format. And this means that the start \texttt{BDC}/\texttt{BMC}  and the corresponding end \texttt{EMC} must be on the same page.
   So marking e.g. a section title like in the following example won't always work as the literal before the section could end on the previous page:\TagPend
 
 \tagstructbegin{tag=Code}\tagmcbegin{tag=Code}
@@ -498,7 +564,7 @@
 
 
   \item
-  \TagP^Pdf is a page oriented format. And this means that the start and the end marker must be on the same page \ldots\ \emph{so what to do with normal paragraphs that split over pages??}. This question will be discussed in subsection~\ref{sec:splitpara}.\Pmeti
+  \TagP^\PDF{} is a page oriented format. And this means that the start and the end marker must be on the same page \ldots\ \emph{so what to do with normal paragraphs that split over pages??}. This question will be discussed in subsection~\ref{sec:splitpara}.\Pmeti
 \end{enumerate}
 
 \subsubsection{Generic mode versus lua mode in the mc-task}
@@ -508,7 +574,7 @@
 \TagP This means that quite a number of problems mentioned above are not relevant for the lua mode:\TagPend
 
 \begin{enumerate}
-\item \TagP^Pagebreaks between start and end of the marker are \emph{not} a problem. So you can mark a complete paragraph. If a pagebreak occur directly after an start marker or before an end marker this can lead to empty chunks in the pdf and so bloat up pdf a bit, but this is imho not really a problem (compared to the size increase by the rest of the tagging).\Pmeti
+\item \TagP^Pagebreaks between start and end of the marker are \emph{not} a problem. So you can mark a complete paragraph. If a pagebreak occur directly after an start marker or before an end marker this can lead to empty chunks in the \PDF{} and so bloat up \PDF{} a bit, but this is imho not really a problem (compared to the size increase by the rest of the tagging).\Pmeti
 \item \TagP^The commands don't insert literals directly and so affect line and page breaking much less.\Pmeti
 \item \TagP^The numbering of the MCID are done at shipout, so no label/ref system is needed.\Pmeti
 \item \TagP^The code can do some marking automatically. Currently everything that has not been marked up by the document is marked as artifact.\Pmeti
@@ -521,10 +587,10 @@
 
 \ExplSyntaxOn
 \DescribeMacro\tagmcbegin{<key-val-list>}
-\DescribeMacro\uftag_mc_begin:n{<key-val-list>}
+\DescribeMacro\tag_mc_begin:n{<key-val-list>}
 \ExplSyntaxOff
 
-\TagP^These commands insert the begin of the marked content code in the pdf. They don't start a paragraph. \emph{They don't start a group}. The user command additionally issues an \verb+\ignorespaces+ to suppress spaces after itself.
+\TagP^These commands insert the begin of the marked content code in the \PDF{}. They don't start a paragraph. \emph{They don't start a group}. The user command additionally issues an \verb+\ignorespaces+ to suppress spaces after itself.
 Such markers should not be nested. The command will warn you if this happens.
 
 
@@ -531,7 +597,7 @@
 \TagP The key-val list understands the following keys:\TagPend
 \begin{description}
   \item[\PrintKeyName{tag}]
-  \TagP^This is required, unless you use the \PrintKeyName{artifact} key. The value of the key is normally one of the standard type listed in section \ref{sec:new-tag} (without a slash at the begin, this is added by the code). It is possible to setup new tags, see the same section. The value of the key is expanded, so it can be a command. The expansion is passed unchanged to the pdf, so it should with a starting slash give a valid pdf name  (some ascii with numbers like \texttt{H4} is fine).\Pmeti
+  \TagP^This is required, unless you use the \PrintKeyName{artifact} key. The value of the key is normally one of the standard type listed in section \ref{sec:new-tag} (without a slash at the begin, this is added by the code). It is possible to setup new tags, see the same section. The value of the key is expanded, so it can be a command. The expansion is passed unchanged to the \PDF{}, so it should with a starting slash give a valid \PDF{} name  (some ascii with numbers like \texttt{H4} is fine).\Pmeti
 
   \item[\PrintKeyName{artifact}]
   \TagP^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 \PrintKeyName{pagination}, \PrintKeyName{layout},  \PrintKeyName{page},  \PrintKeyName{background} and \PrintKeyName{notype} (this is the default). Text in the header and footer should be marked with \PrintKeyName{artifact=pagination}.
@@ -560,7 +626,7 @@
       \end{lstlisting}
   \tagmcend\tagstructend
 
-  \TagP^    and it will insert \verb+\frac{a}{b}+  (hex encoded) in the pdf.\Pmeti
+  \TagP^    and it will insert \verb+\frac{a}{b}+  (hex encoded) in the \PDF{}.\Pmeti
 
   \item[\PrintKeyName{actualtext}]
   \TagP^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.\Pmeti
@@ -577,16 +643,16 @@
  \tagmcend\tagstructend
 
 
- \TagP^and it will insert \verb+X+ (hex encoded)  in the pdf.\Pmeti
+ \TagP^and it will insert \verb+X+ (hex encoded)  in the \PDF{}.\Pmeti
 
   \item[\PrintKeyName{raw}]
-  \TagP^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.\Pmeti
+  \TagP^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.\Pmeti
 \end{description}
 
 
 \ExplSyntaxOn
 \DescribeMacro\tagmcend
-\DescribeMacro\uftag_mc_end:
+\DescribeMacro\tag_mc_end:
 \ExplSyntaxOff
 
 \TagP^These commands insert the end code of the marked content. They don't end a group and in generic mode it doesn't matter if they are in another group as the starting commands. The user command also issues at first an \verb+\unskip+. In generic mode both commands check if there has been a begin marker and issue a warning if not. In luamode it is often possible to omit the command, as the effect of the begin command ends with the current group or with a new \verb+\tagmcbegin+ anyway.\TagPend
@@ -603,13 +669,13 @@
 \end{lstlisting}
 \tagmcend\tagstructend
 
-\TagP^Block 3 will here get the same id number as Block 1 and be stored in the structure \emph{before} Block 2. The pdf will record the chunks in the order \texttt{Block 1 -- Block 3 -- Block 2}.
+\TagP^Block 3 will here get the same id number as Block 1 and be stored in the structure \emph{before} Block 2. The \PDF{} will record the chunks in the order \texttt{Block 1 -- Block 3 -- Block 2}.
 \TagPend
 \end{tcolorbox}
 
 \ExplSyntaxOn
 \DescribeMacro\tagmcuse{<label name>}
-\DescribeMacro\uftag_mc_use:n {<label name>}
+\DescribeMacro\tag_mc_use:n {<label name>}
 \ExplSyntaxOff
 
 \TagP^These commands allow you to record a marked content that you stashed away into the current structure. Be aware that a marked content can be used only once -- the command will warn you if you try to use it a second time.\TagPend
@@ -616,7 +682,7 @@
 
 \ExplSyntaxOn
 \DescribeMacro\tagmcifinTF{<true code>}{<false>}
-\DescribeMacro\uftag_mc_if_in:TF{<true code>}{<false>}
+\DescribeMacro\tag_mc_if_in:TF{<true code>}{<false>}
 \ExplSyntaxOff
 
 \TagP^These commands check if a marked content is currently open and allows you to e.g. add the end marker if yes.
@@ -627,11 +693,13 @@
 
 \ExplSyntaxOn
 \DescribeMacro\tagpdfget{<key word>}
-\DescribeMacro\uftag_get:n{<key word>}
+\DescribeMacro\tag_get:n{<key word>}
 \ExplSyntaxOff
 
 \TagP^These commands give back some variables. Currently the only working key word is \verb+mc\_tag+.\TagPend.
 
+
+
 \subsubsection{Tips}
 
 \begin{itemize}
@@ -638,8 +706,8 @@
 \item \TagP^Mark commands inside floats should work fine (but need perhaps some compilation rounds in generic mode).\Pmeti
 \item \TagP^In case you want to use it inside a \verb+\savebox+ (or some command that saves the text internally in a box): If the box is used directly, there is probably no problem. If the use is later, stash the marked content and add the needed \verb+\tagmcuse+ directly  before oder after the box when you use it.\Pmeti
 \item \TagP^Don't use a saved box with markers twice.\Pmeti
-\item \TagP^If boxes are unboxed you will have to analyze the pdf to check if everything is ok.\Pmeti
-\item \TagP^If you use complicated structures and commands (breakable boxes like the one from tcolorbox, multicol, many footnotes) you will have to check the pdf.\Pmeti
+\item \TagP^If boxes are unboxed you will have to analyze the \PDF{} to check if everything is ok.\Pmeti
+\item \TagP^If you use complicated structures and commands (breakable boxes like the one from tcolorbox, multicol, many footnotes) you will have to check the \PDF{}.\Pmeti
  \end{itemize}
 
 
@@ -654,7 +722,7 @@
 
 \subsubsection{Links}
 
-\TagP^Link annotations (like all PDF annotations) are associated with a geometric region of the page rather than with a particular object in its content stream. Any connection between the link and the content is based solely on visual appearance rather than on an explicitly specified association.\TagPend
+\TagP^Link annotations (like all \PDF{} annotations) are associated with a geometric region of the page rather than with a particular object in its content stream. Any connection between the link and the content is based solely on visual appearance rather than on an explicitly specified association.\TagPend
 
 \TagP^To connect such a link with the underlying text a specific structure has to be added, see \ref{fig:linkannot}. When using the low-level commands to create a link, this structure can be created by adding an entry to the attr argument of the startlink command, and by by adding a command of the tagpdf package after the endlink command, as show in the following listing:\TagPend
 
@@ -663,7 +731,7 @@
 \pdfextension startlink
     attr
      {
-     /StructParent \int_use:N\c at g__uftag_parenttree_obj_int %<----
+     /StructParent \int_use:N\c at g__tag_parenttree_obj_int %<----
      }
     user {
           /Subtype/Link
@@ -676,7 +744,7 @@
          }
     This is a link.
 \pdfextension endlink
-\__uftag_struct_finish_link: %<----
+\__tag_struct_finish_link: %<----
 \end{lstlisting}
 \tagmcend\tagstructend
 
@@ -685,7 +753,7 @@
 \subsubsection{Math}
 
 \TagP^Math is a problem. I have seen an example where \emph{every single symbol} has been marked up with tags from MathML along with an \texttt{/ActualText} entry and an entry with alternate text which describes how to read the symbol.
-The pdf then looked like this\TagPend
+The \PDF{} then looked like this\TagPend
 
 \tagstructbegin{tag=Code}\tagmcbegin{tag=Code}
 \begin{lstlisting}
@@ -700,7 +768,7 @@
 
 \TagP^If this is really the way to go one would need some script to add the mark-up as doing it manually is too much work and would make the source unreadable -- at least with pdflatex and the generic mode. In lua mode is it probably possible to hook into the \texttt{mlist\_to\_hlist} callback and add marker automatically.\TagPend
 
-\TagP^But I'm not sure that this is the best way to do math. It looks rather odd that a document should have to tell a screen reader in such detail how to read an equation. It would be much more efficient, sensible and flexible if a complete representation of the equation in mathML could be stored in the pdf and the task how to read this aloud delegated to the screen reader. More investigations are needed here.\TagPend
+\TagP^But I'm not sure that this is the best way to do math. It looks rather odd that a document should have to tell a screen reader in such detail how to read an equation. It would be much more efficient, sensible and flexible if a complete representation of the equation in mathML could be stored in the \PDF{} and the task how to read this aloud delegated to the screen reader. More investigations are needed here.\TagPend
 
 \TagP^See also section~\ref{sec:alttext} for some more remarks and tests.\TagPend
 
@@ -728,7 +796,7 @@
 
 
 \subsection{Task 2: Marking the structure}
-\TagP^The structure is represented in the pdf with a number of objects of type \texttt{StructElem} which build a tree: each of this objects points back to its parent and normally has a number of kid elements, which are either again structure elements or -- as leafs of the tree -- the marked contents chunks marked up with the \verb+tagmc+-commands. The root of the tree is the \texttt{StructTreeRoot}.\TagPend
+\TagP^The structure is represented in the \PDF{} with a number of objects of type \texttt{StructElem} which build a tree: each of this objects points back to its parent and normally has a number of kid elements, which are either again structure elements or -- as leafs of the tree -- the marked contents chunks marked up with the \verb+tagmc+-commands. The root of the tree is the \texttt{StructTreeRoot}.\TagPend
 
 \subsubsection{Structure types}
 \TagP^The tree should reflect the \emph{semantic} meaning of the text. That means that the text should be marked as section, list, table head, table cell and so on. A number of standard structure types is predefined, see section \ref{sec:new-tag} but it is allowed to create more. If you want to use types of your own you must declare them. E.g. this declares two new types \texttt{TAB} and {FIG} and base them on \texttt{P}:\TagPend
@@ -780,7 +848,7 @@
 
 \ExplSyntaxOn
 \DescribeMacro\tagstructbegin{key-val-list}
-\DescribeMacro\uftag_struct_begin:n {key-val-list}
+\DescribeMacro\tag_struct_begin:n {key-val-list}
 \ExplSyntaxOff
 
 \TagP These commands start a new structure. They don't start a group. They set all their values globally.
@@ -812,7 +880,7 @@
    \tagmcend\tagstructend
 
 
-   \TagP^   and it will insert \verb+\frac{a}{b}+  (hex encoded) in the pdf.\Pmeti
+   \TagP^   and it will insert \verb+\frac{a}{b}+  (hex encoded) in the \PDF{}.\Pmeti
 
 
   \item[\PrintKeyName{actualtext}]
@@ -829,7 +897,7 @@
    \tagmcend\tagstructend
 
 
-   \TagP^and it will insert \verb+X+ (hex encoded)  in the pdf.\Pmeti
+   \TagP^and it will insert \verb+X+ (hex encoded)  in the \PDF{}.\Pmeti
 
    \item[\PrintKeyName{attribute}]
     \TagP^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 the structure object. As an example\TagPend
@@ -856,12 +924,56 @@
   \item[\PrintKeyName{title-o}]
   \TagP^This key allows to set the dictionary entry \texttt{/Title} in the structure object.
   The value is expanded once and then handled as verbatim string like the \PrintKeyName{title} key.\Pmeti
+
+   \item[\PrintKeyName{AF}]
+   \TagP^This key allows to reference an associated file in the structure element.
+   The value should be the name of an object pointing to the \texttt{/Filespec} dictionary as expected by
+   \verb+\pdf_object_ref:n+ from a current \texttt{l3kernel}.
+   For example:\TagPend
+
+   \tagstructbegin{tag=Code}\tagmcbegin{tag=Code}
+   \begin{lstlisting}
+   \pdfdict_put:nnn {l_pdffile/FileSpec} {AFRelationship}{/Supplement}
+   \pdffile_embed_file:nnn{example-input-file.tex}{}{tag/AFtest}
+   \tagstructbegin{tag=P,AF=tag/AFtest}
+   \end{lstlisting}
+   \tagmcend\tagstructend
+
+   \TagP^As shown, the wanted AFRelationship can be set
+   by filling the dictionary with the value. The mime type
+   is here detected automatically, but for unknown types it can be set too.
+   See the \texttt{l3pdffile} documentation for details.  Associated files are
+   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+). \Pmeti
+
+   \item[\PrintKeyName{AFinline}]
+    \TagP^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. \Pmeti
+
+   \begin{lstlisting}
+   \tagstructbegin{tag=P,AFinline=Some extra text}
+   \end{lstlisting}
+
+   \item[\PrintKeyName{AFinline-o}]
+    \TagP^This is like verb+AFinline+, but it expands the value once.\Pmeti
+
+   \item[\PrintKeyName{lang}]
+     \TagP^This key allows to set the language for a structure element. The value should be a bcp-identifier,
+     e.g. |de-De|.\Pmeti
+
+   \item[\PrintKeyName{ref}]
+     \TagP^This key allows to add references to other structure elements, it adds the |/Ref| array to the structure.
+       The value should be a comma seperated list of structure labels set with the |label| key.
+     e.g. |ref={label1,label2}|.\Pmeti
+
+   \item[\PrintKeyName{E}]
+     \TagP^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).\Pmeti
 \end{description}
 
 
 \ExplSyntaxOn
 \DescribeMacro\tagstructend
-\DescribeMacro\uftag_struct_end:
+\DescribeMacro\tag_struct_end:
 \ExplSyntaxOff
 
 \TagP^These commands end a structure. They don't end a group and it doesn't matter if they are in another group as the starting commands.\TagPend
@@ -868,7 +980,7 @@
 
 \ExplSyntaxOn
 \DescribeMacro\tagstructuse{<label>}
-\DescribeMacro\uftag_struct_use:n {<label>}
+\DescribeMacro\tag_struct_use:n {<label>}
 \ExplSyntaxOff
 
 \TagP^These commands insert a structure previously stashed away as kid into the currently active structure. A structure should be used only once, if the structure already has a parent you will get a warning.\TagPend
@@ -901,18 +1013,18 @@
 \tagpdfsetup
  {
   newattribute =
-   {TH-col}{<</Owner /Table /Scope /Column>>},
+   {TH-col}{/Owner /Table /Scope /Column},
   newattribute =
-   {TH-row}{<</Owner /Table /Scope /Row>>},
+   {TH-row}{/Owner /Table /Scope /Row},
   }
 \end{lstlisting}
 \tagmcend\tagstructend
 
 
-\TagP^Attributes are only written to the pdf when used, so it is not a problem to predeclare a number of standard attributes.
+\TagP^Attributes are only written to the \PDF{} when used, so it is not a problem to predeclare a number of standard attributes.
 \TagPend
 
-\TagP^It is your responsability that the content of the dictionary is valid pdf and that the values are sensible!
+\TagP^It is your responsability that the content of the dictionary is valid \PDF{} and that the values are sensible!
 \TagPend
 
 \TagP^Attributes can then be used with the key \PrintKeyName{attribute} or \PrintKeyName{attribute-class} which both take a comma list of attribute names as argument:
@@ -930,13 +1042,13 @@
 
 
 \subsection{Task 3: tree Management}
-\TagP^When all the document content has been correctly marked and the data for the trees has been collected they must be flushed to the pdf. This is done automatically (if the package has been activated) with the following command in \verb+\AfterEndDocument+:\TagPend
+\TagP^When all the document content has been correctly marked and the data for the trees has been collected they must be flushed to the \PDF{}. This is done automatically (if the package has been activated) with the following command in \verb+\AfterEndDocument+:\TagPend
 
 \ExplSyntaxOn
-\DescribeMacro\uftag_finish_structure:
+\DescribeMacro\tag_finish_structure:
 \ExplSyntaxOff
 
-\TagP^This will hopefully write all the needed objects and values to the pdf. (Beside the already mentioned  \texttt{StructTreeRoot} and \texttt{StructElem} objects, additionally a so-called \texttt{ParentTree} is needed which records the parents of all the marked contents bits, a \texttt{Rolemap}, perhaps a \texttt{ClassMap} and object for the attributes, and a few more values and dictionaries).\TagPend
+\TagP^This will hopefully write all the needed objects and values to the \PDF{}. (Beside the already mentioned  \texttt{StructTreeRoot} and \texttt{StructElem} objects, additionally a so-called \texttt{ParentTree} is needed which records the parents of all the marked contents bits, a \texttt{Rolemap}, perhaps a \texttt{ClassMap} and object for the attributes, and a few more values and dictionaries).\TagPend
 
 \TagP^I'm not quite sure if this shouldn't be a really internal command.\TagPend
 
@@ -999,7 +1111,7 @@
 
 \subsection{Lazy and automatic tagging}\label{sec:lazy}
 
-\TagP^A number of features of pdf readers need a fully tagged pdf. As an example screen readers tend to ignore alternative text (see section~\ref{sec:alttext}) if the pdf is not fully tagged. Also reflowing a pdf only works for me (even if real space chars are in the pdf) if the pdf is fully tagged.\TagPend
+\TagP^A number of features of \PDF{} readers need a fully tagged \PDF{}. As an example screen readers tend to ignore alternative text (see section~\ref{sec:alttext}) if the \PDF{} is not fully tagged. Also reflowing a \PDF{} only works for me (even if real space chars are in the \PDF{}) if the \PDF{} is fully tagged.\TagPend
 
 \TagP^This means that even if you don't care about a proper structure you should try to add at least some minimal tagging. With pdflatex this is not easy due to the page break problem. But with lualatex you can use an \texttt{Document} structure and inside it rather large mc-chunks. This minimizes the needed work.\TagPend
 
@@ -1007,14 +1119,34 @@
 \TagPend
 
 
+\subsection{Adding tagging to commands}
+
+\TagP^As mentioned above the mc-markers should not be nested. Basically you write:\TagPend
+
+\tagstructbegin{tag=Code}\tagmcbegin{tag=Code}
+\begin{lstlisting}
+\tagmcbegin{..}some text ...\tagmcend
+<optional structure commands>
+\tagmcbegin{..}some other text\tagmcend
+\end{lstlisting}
+\tagmcend\tagstructend
+
+\TagP^This is quite workable as long as you mark everything manually. But how to write commands, e.g for a tabular or a graphic, that do tagging automatically without breaking the flow and the structure?\TagPend
+
+
+
+
+
+
+
 \section{Alternative text, ActualText and text-to-speech software}\label{sec:alttext}
 
-\TagP^The pdf format allows to add alternative text through the  \PrintKeyName{/Alt} and the \PrintKeyName{/ActualText} key.
+\TagP^The \PDF{} format allows to add alternative text through the  \PrintKeyName{/Alt} and the \PrintKeyName{/ActualText} key.
 %\footnote{
 There is also the \PrintKeyName{/E} key for acronyms but I will ignore it for now.
 Both can be added either to the marked content in the page stream or to the object describing the structure.\TagPend
 
-\TagP^The value of \PrintKeyName{/ActualText} (inserted by \texttt{tagpdf} with \PrintKeyName{actualtext}) is meant to replace single characters or rather small pieces of text. It can be used also without any tagging (e.g. with the package accsupp). If the pdf reader support this (adobe reader does, sumatra not) one can change with it how a piece of text is copied and pasted e.g. to split up a ligature.\TagPend
+\TagP^The value of \PrintKeyName{/ActualText} (inserted by \texttt{tagpdf} with \PrintKeyName{actualtext}) is meant to replace single characters or rather small pieces of text. It can be used also without any tagging (e.g. with the package accsupp). If the \PDF{} reader support this (adobe reader does, sumatra not) one can change with it how a piece of text is copied and pasted e.g. to split up a ligature.\TagPend
 
 \TagP^\PrintKeyName{/Alt} (inserted by \texttt{tagpdf} with \PrintKeyName{alttext}) is a key to improve accessibility: with it one can add to a picture or something else an alternative text.\TagPend
 
@@ -1035,13 +1167,13 @@
 
 \section{Standard type and new tags}\label{sec:new-tag}
 
-\TagP^The pdf reference mentions a number of standard types:
+\TagP^The \PDF{} reference mentions a number of standard types:
 \ExplSyntaxOn
-\clist_use:Nn \c__uftag_role_sttags_clist {,\c_space_tl}
+\clist_use:Nn \c__tag_role_sttags_clist {,\c_space_tl}
 
 \ExplSyntaxOff\TagPend
 
-\TagP^Their meaning can be looked up in the pdf-reference \parencite{pdfreference}.\TagPend
+\TagP^Their meaning can be looked up in the \PDF{}-reference \parencite{pdfreference}.\TagPend
 
 \TagP^New tags can be defined in the setup command with the key \texttt{add-new-tag}. It takes a value consisting of two names separated by a slash. The first is the new name, the second a known (e.g. a standard) tag it should be mapped too. Example:\TagPend
 
@@ -1053,17 +1185,17 @@
 
 \section{\enquote{Real} space glyphs}\label{sec:spacechars}
 
-\TagP^TeX uses only spaces (horizontal movements) to separate words. That means that a pdf reader has to use some heuristic when copying text or reflowing the text to decide if a space is meant as a word boundary or e.g. as a kerning. Accessible document should use real space glyphs (U+0032) from a font in such places.\TagPend
+\TagP^TeX uses only spaces (horizontal movements) to separate words. That means that a \PDF{} reader has to use some heuristic when copying text or reflowing the text to decide if a space is meant as a word boundary or e.g. as a kerning. Accessible document should use real space glyphs (U+0032) from a font in such places.\TagPend
 
 \TagP^With the key \PrintKeyName{interwordspace} you can activate such space glyphs.\TagPend
 
-\TagP^With pdftex this will simply call the primitive \verb+\pdfinterwordspaceon+. pdftex will then insert at various places a char from a font called dummy-space. Attention! This means that at every space there are additional font switches in the pdf: from the current font to the dummy-space font and back again. This will make the pdf larger. As \verb+\pdfinterwordspaceon+ is a primitive function it can't be fine tuned or adapted. You can only turn it on and off and insert manually such a space glyph with \verb+\pdffakespace+.\TagPend
+\TagP^With pdftex this will simply call the primitive \verb+\pdfinterwordspaceon+. pdftex will then insert at various places a char from a font called dummy-space. Attention! This means that at every space there are additional font switches in the \PDF{}: from the current font to the dummy-space font and back again. This will make the \PDF{} larger. As \verb+\pdfinterwordspaceon+ is a primitive function it can't be fine tuned or adapted. You can only turn it on and off and insert manually such a space glyph with \verb+\pdffakespace+.\TagPend
 
 \TagP^With luatex (in luamode) interwordspace is implemented with a lua-function which is inserted in two callbacks and marks up the places where it seems sensible to inter a space glyph. Later in the process (when also the mc-markers are inserted) the space glyphs are injected -- the code will take the glyph from the current font if this has a space glyph or switch to the default latin modern font. The current code works reasonable well in normal text.\TagPend
 
 \TagP^The key \PrintKeyName{show-spaces} will show lines at the places where in lua mode spaces are inserted and so can help you to find problematic places. For listings -- which have a quite specific handling of spaces -- you can find a suggestion in the example \texttt{ex-space-glyph-listings}.\TagPend
 
-\TagP^\emph{Attention:} Even with real spaces copy\& pasting of code doesn't need to give the correct results: you get spaces but not necessarly the right number of spaces. The pdf viewers I tried all copied four real space glyphs as one space. I only got the four spaces with the export to text or xml in the AdobePro.\TagPend
+\TagP^\emph{Attention:} Even with real spaces copy\& pasting of code doesn't need to give the correct results: you get spaces but not necessarly the right number of spaces. The \PDF{} viewers I tried all copied four real space glyphs as one space. I only got the four spaces with the export to text or xml in the AdobePro.\TagPend
 
 \DescribeMacro\pdffakespace
 
@@ -1073,10 +1205,10 @@
 
 \section{Accessibility is not only tagging}
 
-\TagP^A tagged pdf is needed for accessibility but this is not enough. As already mentioned there are more requirements:\TagPend
+\TagP^A tagged \PDF{} is needed for accessibility but this is not enough. As already mentioned there are more requirements:\TagPend
 
  \begin{itemize}
- \item \TagP^The language must be declared by adding a \texttt{/Lang xx-XX} to the pdf catalog or -- if the language changes for a part of the text to the structure or the marked content. Setting the document language can be rather easily done with existing packages or even directly with \verb+\pdfcatalog{/Lang (en-US)}+. For settings in marked content and structure I will have to add keys.\Pmeti
+ \item \TagP^The language must be declared by adding a \texttt{/Lang xx-XX} to the \PDF{} catalog or -- if the language changes for a part of the text to the structure or the marked content. Setting the document language can be rather easily done with existing packages. With the new \PDF{} resource management it should be done with \verb+\pdfmanagement_add:nnn{Catalog}{Lang}{(en-US)}+. For settings in marked content and structure I will have to add keys.\Pmeti
  \item \TagP^All characters must have an unicode representation or a suitable alternative text.
       With lualatex and open type (unicode) fonts this is normally not a problem. With pdflatex it could need\TagPend
       \tagstructbegin{tag=Code}\tagmcbegin{tag=Code}
@@ -1108,7 +1240,7 @@
 \item \TagP^Write more Tests\Pmeti
 \item \TagP^Unicode\Pmeti
 \item \TagP^Hyphenation char\Pmeti
-\item \TagP^Think about included (tagged) pdf. Can one handle them?\Pmeti
+\item \TagP^Think about included (tagged) \PDF{}. Can one handle them?\Pmeti
 \item \TagP^Improve the documentation\Pmeti
 \item \TagP^Tag as proof of concept the documentation (nearly done)\Pmeti
 \item \TagP^Document the code better\Pmeti
@@ -1116,7 +1248,7 @@
 \item \TagP^Find someone to check and improve the lua code\Pmeti
 \item \TagP^Move more things to lua in the luamode\Pmeti
 \item \TagP^Find someone to check and improve the rest of the code\Pmeti
-\item \TagP^Check differences between pdf versions 1.7 and 2.0.\Pmeti
+\item \TagP^Check differences between \PDF{} versions 1.7 and 2.0.\Pmeti
 \item \TagP^bidi?\Pmeti
 \end{itemize}
 
@@ -1124,12 +1256,12 @@
 
 \appendix
 
-\section{Some remarks about the pdf syntax}
+\section{Some remarks about the \PDF{} syntax}
 
 \TagP^This is not meant as a full reference only as a background to make the examples and remarks easier to understand.\TagPend
 
 \begin{description}
-\item[postfix notation] \TagP^pdf uses in various places postfix notation. This means that the operator is behind its arguments:\TagPend
+\item[postfix notation] \TagP^\PDF{} uses in various places postfix notation. This means that the operator is behind its arguments:\TagPend
 
 \tagstructbegin{tag=Figure,alttext={Illustration of postfix notation}}\tagmcbegin{tag=Figure}
 \begin{tikzpicture}[baseline=(c.base)]
@@ -1175,9 +1307,9 @@
 \tagmcend\tagstructend
 \meti
 
-\item[Names] \TagP^pdf knows a sort of variable called a \enquote{name}. Names start with a slash and may include any regular characters, but not delimiter or white-space characters. Uppercase and lowercase letters are considered distinct: \texttt{/A} and \texttt{/a} are different names. \verb+/.notdef+ and \verb+/Adobe#20Green+  are valid names.\TagPend
+\item[Names] \TagP^\PDF{} knows a sort of variable called a \enquote{name}. Names start with a slash and may include any regular characters, but not delimiter or white-space characters. Uppercase and lowercase letters are considered distinct: \texttt{/A} and \texttt{/a} are different names. \verb+/.notdef+ and \verb+/Adobe#20Green+  are valid names.\TagPend
 
-    \TagP^Quite a number of the options of \texttt{tagpdf} actually define such a name which is  later added to the pdf. I recommend \emph{strongly} not to use spaces and exotic chars in such names. While it is possible to escape such names it is rather a pain when moving them through the various lists and commands and quite probably I forgot some place where it is needed.\Pmeti
+    \TagP^Quite a number of the options of \texttt{tagpdf} actually define such a name which is  later added to the \PDF{}. I recommend \emph{strongly} not to use spaces and exotic chars in such names. While it is possible to escape such names it is rather a pain when moving them through the various lists and commands and quite probably I forgot some place where it is needed.\Pmeti
 
 \item[Strings]\TagP^There are two types of strings: \emph{Literal strings} are enclosed in round parentheses. They normally contain a mix of ascii chars and octal numbers:\TagPend
 
@@ -1228,9 +1360,9 @@
 \tagmcend\tagstructend \meti
 
 
- \item[(indirect) objects] \TagP^These are enclosed by the keywords \texttt{obj} (which has two numbers as prefix arguments) and \texttt{endobj}. The first argument is the object number, the second a generation number -- if a pdf is edited objects with a larger generation number can be added. As with pdflatex/lualatex the pdf is always new we can safely assume that the number is always 0. Objects can be referenced in other places with the \texttt{R} operator. The content of an object can be all sort of things.\Pmeti
+ \item[(indirect) objects] \TagP^These are enclosed by the keywords \texttt{obj} (which has two numbers as prefix arguments) and \texttt{endobj}. The first argument is the object number, the second a generation number -- if a \PDF{} is edited objects with a larger generation number can be added. As with pdflatex/lualatex the \PDF{} is always new we can safely assume that the number is always 0. Objects can be referenced in other places with the \texttt{R} operator. The content of an object can be all sort of things.\Pmeti
 
- \item[streams] \TagP^A stream is a sequence of bytes. It can be long and is used for the real content of pdf: text, fonts, content of graphics.
+ \item[streams] \TagP^A stream is a sequence of bytes. It can be long and is used for the real content of \PDF{}: text, fonts, content of graphics.
  A stream starts with a dictionary which at least sets the \texttt{/Length} name to the length of the stream followed by the stream content enclosed by the keywords \texttt{stream} and \texttt{endstream}.
 
  \TagP Here an example of a stream, an object definition and reference. In the object 2 (a page object) the \texttt{/Contents} key references the object 3 and this then contains the text of the page in a stream. \texttt{Tf}, \texttt{Tm} and \texttt{TJ} are (postfix) operators, the first chooses the font with the name \texttt{/F15} at the size 10.9, the second displaces the reference point on the page and the third inserts the text.\TagPend
@@ -1281,5 +1413,5 @@
 \end{description}
 \tagstructend %document
 \end{document}
-%http://msf.mathmlcloud.org/file_formats/8 %sample pdf for math
+%http://msf.mathmlcloud.org/file_formats/8 %sample \PDF{} for math
 

Added: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx	                        (rev 0)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx	2021-02-23 22:24:07 UTC (rev 57857)
@@ -0,0 +1,803 @@
+% \iffalse meta-comment
+%
+%% File: tagpdf-backend.dtx
+%
+% Copyright (C) 2019-2020 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.
+%
+% -----------------------------------------------------------------------
+%
+% The development version of the bundle can be found at
+%
+%    https://github.com/u-fischer/tagpdf
+%
+% for those people who are interested.
+%
+% \fi
+%
+%    \begin{macrocode}
+%<@@=tag>
+%<*luatex>
+\ProvidesExplFile {tagpdf-luatex.def} {2021/02/23} {0.80}
+  {tagpdf~driver~for~luatex}
+
+\newattribute \l_@@_mc_type_attr     %the value represent the type
+\newattribute \l_@@_mc_cnt_attr      %will hold the \c at g_@@_MCID_abs_int value
+
+\newattribute \g_@@_interwordspace_attr
+\newattribute \g_@@_interwordfont_attr
+
+% The lua code
+% ensure that 10pt font has been loaded:
+{
+  \fontencoding{TU}\fontfamily{lmr}\fontseries{m}\fontshape{n}\fontsize{10pt}{10pt}\selectfont
+}
+\directlua { tagpdf=require('tagpdf.lua') }
+
+%%%% driver (lualatex) commands
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+% I probably want also lua tables
+% I put them in the ltx.@@.tables namespaces
+% The tables will be named like the variables but without backslash
+% To access such a table with a dynamical name create a string and then use
+% ltx.@@.tables[string]
+% Old code, I'm not quite sure if this was a good idea. Now I have mix of table in
+% ltx.@@.tables and ltx.@@.mc/struct. And a lot is probably not needed.
+
+\cs_new:Nn \@@_luatex_get_table_name:Nn
+  {
+    \tl_set_rescan:Nnn #1  { \char_set_catcode_ignore:N \\ } { #2 }
+  }
+
+
+\cs_new:Nn \@@_prop_new:N
+  {
+    \prop_new:N #1
+    \@@_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
+    \directlua { ltx.@@.tables.\l_tmpa_tl = {} }
+  }
+
+
+\cs_new:Nn \@@_seq_new:N
+  {
+    \seq_new:N #1
+    \@@_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
+    \directlua { ltx.@@.tables.\l_tmpa_tl = {} }
+  }
+
+
+\cs_new:Nn \@@_prop_gput:Nnn
+  {
+    \prop_gput:Nnn #1 { #2 } { #3 }
+    \@@_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
+    \directlua { ltx.@@.tables.\l_tmpa_tl["#2"] = "#3" }
+  }
+
+
+\cs_new:Nn \@@_seq_gput_right:Nn
+  {
+    \seq_gput_right:Nn #1 { #2 }
+    \@@_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
+    \directlua { table.insert(ltx.@@.tables.\l_tmpa_tl, "#2") }
+  }
+
+%Hm not quite sure about the naming
+
+\cs_new:Npn \@@_seq_item:cn #1 #2
+  {
+    \directlua { tex.print(ltx.@@.tables.#1[#2]) }
+  }
+
+\cs_new:Npn \@@_prop_item:cn #1 #2
+  {
+    \directlua { tex.print(ltx.@@.tables.#1["#2"]) }
+  }
+
+%for debugging commands that show both the seq/prop and the lua tables
+\cs_new:Nn \@@_seq_show:N
+  {
+    \seq_show:N #1
+    \@@_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
+    \directlua { ltx.@@.trace.log ("lua~sequence~array~\l_tmpa_tl",1) }
+    \directlua { ltx.@@.trace.show_seq (ltx.@@.tables.\l_tmpa_tl) }
+  }
+
+\cs_new:Nn \@@_prop_show:N
+  {
+    \prop_show:N #1
+    \@@_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
+    \directlua {ltx.@@.trace.log  ("lua~property~table~\l_tmpa_tl",1) }
+    \directlua {ltx.@@.trace.show_prop (ltx.@@.tables.\l_tmpa_tl) }
+ }
+%</luatex>
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+%<*pdftex>
+\ProvidesExplFile {tagpdf-pdftex.def} {2021/02/23} {0.80}
+  {tagpdf~driver~for~pdftex}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%% driver (pdflatex) commands
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+% These commands are only aliases for pdflatex but are defined differently with luatex
+% to get also lua tables.
+\cs_set_eq:NN \@@_prop_new:N     \prop_new:N
+
+\cs_set_eq:NN \@@_seq_new:N      \seq_new:N
+
+\cs_set_eq:NN \@@_prop_gput:Nnn  \prop_gput:Nnn
+
+\cs_set_eq:NN \@@_seq_gput_right:Nn \seq_gput_right:Nn
+
+\cs_set_eq:NN \@@_seq_item:cn    \seq_item:cn
+
+\cs_set_eq:NN \@@_prop_item:cn   \prop_item:cn
+
+\cs_set_eq:NN \@@_seq_show:N     \seq_show:N
+
+\cs_set_eq:NN \@@_prop_show:N    \prop_show:N
+
+%</pdftex>
+%    \end{macrocode}
+%    \begin{macrocode}
+%<*lua>
+-- tagpdf.lua
+-- Ulrike Fischer
+
+local ProvidesLuaModule = {
+    name          = "tagpdf",
+    version       = "0.80",       --TAGVERSION
+    date          = "2021-02-23", --TAGDATE
+    description   = "tagpdf lua code",
+    license       = "The LATEX Project Public License 1.3c"
+}
+
+if luatexbase and luatexbase.provides_module then
+  luatexbase.provides_module (ProvidesLuaModule)
+end
+
+--[[
+The code has quite probably a number of problems
+ - more variables should be local instead of global
+ - the naming is not always consistent due to the development of the code
+ - the traversing of the shipout box must be tested with more complicated setups
+ - it should probably handle more node types
+ -
+--]]
+
+
+
+--[[
+the main table is named ltx.@@. It contains the functions and also the data
+collected during the compilation.
+
+ltx.@@.mc     will contain mc connected data.
+ltx.@@.struct will contain structure related data.
+ltx.@@.page   will contain page data
+ltx.@@.tables contains also data from mc and struct (from older code). This needs cleaning up.
+             There are certainly dublettes, but I don't dare yet ...
+ltx.@@.func   will contain (public) functions.
+ltx.@@.trace  will contain tracing/loging functions.
+local funktions starts with __
+functions meant for users will be in ltx.tag
+
+functions
+ ltx.@@.func.get_num_from (tag):    takes a tag (string) and returns the id number
+ ltx.@@.func.output_num_from (tag): takes a tag (string) and prints (to tex) the id number
+ ltx.@@.func.get_tag_from (num):    takes a num and returns the tag
+ ltx.@@.func.output_tag_from (num): takes a num and prints (to tex) the tag
+ ltx.@@.func.store_mc_data (num,key,data): stores key=data in ltx.@@.mc[num]
+ ltx.@@.func.store_mc_label (label,num): stores label=num in ltx.@@.mc.labels
+ ltx.@@.func.store_mc_kid (mcnum,kid,page): stores the mc-kids of mcnum on page page
+ ltx.@@.func.store_mc_in_page(mcnum,mcpagecnt,page): stores in the page table the number of mcnum on this page
+ ltx.@@.func.store_struct_mcabs (structnum,mcnum): stores relations structnum<->mcnum (abs)
+ ltx.@@.func.mc_insert_kids (mcnum): inserts the /K entries for mcnum by wandering throught the [kids] table
+ ltx.@@.func.mark_page_elements(box,mcpagecnt,mccntprev,mcopen,name,mctypeprev) : the main function
+ ltx.@@.func.mark_shipout (): a wrapper around the core function which inserts the last EMC
+ ltx.@@.func.fill_parent_tree_line (page): outputs the entries of the parenttree for this page
+ ltx.@@.func.output_parenttree(): outputs the content of the parenttree
+ ltx.@@.func.markspaceon(), ltx.@@.func.markspaceoff(): (de)activates the marking of positions for space chars
+ ltx.@@.trace.show_mc_data (num): shows ltx.@@.mc[num]
+ ltx.@@.trace.show_all_mc_data (max): shows a maximum about mc's
+ ltx.@@.trace.show_seq: shows a sequence (array)
+ ltx.@@.trace.show_struct_data (num): shows data of structure num
+ ltx.@@.trace.show_prop: shows a prop
+ ltx.@@.trace.log
+ ltx.@@.trace.showspaces : boolean
+--]]
+
+local mctypeattributeid       = luatexbase.registernumber ("l_@@_mc_type_attr")
+local mccntattributeid        = luatexbase.registernumber ("l_@@_mc_cnt_attr")
+local iwspaceattributeid = luatexbase.registernumber ("g_@@_interwordspace_attr")
+local iwfontattributeid = luatexbase.registernumber ("g_@@_interwordfont_attr")
+
+
+local catlatex       = luatexbase.registernumber("catcodetable at latex")
+local tagunmarkedbool= token.create("g_@@_tagunmarked_bool")
+local truebool       = token.create("c_true_bool")
+
+local tableinsert    = table.insert
+
+-- not all needed, copied from lua-visual-debug.
+local nodeid           = node.id
+local nodecopy         = node.copy
+local nodegetattribute = node.get_attribute
+local nodesetattribute = node.set_attribute
+local nodenew          = node.new
+local nodetail         = node.tail
+local nodeslide        = node.slide
+local noderemove       = node.remove
+local nodetraverseid   = node.traverse_id
+local nodetraverse     = node.traverse
+local nodeinsertafter  = node.insert_after
+local nodeinsertbefore = node.insert_before
+local pdfpageref       = pdf.pageref
+
+local HLIST          = node.id("hlist")
+local VLIST          = node.id("vlist")
+local RULE           = node.id("rule")
+local DISC           = node.id("disc")
+local GLUE           = node.id("glue")
+local GLYPH          = node.id("glyph")
+local KERN           = node.id("kern")
+local PENALTY        = node.id("penalty")
+local LOCAL_PAR      = node.id("local_par")
+local MATH           = node.id("math")
+
+local function @@_get_mathsubtype  (mathnode)
+ if mathnode.subtype == 0 then
+  subtype = "beginmath"
+ else
+  subtype = "endmath"
+ end
+ return subtype
+end
+
+
+
+ltx             = ltx        or { }
+ltx.@@          = ltx.@@        or { }
+ltx.@@.mc             = ltx.@@.mc     or  { } -- mc data
+ltx.@@.struct         = ltx.@@.struct or  { } -- struct data
+ltx.@@.tables         = ltx.@@.tables or  { } -- tables created with new prop and new seq.
+                                            -- wasn't a so great idea ...
+ltx.@@.page           = ltx.@@.page   or  { } -- page data, currently only i->{0->mcnum,1->mcnum,...}
+ltx.@@.trace          = ltx.@@.trace  or  { } -- show commands
+ltx.@@.func           = ltx.@@.func   or  { } -- functions
+ltx.@@.conf           = ltx.@@.conf   or  { } -- configuration variables
+
+local @@_log =
+ function (message,loglevel)
+  if (loglevel or 3) <= tex.count["l_@@_loglevel_int"] then
+   texio.write_nl("tagpdf: ".. message)
+  end
+ end
+
+ltx.@@.trace.log = @@_log
+
+
+local @@_get_mc_cnt_type_tag = function (n)
+  local mccnt      =  nodegetattribute(n,mccntattributeid)  or -1
+  local mctype     =  nodegetattribute(n,mctypeattributeid)  or -1
+  local tag        =  ltx.@@.func.get_tag_from(mctype)
+  return mccnt,mctype,tag
+end
+
+
+local function @@_insert_emc_node (head,current)
+ local emcnode = nodenew("whatsit","pdf_literal")
+       emcnode.data = "EMC"
+       emcnode.mode=1
+       head = node.insert_before(head,current,emcnode)
+ return head
+end
+
+
+local function @@_insert_bmc_node (head,current,tag)
+ local bmcnode = nodenew("whatsit","pdf_literal")
+       bmcnode.data = "/"..tag.." BMC"
+       bmcnode.mode=1
+       head = node.insert_before(head,current,bmcnode)
+ return head
+end
+
+local function @@_insert_bdc_node (head,current,tag,dict)
+ local bdcnode = nodenew("whatsit","pdf_literal")
+       bdcnode.data = "/"..tag.."<<"..dict..">> BDC"
+       bdcnode.mode=1
+       head = node.insert_before(head,current,bdcnode)
+ return head
+end
+
+-- this is for debugging the space chars
+local function @@_show_spacemark (head,current,color,height)
+ local markcolor = color or "1 0 0"
+ local markheight = height or 10
+ local pdfstring = node.new("whatsit","pdf_literal")
+       pdfstring.data =
+       string.format("q "..markcolor.." RG "..markcolor.." rg 0.4 w 0 %g m 0 %g l S Q",-3,markheight)
+       head = node.insert_after(head,current,pdfstring)
+ return head
+end
+
+--[[ a function to mark up places where real space chars should be inserted
+     it only sets an attribute.
+--]]
+
+local function @@_mark_spaces (head)
+  local inside_math = false
+  for n in nodetraverse(head) do
+    local id = n.id
+    if id == GLYPH then
+      local glyph = n
+      if glyph.next and (glyph.next.id == GLUE)
+        and not inside_math  and (glyph.next.width >0)
+      then
+        nodesetattribute(glyph.next,iwspaceattributeid,1)
+        nodesetattribute(glyph.next,iwfontattributeid,glyph.font)
+      -- for debugging
+       if ltx.@@.trace.showspaces then
+        @@_show_spacemark (head,glyph)
+       end
+      elseif glyph.next and (glyph.next.id==KERN) and not inside_math then
+       local kern = glyph.next
+       if kern.next and (kern.next.id== GLUE)  and (kern.next.width >0)
+       then
+        nodesetattribute(kern.next,iwspaceattributeid,1)
+        nodesetattribute(kern.next,iwfontattributeid,glyph.font)
+       end
+      end
+    elseif id == PENALTY then
+      local glyph = n
+      -- ltx.@@.trace.log ("PENALTY ".. n.subtype.."VALUE"..n.penalty,3)
+      if glyph.next and (glyph.next.id == GLUE)
+        and not inside_math  and (glyph.next.width >0) and n.subtype==0
+      then
+        nodesetattribute(glyph.next,iwspaceattributeid,1)
+      --  nodesetattribute(glyph.next,iwfontattributeid,glyph.font)
+      -- for debugging
+       if ltx.@@.trace.showspaces then
+        @@_show_spacemark (head,glyph)
+       end
+      end
+    elseif id == MATH then
+      inside_math = (n.subtype == 0)
+    end
+  end
+  return head
+end
+
+local function @@_activate_mark_space ()
+ if not luatexbase.in_callback ("pre_linebreak_filter","markspaces") then
+  luatexbase.add_to_callback("pre_linebreak_filter",@@_mark_spaces,"markspaces")
+  luatexbase.add_to_callback("hpack_filter",@@_mark_spaces,"markspaces")
+ end
+end
+
+ltx.@@.func.markspaceon=@@_activate_mark_space
+
+local function @@_deactivate_mark_space ()
+ if luatexbase.in_callback ("pre_linebreak_filter","markspaces") then
+ luatexbase.remove_from_callback("pre_linebreak_filter","markspaces")
+ luatexbase.remove_from_callback("hpack_filter","markspaces")
+ end
+end
+--
+ltx.@@.func.markspaceoff=@@_deactivate_mark_space
+
+local default_space_char = node.new(GLYPH)
+local default_fontid     = font.id("TU/lmr/m/n/10")
+default_space_char.char  = 32
+default_space_char.font  = default_fontid
+
+local function @@_insert_space_char (head,n,fontid)
+ if luaotfload.aux.slot_of_name(fontid,"space") then
+  local space
+  -- head, space = node.insert_before(head, n, ) -- Set the right font
+  -- n.width = n.width - space.width
+  -- space.attr = n.attr
+ end
+end
+
+--[[
+    Now follows the core function
+    It wades through the shipout box and checks the attributes
+    ARGUMENTS
+    box: is a box,
+    mcpagecnt: num, the current page cnt of mc (should start at -1 in shipout box), needed for recursion
+    mccntprev: num, the attribute cnt of the previous node/whatever - if different we have a chunk border
+    mcopen: num, records if some bdc/emc is open
+    These arguments are only needed for log messages, if not present are replaces by fix strings:
+    name: string to describe the box
+    mctypeprev: num, the type attribute of the previous node/whatever
+
+    there are lots of logging messages currently. Should be cleaned up in due course.
+    One should also find ways to make the function shorter.
+--]]
+
+function ltx.@@.func.mark_page_elements (box,mcpagecnt,mccntprev,mcopen,name,mctypeprev)
+  local name = name or ("SOMEBOX")
+  local mctypeprev = mctypeprev or -1
+  local abspage = status.total_pages + 1  -- the real counter is increased inside the box so one off
+                                                                       -- if the callback is not used.
+  ltx.@@.trace.log ("PAGE " .. abspage,3)
+  ltx.@@.trace.log ("FUNC ARGS: pagecnt".. mcpagecnt.." prev "..mccntprev .. " type prev "..mctypeprev,4)
+  ltx.@@.trace.log ("TRAVERSING BOX ".. tostring(name).." TYPE ".. node.type(node.getid(box)),3)
+  local head = box.head -- ShipoutBox is a vlist?
+  if head then
+    mccnthead, mctypehead,taghead = @@_get_mc_cnt_type_tag (head)
+    ltx.@@.trace.log ("HEAD " .. node.type(node.getid(head)).. " MC"..tostring(mccnthead).." => TAG "..tostring(mctypehead).." => "..tostring(taghead),3)
+  else
+    ltx.@@.trace.log ("HEAD is ".. tostring(head),3)
+  end
+  for n in node.traverse(head) do
+    local mccnt, mctype, tag = @@_get_mc_cnt_type_tag (n)
+    local spaceattr = nodegetattribute(n,iwspaceattributeid)  or -1
+    ltx.@@.trace.log ("NODE ".. node.type(node.getid(n)).." MC"..tostring(mccnt).." => TAG "..tostring(mctype).." => " .. tostring(tag),3)
+    if n.id == HLIST
+    then -- enter the hlist
+     mcopen,mcpagecnt,mccntprev,mctypeprev=
+      ltx.@@.func.mark_page_elements (n,mcpagecnt,mccntprev,mcopen,"INTERNAL HLIST",mctypeprev)
+    elseif n.id == VLIST then -- enter the vlist
+     mcopen,mcpagecnt,mccntprev,mctypeprev=
+      ltx.@@.func.mark_page_elements (n,mcpagecnt,mccntprev,mcopen,"INTERNAL VLIST",mctypeprev)
+    elseif n.id == GLUE then       -- at glue real space chars are inserted, for the rest it is ignored
+     -- for debugging
+     if ltx.@@.trace.showspaces and spaceattr==1  then
+        @@_show_spacemark (head,n,"0 1 0")
+     end
+     if spaceattr==1  then
+        local space
+        local space_char = node.copy(default_space_char)
+        local curfont    = nodegetattribute(n,iwfontattributeid)
+        ltx.@@.trace.log ("FONT ".. tostring(curfont),3)
+        if curfont and luaotfload.aux.slot_of_name(curfont,"space") then
+          space_char.font=curfont
+        end
+        head, space = node.insert_before(head, n, space_char) --
+        n.width     = n.width - space.width
+        space.attr  = n.attr
+     end
+    elseif n.id == LOCAL_PAR then  -- local_par is ignored
+    elseif n.id == PENALTY then    -- penalty is ignored
+    elseif n.id == KERN then       -- kern is ignored
+     ltx.@@.trace.log ("SUBTYPE KERN ".. n.subtype,3)
+    else
+     -- math is currently only logged.
+     -- we could mark the whole as math
+     -- for inner processing the mlist_to_hlist callback is probably needed.
+     if n.id == MATH then
+      ltx.@@.trace.log("NODE "..node.type(node.getid(n)).." "..@@_get_mathsubtype(n),3)
+     end
+     -- endmath
+     ltx.@@.trace.log("CURRENT "..mccnt.." PREV "..mccntprev,3)
+     if mccnt~=mccntprev then -- a new mc chunk
+      ltx.@@.trace.log ("NODE ".. node.type(node.getid(n)).." MC"..tostring(mccnt).." <=> PREVIOUS "..tostring(mccntprev),3)
+      if mcopen~=0 then -- there is a chunk open, close it (hope there is only one ...
+       box.list=@@_insert_emc_node (box.list,n)
+       mcopen = mcopen - 1
+       ltx.@@.trace.log ("INSERT EMC " .. mcpagecnt .. " MCOPEN = " .. mcopen,2)
+       if mcopen ~=0 then
+        ltx.@@.trace.log ("!WARNING! open mc" .. " MCOPEN = " .. mcopen,1)
+       end
+      end
+      if ltx.@@.mc[mccnt] then
+       if ltx.@@.mc[mccnt]["artifact"] then
+        ltx.@@.trace.log("THIS IS AN ARTIFACT of type "..tostring(ltx.@@.mc[mccnt]["artifact"]),3)
+        if ltx.@@.mc[mccnt]["artifact"] == "" then
+         box.list = @@_insert_bmc_node (box.list,n,"Artifact")
+        else
+         box.list = @@_insert_bdc_node (box.list,n,"Artifact", "/Type /"..ltx.@@.mc[mccnt]["artifact"])
+        end
+       else
+        ltx.@@.trace.log("THIS IS A TAG "..tostring(tag),3)
+        mcpagecnt = mcpagecnt +1
+        ltx.@@.trace.log ("INSERT BDC "..mcpagecnt,2)
+        local dict= "/MCID "..mcpagecnt
+        if ltx.@@.mc[mccnt]["raw"] then
+         ltx.@@.trace.log("RAW CONTENT"..tostring(ltx.@@.mc[mccnt]["raw"]),3)
+         dict= dict .. " " .. ltx.@@.mc[mccnt]["raw"]
+        end
+        if ltx.@@.mc[mccnt]["alt"] then
+         ltx.@@.trace.log("RAW CONTENT"..tostring(ltx.@@.mc[mccnt]["alt"]),3)
+         dict= dict .. " " .. ltx.@@.mc[mccnt]["alt"]
+        end
+        if ltx.@@.mc[mccnt]["actualtext"] then
+         ltx.@@.trace.log("RAW CONTENT"..tostring(ltx.@@.mc[mccnt]["actualtext"]),3)
+         dict= dict .. " " .. ltx.@@.mc[mccnt]["actualtext"]
+        end
+        box.list = @@_insert_bdc_node (box.list,n,tag, dict)
+        ltx.@@.func.store_mc_kid (mccnt,mcpagecnt,abspage)
+        ltx.@@.func.store_mc_in_page(mccnt,mcpagecnt,abspage)
+        ltx.@@.trace.show_mc_data (mccnt)
+       end
+       mcopen = mcopen + 1
+      else
+       ltx.@@.trace.log("THIS HAS NOT BEEN TAGGED",1)
+     -- perhaps code that tag a artifact can be added ...
+       if tagunmarkedbool.mode == truebool.mode then
+        box.list = @@_insert_bmc_node (box.list,n,"Artifact")
+        mcopen = mcopen + 1
+       end
+      end
+      mccntprev = mccnt
+     end
+    end -- end if
+  end -- end for
+  if head then
+    mccnthead, mctypehead,taghead = @@_get_mc_cnt_type_tag (head)
+    ltx.@@.trace.log ("ENDHEAD " .. node.type(node.getid(head)).. " MC"..tostring(mccnthead).." => TAG "..tostring(mctypehead).." => "..tostring(taghead),3)
+  else
+    ltx.@@.trace.log ("ENDHEAD is ".. tostring(head),3)
+  end
+  ltx.@@.trace.log ("QUITTING TRAVERSING BOX ".. tostring(name).." TYPE ".. node.type(node.getid(box)),3)
+ return mcopen,mcpagecnt,mccntprev,mctypeprev
+end
+
+
+
+function ltx.__tag.func.mark_shipout (box)
+ mcopen = ltx.__tag.func.mark_page_elements (box,-1,-100,0,"Shipout",-1)
+ if mcopen~=0 then -- there is a chunk open, close it (hope there is only one ...
+  local emcnode = nodenew("whatsit","pdf_literal")
+  local list = box.list
+  emcnode.data = "EMC"
+  emcnode.mode=1
+  if list then
+     list = node.insert_after (list,node.tail(list),emcnode)
+     mcopen = mcopen - 1
+     ltx.__tag.trace.log ("INSERT LAST EMC, MCOPEN = " .. mcopen,2)
+  else
+     ltx.__tag.trace.log ("UPS ",1)
+  end
+  if mcopen ~=0 then
+     ltx.__tag.trace.log ("!WARNING! open mc" .. " MCOPEN = " .. mcopen,1)
+  end
+ end
+end
+
+
+function ltx.@@.trace.show_seq (seq)
+ if (type(seq) == "table") then
+  for i,v in ipairs(seq) do
+   @@_log ("[" .. i .. "] => " .. tostring(v),1)
+  end
+  else
+   @@_log ("sequence " .. tostring(seq) .. " not found",1)
+  end
+end
+
+local @@_pairs_prop =
+ function  (prop)
+      local a = {}
+      for n in pairs(prop) do tableinsert(a, n) end
+      table.sort(a)
+      local i = 0                -- iterator variable
+      local iter = function ()   -- iterator function
+        i = i + 1
+        if a[i] == nil then return nil
+        else return a[i], prop[a[i]]
+        end
+      end
+      return iter
+  end
+
+
+function ltx.@@.trace.show_prop (prop)
+ if (type(prop) == "table") then
+  for i,v in @@_pairs_prop (prop) do
+    @@_log ("[" .. i .. "] => " .. tostring(v),1)
+  end
+ else
+   @@_log ("prop " .. tostring(prop) .. " not found or not a table",1)
+ end
+ end
+
+
+local @@_get_num_from =
+ function (tag)
+  if ltx.@@.tables["g_@@_role_tags_prop"][tag] then
+    a= ltx.@@.tables["g_@@_role_tags_prop"][tag]
+  else
+    a= -1
+  end
+  return a
+ end
+
+ltx.@@.func.get_num_from = @@_get_num_from
+
+function ltx.@@.func.output_num_from (tag)
+  local num = @@_get_num_from (tag)
+  tex.sprint(catlatex,num)
+  if num == -1 then
+   @@_log ("Unknown tag "..tag.." used")
+  end
+end
+
+local @@_get_tag_from =
+ function  (num)
+  if ltx.@@.tables["g_@@_role_tags_seq"][num] then
+   a = ltx.@@.tables["g_@@_role_tags_seq"][num]
+  else
+   a= "UNKNOWN"
+  end
+ return a
+end
+
+ltx.@@.func.get_tag_from = @@_get_tag_from
+
+function ltx.@@.func.output_tag_from (num)
+  tex.sprint(catlatex,@@_get_tag_from (num))
+end
+
+function ltx.@@.func.store_mc_data (num,key,data)
+ ltx.@@.mc[num] = ltx.@@.mc[num] or { }
+ ltx.@@.mc[num][key] = data
+ @@_log  ("storing mc"..num..": "..tostring(key).."=>"..tostring(data))
+end
+
+function ltx.@@.trace.show_mc_data (num)
+ if ltx.@@ and ltx.@@.mc and ltx.@@.mc[num] then
+  for k,v in pairs(ltx.@@.mc[num]) do
+   @@_log  ("mc"..num..": "..tostring(k).."=>"..tostring(v),3)
+  end
+  if ltx.@@.mc[num]["kids"] then
+  @@_log ("mc" .. num .. " has " .. #ltx.@@.mc[num]["kids"] .. " kids",3)
+   for k,v in ipairs(ltx.@@.mc[num]["kids"]) do
+    @@_log ("mc ".. num .. " kid "..k.." =>" .. v.kid.." on page " ..v.page,3)
+   end
+  end
+ else
+  @@_log  ("mc"..num.." not found",3)
+ end
+end
+
+function ltx.@@.trace.show_all_mc_data (max)
+ for i = 1, max do
+  ltx.@@.trace.show_mc_data (i)
+ end
+end
+
+
+function ltx.@@.func.store_mc_label (label,num)
+ ltx.@@.mc["labels"] = ltx.@@.mc["labels"] or { }
+ ltx.@@.mc.labels[label] = num
+end
+
+function ltx.@@.func.store_mc_kid (mcnum,kid,page)
+ ltx.@@.trace.log("MC"..mcnum.." STORING KID" .. kid.." on page " .. page,3)
+ ltx.@@.mc[mcnum]["kids"] = ltx.@@.mc[mcnum]["kids"] or { }
+ local kidtable = {kid=kid,page=page}
+ tableinsert(ltx.@@.mc[mcnum]["kids"], kidtable )
+end
+
+
+function ltx.@@.func.mc_num_of_kids (mcnum)
+ local num = 0
+ if ltx.@@.mc[mcnum] and ltx.@@.mc[mcnum]["kids"] then
+   num = #ltx.@@.mc[mcnum]["kids"]
+ end
+ ltx.@@.trace.log ("MC" .. mcnum .. "has " .. num .. "KIDS",4)
+ return num
+end
+
+function ltx.@@.func.mc_insert_kids (mcnum,single)
+  if ltx.@@.mc[mcnum] then
+  ltx.@@.trace.log("MC-KIDS test " .. mcnum,4)
+   if ltx.@@.mc[mcnum]["kids"] then
+    if #ltx.@@.mc[mcnum]["kids"] > 1 and single==1 then
+     tex.sprint("[")
+    end
+    for i,kidstable in ipairs( ltx.@@.mc[mcnum]["kids"] ) do
+     local kidnum  = kidstable["kid"]
+     local kidpage = kidstable["page"]
+     local kidpageobjnum = pdfpageref(kidpage)
+     ltx.@@.trace.log("MC" .. mcnum .. " insert KID " ..i.. " with num " .. kidnum .. " on page " .. kidpage.."/"..kidpageobjnum,3)
+     tex.sprint(catlatex,"<</Type /MCR /Pg "..kidpageobjnum .. " 0 R /MCID "..kidnum.. ">> " )
+    end
+    if #ltx.@@.mc[mcnum]["kids"] > 1 and single==1 then
+     tex.sprint("]")
+    end
+   else
+    ltx.@@.trace.log("WARN! MC"..mcnum.." has no kids",0)
+    if single==1 then
+      tex.sprint("null")
+    end
+   end
+  else
+   ltx.@@.trace.log("WARN! MC"..mcnum.." doesn't exist",0)
+  end
+end
+
+
+function ltx.@@.func.store_struct_mcabs (structnum,mcnum)
+ ltx.@@.struct[structnum]=ltx.@@.struct[structnum] or { }
+ ltx.@@.struct[structnum]["mc"]=ltx.@@.struct[structnum]["mc"] or { }
+ -- a structure can contain more than on mc chunk, the content should be ordered
+ tableinsert(ltx.@@.struct[structnum]["mc"],mcnum)
+ ltx.@@.trace.log("MCNUM "..mcnum.." insert in struct "..structnum,3)
+ -- but every mc can only be in one structure
+ ltx.@@.mc[mcnum]= ltx.@@.mc[mcnum] or { }
+ ltx.@@.mc[mcnum]["parent"] = structnum
+end
+
+function ltx.@@.trace.show_struct_data (num)
+ if ltx.@@ and ltx.@@.struct and ltx.@@.struct[num] then
+  for k,v in ipairs(ltx.@@.struct[num]) do
+   @@_log  ("struct "..num..": "..tostring(k).."=>"..tostring(v))
+  end
+ else
+  @@_log   ("struct "..num.." not found ")
+ end
+end
+
+-- pay attention: lua counts arrays from 1, tex pages from one
+-- mcid and arrays in pdf count from 0.
+function ltx.@@.func.store_mc_in_page (mcnum,mcpagecnt,page)
+ ltx.@@.page[page] = ltx.@@.page[page] or {}
+ ltx.@@.page[page][mcpagecnt] = mcnum
+ ltx.@@.trace.log("PAGE " .. page .. ": inserting MCID " .. mcpagecnt .. " => " .. mcnum,3)
+end
+
+function ltx.@@.func.fill_parent_tree_line (page)
+     -- we need to get page-> i=kid -> mcnum -> structnum
+     -- pay attention: the kid numbers and the page number in the parent tree start with 0!
+    local numsentry =""
+    local pdfpage = page-1
+    if ltx.@@.page[page] and ltx.@@.page[page][0] then
+     mcchunks=#ltx.@@.page[page]
+     ltx.@@.trace.log("PAGETREE PAGE "..page.." has "..mcchunks.."+1 Elements ",3)
+     for i=0,mcchunks do
+      ltx.@@.trace.log("PAGETREE CHUNKS "..ltx.@@.page[page][i],3)
+     end
+     if mcchunks == 0 then
+      -- only one chunk so no need for an array
+      local mcnum  = ltx.@@.page[page][0]
+      local structnum = ltx.@@.mc[mcnum]["parent"]
+      local propname  = "g_@@_struct_"..structnum.."_prop"
+      local objref   =  ltx.@@.tables[propname]["objref"] or "XXXX"
+       texio.write_nl("=====>"..tostring(objref))
+      numsentry = pdfpage .. " [".. objref .. "]"
+      ltx.@@.trace.log("PAGETREE PAGE" .. page.. " NUM ENTRY = ".. numsentry,3)
+     else
+      numsentry = pdfpage .. " ["
+       for i=0,mcchunks do
+        local mcnum  = ltx.@@.page[page][i]
+        local structnum = ltx.@@.mc[mcnum]["parent"] or 0
+        local propname  = "g_@@_struct_"..structnum.."_prop"
+        local objref   =  ltx.@@.tables[propname]["objref"] or "XXXX"
+        numsentry = numsentry .. " ".. objref
+       end
+      numsentry = numsentry .. "] "
+      ltx.@@.trace.log("PAGETREE PAGE" .. page.. " NUM ENTRY = ".. numsentry,3)
+     end
+    else
+      ltx.@@.trace.log ("PAGETREE: NO DATA FOR PAGE "..page,3)
+    end
+    return numsentry
+end
+
+function ltx.@@.func.output_parenttree (abspage)
+ for i=1,abspage do
+  line = ltx.@@.func.fill_parent_tree_line (i) .. "^^J"
+  tex.sprint(catlatex,line)
+ end
+end
+
+
+%</lua>
+%    \end{macrocode}


Property changes on: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx	                        (rev 0)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx	2021-02-23 22:24:07 UTC (rev 57857)
@@ -0,0 +1,232 @@
+% \iffalse meta-comment
+%
+%% File: tagpdf-checks.dtx
+%
+% Copyright (C) 2019-2020 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.
+%
+% -----------------------------------------------------------------------
+%
+% The development version of the bundle can be found at
+%
+%    https://github.com/u-fischer/tagpdf
+%
+% for those people who are interested.
+%
+% \fi
+%
+%    \begin{macrocode}
+%<@@=tag>
+%<*checks>
+\ProvidesExplPackage {tagpdf-checks-code} {2021/02/23} {0.80}
+ {part of tagpdf - code related to checks and messages}
+
+
+%messages
+
+% mc
+\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} { label~#1~unknown~-~rerun }
+\msg_new:nnn { tag } {mc-used-twice}    { mc~#1~has~been~already~used }
+\msg_new:nnn { tag } {mc-not-open}      { there~is~no~mc~to~end~at~#1 }
+
+% structures
+\msg_new:nnn { tag } {struct-no-objnum}      { objnum~missing~for~structure~#1 }
+\msg_new:nnn { tag } {struct-faulty-nesting} { there~is~no~open~structure~on~the~stack }
+\msg_new:nnn { tag } {struct-missing-tag}    { a~structure~must~have~a~tag! }
+\msg_new:nnn { tag } {struct-show-closing}   { closing~structure~#1~tagged~\prop_item:cn{g_@@_struct_#1_prop}{S} }
+\msg_new:nnn { tag } {struct-used-twice}     { structure~with~label~#1~has~already~been~used}
+\msg_new:nnn { tag } {struct-label-unknown}  { structure~with~label~#1~is~unknown~rerun}
+
+% attributes
+\msg_new:nnn { tag } {attr-unknown}  { attribute~#1~is~unknown}
+
+
+%Roles
+\msg_new:nnn { tag } {role-missing}     { tag~#1~has~no~role~assigned  }
+\msg_new:nnn { tag } {role-unknown}     { role~#1~is~not~known  }
+\msg_new:nnn { tag } {role-unknown-tag} { tag~#1~is~not~known  }
+\msg_new:nnn { tag } {role-new-tag}     { adding~new~tag~#1~mapped~to~role~#2  }
+
+
+% trees
+\msg_new:nnn { tag } {tree-mcid-index-wrong} {something~is~wrong~with~the~mcid}
+
+% obj
+\msg_new:nnn { tag } {obj-write-num} {write~obj~#1~to~pdf}
+
+% engine problem
+\msg_new:nnn { tag } {sys-no-interwordspace} {engine~#1~doesn't~support~the~interword~spaces}
+
+%checks
+%structures
+
+\cs_new:Nn \@@_check_structure_has_tag:n %#1 struct num %_protected?
+  {
+    \prop_if_in:cnF { g_@@_struct_#1_prop }
+      {S}
+      {
+        \msg_error:nn { tag } {struct-missing-tag}
+      }
+  }
+
+\cs_new:Nn \@@_check_structure_tag:N            %_protected?
+  {
+    \prop_if_in:NoF \g_@@_role_tags_prop {#1}
+      {
+        \msg_warning:nnx { tag } {role-unknown-tag} {#1}
+      }
+  }
+
+\cs_new_protected:Nn \@@_check_info_closing_struct:n %#1 struct num
+  {
+    \msg_info:nnn { tag } {struct-show-closing} {#1}
+  }
+
+\cs_generate_variant:Nn \@@_check_info_closing_struct:n {o,x}
+
+\cs_new_protected:Nn \@@_check_no_open_struck:
+  {
+    \msg_error:nn { tag } {struct-faulty-nesting}
+  }
+
+\cs_new_protected:Nn \@@_check_struct_used:n %#1 label
+  {
+    \prop_get:cnNT
+      {g_@@_struct_\@@_ref_value:enn{tagpdfstruct-#1}{tagstruct}{unknown}_prop}
+      {P}
+      \l_tmpa_tl
+      {
+        \msg_warning:nnn { tag } {struct-used-twice} {#1}
+      }
+  }
+
+%roles
+
+\cs_new_protected:Nn \@@_check_add_tag_role:nn %#1 tag, #2 role
+  {
+    \tl_if_empty:nTF {#2}
+      {
+        \msg_warning:nnn { tag } {role-missing} {#1}
+      }
+      {
+        \prop_get:NnNTF \g_@@_role_tags_prop {#2} \l_tmpa_tl
+          {
+            \msg_info:nnnn { tag } {role-new-tag} {#1} {#2}
+          }
+          {
+            \msg_warning:nnn { tag } {role-unknown} {#2}
+          }
+      }
+  }
+
+%mc
+\cs_new_protected:Nn \@@_check_mc_if_nested:
+  {
+    \@@_mc_if_in:T
+      {
+        \msg_warning:nnx { tag } {mc-nested} { \@@_get_mc_abs_cnt: }
+      }
+  }
+
+\cs_new_protected:Nn \@@_check_mc_if_open:
+  {
+    \@@_mc_if_in:F
+      {
+        \msg_warning:nnx { tag } {mc-not-open} { \@@_get_mc_abs_cnt: }
+      }
+  }
+
+\cs_new:Nn \@@_check_mc_tag:N %protected??
+  {
+    \tl_if_empty:NT #1
+      {
+        \msg_error:nnx { tag } {mc-tag-missing} { \@@_get_mc_abs_cnt: }
+      }
+   \prop_if_in:NoF \g_@@_role_tags_prop {#1}
+     {
+       \msg_warning:nnx { tag } {role-unknown-tag} {#1}
+     }
+  }
+
+\seq_new:N \g_@@_check_mc_used_seq
+\cs_new_protected:Nn \@@_check_mc_used:n
+  {
+    \seq_if_in:NnTF \g_@@_check_mc_used_seq {#1}
+      {
+        \msg_warning:nnn { tag } {mc-used-twice} {#1}
+      }
+      {
+        \seq_gput_right:Nx \g_@@_check_mc_used_seq {#1}
+      }
+  }
+
+
+
+\cs_new_protected:Nn \@@_check_show_MCID_by_page:
+  {
+    \tl_set:Nx \l_@@_tmpa_tl
+      {
+        \@@_ref_value_lastpage:nn
+          {abspage}
+          {-1}
+      }
+    \int_step_inline:nnnn {1}{1}
+      {
+        \l_@@_tmpa_tl
+      }
+      {
+        \seq_clear:N \l_tmpa_seq
+        \int_step_inline:nnnn
+          {1}
+          {1}
+          {
+            \@@_ref_value_lastpage:nn
+              {tagmcabs}
+              {-1}
+          }
+          {
+            \int_compare:nT
+              {
+                \@@_ref_value:enn
+                  {mcid-####1}
+                  {tagabspage}
+                  {-1}
+                =
+                ##1
+             }
+             {
+               \seq_gput_right:Nx \l_tmpa_seq
+                 {
+                   Page##1-####1-
+                   \@@_ref_value:enn
+                     {mcid-####1}
+                     {tagmcid}
+                     {-1}
+                 }
+             }
+          }
+          \seq_show:N \l_tmpa_seq
+      }
+  }
+
+\cs_new:Nn \@@_check_record_pdfobj_num:n %protected?
+  {
+    \int_compare:nT { \l_@@_loglevel_int >= 3 }
+      {
+        \msg_info:nnx { tag } {obj-write-num} {#1}
+      }
+  }
+
+%</checks>
+%    \end{macrocode}


Property changes on: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc.dtx	                        (rev 0)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc.dtx	2021-02-23 22:24:07 UTC (rev 57857)
@@ -0,0 +1,779 @@
+% \iffalse meta-comment
+%
+%% File: tagpdf-mc.dtx
+%
+% Copyright (C) 2019-2020 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.
+%
+% -----------------------------------------------------------------------
+%
+% The development version of the bundle can be found at
+%
+%    https://github.com/u-fischer/tagpdf
+%
+% for those people who are interested.
+%
+% \fi
+%
+%    \begin{macrocode}
+%<@@=tag>
+%<*shared>
+\ProvidesExplPackage {tagpdf-mc-code-shared} {2021/02/23} {0.80}
+  {part of tagpdf - code related to marking chunks -
+   code shared by generic and luamode }
+% I use a latex counter for the absolute count, so that it is added to
+% \cl@@ckpt and restored e.g. in tabulars and align
+% \int_new:N  \c at g_@@_MCID_int and
+% \tl_put_right:Nn\cl@@ckpt{\@elt{g_uf_test_int}}
+% would work too, but as the name is not expl3 then too, why bother?
+% the absolute counter can be used to label and to check if the page
+% counter needs a reset.
+
+\newcounter { g_@@_MCID_abs_int }
+\cs_new:Nn \_@@_get_mc_abs_cnt: { \int_use:N \c at g_@@_MCID_abs_int }
+
+% tagmcabs is the label name of the absolute count which is used
+% to identify the chunk
+% the ref code is now in tagpdf.dtx
+
+%stores labels of mcid.
+\cs_new:Nn \_@@_mc_handle_mc_label:n
+  {
+    \@@_ref_label:en{tagpdf-#1}{mc}
+  }
+
+% will hold the structure numbers for the parenttree
+% key:   absolute number of the mc (tagmcabs)
+% value: the structure number the mc is in
+\_@@_prop_new:N \g_@@_mc_parenttree_prop
+
+% shared keys
+% the rest are in the splitted code
+\tl_new:N \l_@@_mc_artifact_type_tl
+
+\keys_define:nn { @@ / mc }
+  {
+    stash                  .bool_set:N    = \l_@@_mc_key_stash_bool,
+    artifact-bool          .bool_set:N    = \l_@@_mc_artifact_bool,
+    artifact-type          .choice:,
+    artifact-type / pagination .code:n    =
+      {
+        \tl_set:Nn \l_@@_mc_artifact_type_tl { Pagination }
+      },
+    artifact-type / layout     .code:n    =
+      {
+        \tl_set:Nn \l_@@_mc_artifact_type_tl { Layout }
+      },
+    artifact-type / page       .code:n    =
+      {
+        \tl_set:Nn \l_@@_mc_artifact_type_tl { Page }
+      },
+    artifact-type / background .code:n    =
+      {
+        \tl_set:Nn \l_@@_mc_artifact_type_tl { Background }
+      },
+    artifact-type / notype     .code:n    =
+      {
+        \tl_set:Nn \l_@@_mc_artifact_type_tl {}
+      },
+     artifact-type /      .code:n    =
+      {
+        \tl_set:Nn \l_@@_mc_artifact_type_tl {}
+      },
+  }
+%    \end{macrocode}
+%  \begin{function}[added = 2019-11-20]
+%   {
+%     \tag_mc_artifact_group_begin:n, \tag_mc_artifact_group_end:
+%   }
+%   \begin{syntax}
+%     \cs{tag_mc_artifact_group_begin:n} \Arg{name}
+%   \end{syntax}
+%   This command pair create a group with an artifact marker at the begin
+%   and the end. Inside the group the tagging commands are disabled.
+%   \end{function}
+%    \begin{macrocode}
+
+
+\cs_new_protected:Npn \tag_mc_artifact_group_begin:n #1
+ {
+  \tag_mc_begin:n {artifact=#1}
+  \tag_stop_group_begin:
+ }
+
+\cs_new_protected:Npn \tag_mc_artifact_group_end:
+ {
+  \tag_stop_group_end:
+  \tag_mc_end:
+ }
+
+% we need to define it for both modes to avoid a problem with the label
+\int_new:N \g_@@_MCID_tmp_bypage_int
+
+%</shared>
+%    \end{macrocode}
+%    \begin{macrocode}
+%<*generic>
+\ProvidesExplPackage {tagpdf-mc-code-generic} {2021/02/23} {0.80}
+ {part of tagpdf - code related to marking chunks - generic mode}
+
+% for the label system
+% tagmcid is the id which should be also in the pdf
+% it will be (hopefully) reset by page
+
+% ref code is in tagpdf.dtx now
+%
+% will hold the current maximum on a page
+% it will contain key-value of type "abspagenum=max mcid on this page"
+\@@_prop_new:N \g_@@_MCID_byabspage_prop
+
+%to test nesting mc:
+\bool_new:N \g_@@_in_mc_bool
+
+\prg_new_conditional:Nnn \@@_mc_if_in: {p,T,F,TF}
+  {
+    \bool_if:NTF \g_@@_in_mc_bool
+      { \prg_return_true:  }
+      { \prg_return_false: }
+  }
+
+\prg_new_eq_conditional:NNn \tag_mc_if_in: \@@_mc_if_in: {p,T,F,TF}
+
+%deprecated
+\prg_new_eq_conditional:NNn \uftag_mc_if_in: \@@_mc_if_in: {p,T,F,TF}
+
+
+% this are the low level mc command.
+% they insert literals and so a are specific to generic mode
+% checking if the type is defined will done somewhere else
+% #1 is the type/tag
+% change 04.08.2018: I don't try to escape the name, but assume that it is valid.
+% Checks/conversions should perhaps be done on a higher level
+\cs_new_protected:Nn \@@_mc_bmc:n
+  {
+    \pdf_bmc:n {#1}
+%    \@@_pdfliteral_page:n
+%      {
+%        /#1\c_space_tl BMC
+%      }
+  }
+
+\cs_new_protected:Nn \@@_mc_emc:
+  {
+    \pdf_emc:
+    %\@@_pdfliteral_page:n
+%      {
+%        EMC
+%      }
+  }
+
+% #1 tag, #2 properties
+% change 04.08.2018: I don't escape the name. Also the dictionary content
+% must imho be done at a higher level
+\cs_new_protected:Nn \@@_mc_bdc:nn
+  {
+    \pdf_bdc:nn { #1 } { #2 }
+  }
+
+\cs_generate_variant:Nn \@@_mc_bdc:nn {nx}
+% bdc with /MCID + more properties
+% we need a ref-label system to ensure that the cnt restarts at 0 on a new page
+
+\tl_new:N \l_@@_mc_ref_abspage_tl %will store the abspage value of label
+\tl_new:N \l_@@_mc_tmp_tl
+
+\cs_new:Nn \@@_mc_bdc_mcid:nn
+  {
+    \int_gincr:N \c at g_@@_MCID_abs_int
+    \tl_set:Nx \l_@@_mc_ref_abspage_tl
+      {
+        \@@_ref_value:enn %3 args
+          {
+            mcid-\int_use:N \c at g_@@_MCID_abs_int
+          }
+          { tagabspage }
+          {-1}
+      }
+    \prop_get:NoNTF
+      \g_@@_MCID_byabspage_prop
+      {
+        \l_@@_mc_ref_abspage_tl
+      }
+      \l_@@_mc_tmp_tl
+      {
+        %key already present, use value for MCID and add 1 for the next
+        \int_gset:Nn \g_@@_MCID_tmp_bypage_int { \l_@@_mc_tmp_tl }
+        \@@_prop_gput:Nxx
+          \g_@@_MCID_byabspage_prop
+          { \l_@@_mc_ref_abspage_tl }
+          { \int_eval:n {\l_@@_mc_tmp_tl +1} }
+      }
+      {
+        %key not present, set MCID to 0 and insert 1
+        \int_gzero:N \g_@@_MCID_tmp_bypage_int
+        \@@_prop_gput:Nxx
+          \g_@@_MCID_byabspage_prop
+          { \l_@@_mc_ref_abspage_tl }
+          {1}
+      }
+    \@@_ref_label:en
+      {
+        mcid-\int_use:N \c at g_@@_MCID_abs_int
+      }
+      { mc }
+   %\exp_args:Nnx
+     \@@_mc_bdc:nx
+       {#1}
+       { /MCID~\int_eval:n { \g_@@_MCID_tmp_bypage_int }~ \exp_not:n { #2 } }
+ }
+
+% only /MCID
+\cs_new:Nn \@@_mc_bdc_mcid:n
+  {
+    \@@_mc_bdc_mcid:nn {#1} {}
+  }
+
+%artifact without type
+\cs_new:Nn  \@@_mc_bmc_artifact:
+  {
+    \@@_mc_bmc:n {Artifact}
+  }
+
+%artifact with a type:
+\cs_new:Nn \@@_mc_bmc_artifact:n
+  {
+    \@@_mc_bdc:nn {Artifact}{/Type/#1}
+  }
+
+% perhaps later: more properties for artifacts
+
+
+% keyval definitions for the user commands:
+
+\tl_new:N \l_@@_mc_key_tag_tl
+\tl_new:N \g_@@_mc_key_tag_tl %for "outside" queries
+\tl_new:N \l_@@_mc_key_properties_tl
+
+% Attention! definitions are different in luamode.
+% tag and raw are expanded as \directlua in lua does it too.
+\keys_define:nn { @@ / mc }
+  {
+    tag .code:n = % the name (H,P,Spa) etc
+      {
+         %%????????? \pdfescapename??
+        \tl_set:Nx   \l_@@_mc_key_tag_tl { #1 }
+        \tl_gset:Nx  \g_@@_mc_key_tag_tl { #1 }
+      },
+    raw  .code:n =
+      {
+        \tl_put_right:Nx \l_@@_mc_key_properties_tl { #1 }
+      },
+    alttext .code:n = % Alt property
+      {
+        \str_set_convert:Nnon
+          \l_@@_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \tl_put_right:Nn \l_@@_mc_key_properties_tl { /Alt~< }
+        \tl_put_right:No \l_@@_mc_key_properties_tl { \l_@@_tmpa_str>~ }
+      },
+    alttext-o .code:n      = % Alt property
+      {
+        \str_set_convert:Noon
+          \l_@@_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \tl_put_right:Nn \l_@@_mc_key_properties_tl { /Alt~< }
+        \tl_put_right:No \l_@@_mc_key_properties_tl { \l_@@_tmpa_str>~ }
+      },
+    actualtext .code:n      = % ActualText property
+      {
+        \str_set_convert:Nnon
+          \l_@@_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \tl_put_right:Nn \l_@@_mc_key_properties_tl { /ActualText~< }
+        \tl_put_right:No \l_@@_mc_key_properties_tl { \l_@@_tmpa_str>~ }
+      },
+    actualtext-o .code:n      = % ActualText property
+      {
+        \str_set_convert:Noon
+          \l_@@_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \tl_put_right:Nn \l_@@_mc_key_properties_tl { /ActualText~< }
+        \tl_put_right:No \l_@@_mc_key_properties_tl { \l_@@_tmpa_str>~ }
+      },
+    label .tl_set:N        = \l_@@_mc_key_label_tl,
+    artifact .code:n       =
+      {
+        \exp_args:Nnx
+          \keys_set:nn
+            { @@ / mc }
+            { artifact-bool, artifact-type=#1 }
+      },
+    artifact .default:n    = {notype}
+  }
+
+\cs_new:Nn \@@_mc_handle_artifact:N %#1 contains the artifact type
+  {
+    \tl_if_empty:NTF #1
+      { \@@_mc_bmc_artifact: }
+      { \exp_args:No\@@_mc_bmc_artifact:n {#1} }
+  }
+
+\cs_new:Nn \@@_mc_handle_mcid:nn %#1 tag, #2 properties
+  {
+    \@@_mc_bdc_mcid:nn {#1} {#2}
+  }
+
+\cs_generate_variant:Nn \@@_mc_handle_mcid:nn {VV}
+
+% puts the absolute number of an mcid in the current structure
+\cs_new:Nn \@@_mc_handle_stash:n %1 mcidnum
+  {
+    \@@_check_mc_used:n {#1}
+    \@@_struct_kid_mc_gput_right:nn
+      { \g_@@_struct_stack_current_tl }
+      {#1}
+   \prop_gput:Nxx \g_@@_mc_parenttree_prop
+     {#1}
+     { \g_@@_struct_stack_current_tl }
+  }
+
+\cs_new_protected:Nn \tag_mc_begin:n
+  {
+    \group_begin: %hm
+    \@@_check_mc_if_nested:
+    \bool_gset_true:N \g_@@_in_mc_bool
+    \keys_set:nn { @@ / mc } {#1}
+    \bool_if:NTF \l_@@_mc_artifact_bool
+      { %handle artifact
+        \@@_mc_handle_artifact:N \l_@@_mc_artifact_type_tl
+      }
+      { %handle mcid type
+        \@@_check_mc_tag:N  \l_@@_mc_key_tag_tl
+        \@@_mc_handle_mcid:VV
+           \l_@@_mc_key_tag_tl
+           \l_@@_mc_key_properties_tl
+        \tl_if_empty:NF {\l_@@_mc_key_label_tl}
+          {
+            \@@_mc_handle_mc_label:n { \l_@@_mc_key_label_tl }
+          }
+        \bool_if:NF \l_@@_mc_key_stash_bool
+          {
+            \@@_mc_handle_stash:n { \int_use:N \c at g_@@_MCID_abs_int }
+          }
+      }
+    \group_end:
+  }
+
+%deprecated
+\cs_set_eq:NN \uftag_mc_begin:n \tag_mc_begin:n
+
+\cs_new_protected:Nn \tag_mc_end:
+  {
+    \@@_check_mc_if_open:
+    \bool_gset_false:N \g_@@_in_mc_bool
+    \tl_gset:Nn  \g_@@_mc_key_tag_tl { }
+    \@@_mc_emc:
+  }
+
+\cs_set_eq:NN \uftag_mc_end: \tag_mc_end:
+
+\cs_new_protected:Nn \tag_mc_use:n %#1: label name
+  {
+    \tl_set:Nx  \l_tmpa_tl { \@@_ref_value:enn{tagpdf-#1}{tagmcabs}{} }
+    \tl_if_empty:NTF\l_tmpa_tl
+      {
+        \msg_warning:nnn {tag} {mc-label-unknown} {#1}
+      }
+      {
+        \prop_gput:Nxx
+          \g_@@_mc_parenttree_prop
+          {
+            \@@_ref_value:enn {tagpdf-#1} {tagmcabs} {}
+          }
+          {
+            \g_@@_struct_stack_current_tl
+          }
+        \@@_struct_kid_mc_gput_right:nn
+          {
+            \g_@@_struct_stack_current_tl
+          }
+          {
+            \@@_ref_value:enn {tagpdf-#1} {tagmcabs} {}
+          }
+       }
+  }
+
+%deprecated
+\cs_set_eq:NN \uftag_mc_use:n \tag_mc_use:n
+
+\cs_new:Nn \@@_get_data_mc_tag: { \g_@@_mc_key_tag_tl }
+
+%</generic>
+%    \end{macrocode}
+%    \begin{macrocode}
+%<*luamode>
+\ProvidesExplPackage {tagpdf-mc-code-lua} {2021/02/23} {0.80}
+  {tagpdf - mc code only for the luamode }
+
+% the two attibutes are defined in the driver file.
+% it also load the lua (as it can also contain functions needed by generic mode.
+% (new) attributes for mc are local:
+% \newattribute \l_@@_mc_type_attr     %the value represent the type
+% \newattribute \l_@@_mc_cnt_attr      %will hold the \c at g_@@_MCID_abs_int value
+
+
+% An attribute for the current structure probably doesn't make sense as mc chunks can be used later.
+% \newattribute \g_@@_struct_type_attr %represent the current structure type. Not sure if needed
+% \newattribute \g_@@_struct_cnt_attr  %will hold \c at g_@@_struct_abs_int a cnt
+
+% handling attribute needs a different system to number the page wise mcid's:
+% a tagmcbegin ... tagmcend pair no longer surrounds exactly one mc chunk: it can be split
+% at page breaks. We know the included mcid(s) only after the ship out. So for the struct-> mcid mapping we
+% need to record struct -> mc-cnt (in \g_@@_mc_parenttree_prop and/or a lua table
+% and at shipout mc-cnt-> {mcid, mcid, ...} (in a table?)
+% and when building the trees connect both
+
+% key definitions are overwritten for luatex to store that data in tables
+% the data for the mc are in ltx.@@.mc[absnum]
+% the fields of the table are
+% tag : the type (a string)
+% raw : more properties (string)
+% label: a string. Do we need a way to retrieve the num from the label from lua??
+% artifact: the presence indicates an artifact, the value (string) is the type.
+% kids: a array of tables {1={kid=num2,page=pagenum1}, 2={kid=num2,page=pagenum2},...},
+% this describes the chunks the mc has been split to by the traversing code
+% parent: the number of the structure it is in. Needed to build the parent tree.
+
+% The main function which wanders through the shipout box to inject the literals.
+% if the new callback is there, it is used.
+\hook_gput_code:nnn{begindocument}{tagpdf/mc}
+  {
+    \bool_if:NT\g__tag_active_mc_bool
+      {
+        \directlua
+          {
+            if~luatexbase.callbacktypes.pre_shipout_filter~then~
+              luatexbase.add_to_callback("pre_shipout_filter", function(TAGBOX)~
+              ltx.__tag.func.mark_shipout(TAGBOX)~return~true~
+              end, "tagpdf")~
+            end
+          }
+       \directlua
+         {
+           if~luatexbase.callbacktypes.pre_shipout_filter~then~
+           token.get_next()~
+           end
+         }\@secondoftwo\@gobble
+           {
+             \hook_gput_code:nnn{shipout/before}{tagpdf/lua}
+               {
+                 \directlua
+                   { ltx.__tag.func.mark_shipout (tex.box["ShipoutBox"]) }
+               }
+           }
+      }
+  }
+
+\prg_new_conditional:Nnn \@@_mc_if_in: {p,T,F,TF}
+  {
+    \int_compare:nNnTF { -2147483647 }={ \l_@@_mc_type_attr }
+      { \prg_return_false:  }
+      { \prg_return_true: }
+  }
+
+\prg_new_eq_conditional:NNn \tag_mc_if_in: \@@_mc_if_in: {p,T,F,TF}
+
+%deprecated
+\prg_new_eq_conditional:NNn \uftag_mc_if_in: \@@_mc_if_in: {p,T,F,TF}
+
+% the keys
+\tl_new:N \l_@@_mc_key_tag_tl
+\tl_new:N \l_@@_mc_key_label_tl
+\tl_new:N \l_@@_mc_key_properties_tl
+
+\keys_define:nn { @@ / mc }
+  {
+    tag .code:n = %
+      {%%????????? \pdfescapename??
+        \tl_set:Nx  \l_@@_mc_key_tag_tl { #1 }
+        \directlua
+          {
+            ltx.@@.func.store_mc_data(\@@_get_mc_abs_cnt:,"tag","#1")
+          }
+      },
+    raw .code:n =
+      {
+        \tl_put_right:Nx \l_@@_mc_key_properties_tl { #1 }
+        \directlua
+          {
+            ltx.@@.func.store_mc_data(\@@_get_mc_abs_cnt:,"raw","#1")
+          }
+      },
+    alttext .code:n      = % Alt property
+      {
+        \str_set_convert:Nnon
+          \l_@@_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \tl_put_right:Nn \l_@@_mc_key_properties_tl { /Alt~< }
+        \tl_put_right:No \l_@@_mc_key_properties_tl { \l_@@_tmpa_str>~ }
+        \directlua
+          {
+            ltx.@@.func.store_mc_data
+              (
+                 \@@_get_mc_abs_cnt:,"alt","/Alt~<\str_use:N \l_@@_tmpa_str>"
+              )
+          }
+      },
+    alttext-o .code:n      = % Alt property
+      {
+        \str_set_convert:Noon
+          \l_@@_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \tl_put_right:Nn \l_@@_mc_key_properties_tl { /Alt~< }
+        \tl_put_right:No \l_@@_mc_key_properties_tl { \l_@@_tmpa_str>~ }
+        \directlua
+          {
+            ltx.@@.func.store_mc_data
+              (
+                \@@_get_mc_abs_cnt:,"alt","/Alt~<\str_use:N \l_@@_tmpa_str>"
+              )
+          }
+      },
+    actualtext .code:n      = % Alt property
+      {
+        \str_set_convert:Nnon
+          \l_@@_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \tl_put_right:Nn \l_@@_mc_key_properties_tl { /Alt~< }
+        \tl_put_right:No \l_@@_mc_key_properties_tl { \l_@@_tmpa_str>~ }
+        \directlua
+          {
+            ltx.@@.func.store_mc_data
+              (
+                \@@_get_mc_abs_cnt:,"actualtext","/ActualText~<\str_use:N \l_@@_tmpa_str>"
+              )
+         }
+      },
+    actualtext-o .code:n      = % Alt property
+      {
+        \str_set_convert:Noon
+          \l_@@_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \tl_put_right:Nn \l_@@_mc_key_properties_tl { /Alt~< }
+        \tl_put_right:No \l_@@_mc_key_properties_tl { \l_@@_tmpa_str>~ }
+        \directlua
+          {
+            ltx.@@.func.store_mc_data
+              (
+                \@@_get_mc_abs_cnt:,
+                "actualtext",
+                "/ActualText~<\str_use:N \l_@@_tmpa_str>"
+              )
+          }
+      },
+    label .code:n =
+      {
+        \tl_set:Nn\l_@@_mc_key_label_tl { #1 }
+        \directlua
+          {
+            ltx.@@.func.store_mc_data
+              (
+                \@@_get_mc_abs_cnt:,"label","#1"
+              )
+          }
+      },
+    __artifact-store .code:n =
+      {
+        \directlua
+          {
+            ltx.@@.func.store_mc_data
+              (
+                \@@_get_mc_abs_cnt:,"artifact","#1"
+              )
+          }
+      },
+    artifact .code:n       =
+      {
+        \exp_args:Nnx
+          \keys_set:nn
+            { @@ / mc}
+            { artifact-bool, artifact-type=#1, tag=Artifact }
+        \exp_args:Nnx
+          \keys_set:nn
+            { @@ / mc }
+            { __artifact-store=\l_@@_mc_artifact_type_tl }
+      },
+    artifact .default:n    = { notype }
+  }
+
+
+% attributes
+% set the mc from a tag name
+
+\cs_set_protected:Npn \@@_attribute_gset:Nn #1 #2
+  {
+    \tex_global:D \setattribute #1 #2
+  }
+
+\cs_set_protected:Npn \@@_attribute_set:Nn #1 #2
+  {
+    \setattribute #1 #2
+  }
+
+\cs_set_protected:Npn \@@_attribute_gunset:N #1
+  {
+    \tex_global:D \unsetattribute #1
+  }
+
+\cs_set_protected:Npn \@@_attribute_unset:N #1
+  {
+    \unsetattribute #1
+  }
+
+
+\cs_new:Nn \@@_mc_lua_set_mc_type_attr:n % #1 is a tag name
+  {
+    \@@_attribute_set:Nn \l_@@_mc_type_attr
+      {
+        \directlua { ltx.@@.func.output_num_from ("#1") }
+      }
+    \@@_attribute_set:Nn \l_@@_mc_cnt_attr  { \@@_get_mc_abs_cnt: }
+  }
+
+\cs_generate_variant:Nn\@@_mc_lua_set_mc_type_attr:n { o }
+
+\cs_new:Nn \@@_mc_lua_unset_mc_type_attr:
+  {
+    \@@_attribute_unset:N \l_@@_mc_type_attr
+    \@@_attribute_unset:N \l_@@_mc_cnt_attr
+  }
+
+
+
+%This command will in the finish code replace the dummy for a mc by the real mcid kids
+%we need a variant for the case that it is the only kid, to get the array right
+\cs_new:Nn \@@_mc_insert_mcid_kids:n
+  {
+    \directlua { ltx.@@.func.mc_insert_kids (#1,0) }
+  }
+
+\cs_new:Nn \@@_mc_insert_mcid_single_kids:n
+  {
+    \directlua {ltx.@@.func.mc_insert_kids (#1,1) }
+  }
+
+
+% we need to pass the info if the kids are alone or already in an array
+% so we add a second argument, which should == 1 if the kids are single
+
+
+% puts an mcid absolute number in the current structure
+\cs_new:Nn \@@_mc_handle_stash:n %1 mcidnum
+  {
+    \@@_check_mc_used:n { #1 }
+    \seq_gput_right:cn % Don't fill a lua table due to the command in the item,
+                       % so use the kernel command
+      { g_@@_struct_kids_\g_@@_struct_stack_current_tl _seq }
+      {
+        \@@_mc_insert_mcid_kids:n {#1}%
+      }
+    \directlua
+      {
+        ltx.@@.func.store_struct_mcabs
+          (
+            \g_@@_struct_stack_current_tl,#1
+          )
+      }
+    \prop_gput:Nxx
+      \g_@@_mc_parenttree_prop
+      { #1 }
+      { \g_@@_struct_stack_current_tl }
+  }
+
+\cs_generate_variant:Nn \@@_mc_handle_stash:n { o }
+
+\cs_new_protected:Nn \tag_mc_begin:n
+  {
+    %\group_begin:
+    %\@@_check_mc_if_nested:
+    %\bool_gset_true:N \g_@@_in_mc_bool
+    \bool_set_false:N\l_@@_mc_artifact_bool
+    \int_gincr:N \c at g_@@_MCID_abs_int
+    \tl_clear:N \l_@@_mc_key_properties_tl
+    \keys_set:nn { @@ / mc }{ label={}, #1 }
+    %check that a tag or artifact has been used
+    \@@_check_mc_tag:N \l_@@_mc_key_tag_tl
+    %set the attributes:
+    \@@_mc_lua_set_mc_type_attr:o  { \l_@@_mc_key_tag_tl }
+    \bool_if:NF \l_@@_mc_artifact_bool
+      { % store the absolute num name in a label:
+        \tl_if_empty:NF {\l_@@_mc_key_label_tl}
+          {
+            \@@_mc_handle_mc_label:n { \l_@@_mc_key_label_tl }
+          }
+       % if not stashed record the absolute number
+        \bool_if:NF \l_@@_mc_key_stash_bool
+          {
+            \exp_args:Nx \@@_mc_handle_stash:n { \@@_get_mc_abs_cnt: }
+          }
+      }
+    %\bool_set_false:N\l_@@_mc_artifact_bool
+    %\group_end:
+  }
+
+%deprecated
+\cs_set_eq:NN \uftag_mc_begin:n \tag_mc_begin:n
+
+\cs_new_protected:Nn \tag_mc_end:
+  {
+    %\@@_check_mc_if_open:
+    %\bool_gset_false:N \g_@@_in_mc_bool
+    \bool_set_false:N\l_@@_mc_artifact_bool
+    \@@_mc_lua_unset_mc_type_attr:
+    \tl_set:Nn  \l_@@_mc_key_tag_tl { }
+  }
+
+\cs_set_eq:NN \uftag_mc_end: \tag_mc_end:
+
+\cs_new_protected:Nn \tag_mc_use:n %#1: label name
+  {
+    \tl_set:Nx  \l_tmpa_tl { \@@_ref_value:enn{tagpdf-#1}{tagmcabs}{} }
+    \tl_if_empty:NTF\l_tmpa_tl
+      {
+        \msg_warning:nnn {tag} {mc-label-unknown} { #1 }
+      }
+      {
+        \@@_mc_handle_stash:o { \l_tmpa_tl }
+      }
+  }
+
+\cs_set_eq:NN \uftag_mc_use:n \tag_mc_use:n
+
+\cs_new:Nn \@@_get_data_mc_tag: { \l_@@_mc_key_tag_tl }
+%</luamode>
+%    \end{macrocode}


Property changes on: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc.dtx
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx	                        (rev 0)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx	2021-02-23 22:24:07 UTC (rev 57857)
@@ -0,0 +1,156 @@
+% \iffalse meta-comment
+%
+%% File: tagpdf-roles.dtx
+%
+% Copyright (C) 2019 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.
+%
+% -----------------------------------------------------------------------
+%
+% The development version of the bundle can be found at
+%
+%    https://github.com/u-fischer/tagpdf
+%
+% for those people who are interested.
+%
+% \fi
+%
+%    \begin{macrocode}
+%<@@=tag>
+%<*roles>
+\ProvidesExplPackage {tagpdf-roles-code} {2021/02/23} {0.80}
+ {part of tagpdf - code related to roles and structure names}
+
+\@@_seq_new:N     \g_@@_role_tags_seq  %to get names from numbers
+\@@_prop_new:N    \g_@@_role_tags_prop %to get numbers from names
+
+%The list of standard adobe tags.
+\clist_const:Nn \c_@@_role_sttags_clist
+  {%possible root elements
+    Document,   %A complete document. This is the root element of any structure tree containing
+                %multiple parts or multiple articles.
+    Part,       %A large-scale division of a document.
+    Art,        %A relatively self-contained body of text constituting a single narrative or exposition
+    %subelements
+    Sect,       %A container for grouping related content elements.
+    Div,        %A generic block-level element or group of elements
+    BlockQuote, %A portion of text consisting of one or more paragraphs attributed to someone other
+                %than the author of the  surrounding text.
+    Caption,    %A brief portion of text describing a table or figure.
+    TOC,        %A list made up of table of contents item entries (structure tag TOCI; see below)
+                %and/or other nested table of contents entries
+    TOCI,       %An individual member of a table of contents. This entry's children can be any of
+                %the following structure  tags:
+                %Lbl,Reference,NonStruct,P,TOC
+    Index,
+    NonStruct,  %probably not needed
+    H,
+    H1,
+    H2,
+    H3,
+    H4,
+    H5,
+    H6,
+    P,
+    L,           %list
+    LI,          %list item (around label and list item body)
+    Lbl,         %list label
+    LBody,       %list item body
+    Table,
+    TR,          %table row
+    TH,          %table header cell
+    TD,          %table data cell
+    THead,       %table header (n rows)
+    TBody,       %table rows
+    TFoot,       %table footer
+    Span,        %generic inline marker
+    Quote,       %inline quote
+    Note,        % footnote, endnote. Lbl can be child
+    Reference,   % A citation to content elsewhere in the document.
+    BibEntry,    %bibentry
+    Code,        %
+    Link,        %
+    Annot,
+    Figure,
+    Formula,
+    Form,
+    Artifact
+  }
+
+% get tag name from number: \seq_item:Nn \g_@@_role_tags_seq { n }
+%\seq_gset_from_clist:NN \g_@@_role_tags_seq \c_@@_role_tags_clist
+
+\clist_map_inline:Nn \c_@@_role_sttags_clist
+  {
+    \@@_seq_gput_right:Nn \g_@@_role_tags_seq { #1 }
+  }
+
+
+% get tag number from name: \prop_item:Nn \g_@@_role_tags_prop { name }
+\int_step_inline:nnnn { 1 }{ 1 }{ \seq_count:N \g_@@_role_tags_seq }
+  {
+    \@@_prop_gput:Nxn \g_@@_role_tags_prop
+      {
+        \seq_item:Nn \g_@@_role_tags_seq  { #1 }
+      }
+      { #1 }
+  }
+
+\cs_new:Nn \@@_role_get_tag_from_index:nn
+  {
+    \@@_seq_item:cn { #1_seq } { #2 }
+  }
+
+\cs_new:Nn \@@_role_get_index_from_tag:nn
+  {
+    \@@_prop_item:cn { #1_prop } { #2 }
+  }
+
+% new tags and the rolemap
+
+\@@_prop_new:N \g_@@_role_rolemap_prop
+
+\cs_new_protected:Nn \@@_role_add_tag:nn %new name, reference to old
+  {
+    \@@_seq_gput_right:Nn \g_@@_role_tags_seq { #1 }
+    \@@_prop_gput:Nnx \g_@@_role_tags_prop    { #1 }
+      {
+        \seq_count:N \g_@@_role_tags_seq
+      }
+    \@@_check_add_tag_role:nn {#1}{#2}
+    \tl_if_empty:nF { #2 }
+      {
+        \@@_prop_gput:Nnn \g_@@_role_rolemap_prop
+          { #1 } { #2 }
+      }
+  }
+
+\cs_generate_variant:Nn \@@_role_add_tag:nn {xx}
+
+\keys_define:nn { @@ / setup }
+  {
+    add-new-tag .code:n =
+     {
+       \seq_set_split:Nnn \l_tmpa_seq { / } {#1/}
+       \@@_role_add_tag:xx
+         {
+           \seq_item:Nn \l_tmpa_seq {1}
+         }
+         {
+           \seq_item:Nn \l_tmpa_seq {2}
+         }
+     }
+  }
+
+
+%</roles>
+%    \end{macrocode}


Property changes on: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx	                        (rev 0)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx	2021-02-23 22:24:07 UTC (rev 57857)
@@ -0,0 +1,89 @@
+% \iffalse meta-comment
+%
+%% File: tagpdf-space.dtx
+%
+% Copyright (C) 2019 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.
+%
+% -----------------------------------------------------------------------
+%
+% The development version of the bundle can be found at
+%
+%    https://github.com/u-fischer/tagpdf
+%
+% for those people who are interested.
+%
+% \fi
+%
+%    \begin{macrocode}
+%<@@=tag>
+%<*space>
+\ProvidesExplPackage {tagpdf-space-code} {2021/02/23} {0.80}
+ {part of tagpdf - code related to real space chars}
+% luatex uses an attribute (declared in the driver file) and some luacode in tagpdf.lua
+% perhaps I will split the code by engine in the future
+
+\sys_if_engine_pdftex:T
+  {
+    \pdfglyphtounicode{space}{0020}
+    \keys_define:nn { @@ / setup }
+      {
+        interwordspace .choices:nn = { true, on }  { \pdfinterwordspaceon },
+        interwordspace .choices:nn = { false, off }{ \pdfinterwordspaceon },
+        show-spaces .bool_set:N = \l_@@_showspaces_bool
+      }
+  }
+
+
+\sys_if_engine_luatex:T
+  {
+    \keys_define:nn { @@ / setup }
+      {
+        interwordspace .choices:nn =
+                                 { true, on }
+                                 { \directlua{ltx.@@.func.markspaceon()} },
+        interwordspace .choices:nn =
+                                 { false, off }
+                                 {\directlua{ltx.@@.func.markspaceoff()} },
+        show-spaces      .choice:,
+        show-spaces  / true  .code:n =
+                                 {\directlua{ltx.@@.trace.showspaces=true}},
+        show-spaces  / false .code:n =
+                                 {\directlua{ltx.@@.trace.showspaces=nil}},
+        show-spaces .default:n = true
+      }
+
+    \cs_new_protected:Nn \@@_fakespace:
+      {
+        \group_begin:
+        \setattribute\g_@@_interwordspace_attr{1}
+        \setattribute\g_@@_interwordfont_attr
+          {
+            \directlua{tex.print(\the\catcodetable at latex, font.current())}
+          }
+        \skip_horizontal:n{\c_zero_skip}
+        \group_end:
+      }
+  }
+
+\sys_if_engine_xetex:T
+  {
+    \keys_define:nn { @@ / setup }
+      {
+        interwordspace .choices:nn = { true, on }  { \msg_warning:nnn {tag}{sys-no-interwordspace}{xetex}  },
+        interwordspace .choices:nn = { false, off }{ \msg_warning:nnn {tag}{sys-no-interwordspace}{xetex}  },
+        show-spaces .bool_set:N = \l_@@_showspaces_bool
+      }
+  }
+
+%</space>
+%    \end{macrocode}


Property changes on: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx	                        (rev 0)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx	2021-02-23 22:24:07 UTC (rev 57857)
@@ -0,0 +1,789 @@
+% \iffalse meta-comment
+%
+%% File: tagpdf-struct.dtx
+%
+% Copyright (C) 2019-2020 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.
+%
+% -----------------------------------------------------------------------
+%
+% The development version of the bundle can be found at
+%
+%    https://github.com/u-fischer/tagpdf
+%
+% for those people who are interested.
+%
+% \fi
+%
+%    \begin{macrocode}
+%<@@=tag>
+%<*struct>
+\ProvidesExplPackage {tagpdf-struct-code} {2021/02/23} {0.80}
+ {part of tagpdf - code related to storing structure}
+
+% I will use a latex counter for the structure count
+% to have a chance to avoid double structures in align etc
+
+\newcounter  { g_@@_struct_abs_int }
+\int_gzero:N \c at g_@@_struct_abs_int
+
+% ref code is in tagpdf.dtx
+
+% a sequence stores structnum -> the obj numbers
+% to allow easy mapping over the structures
+
+\@@_seq_new:N  \g_@@_struct_objR_seq
+
+% a sequence for the structure stack. When a sequence is opened it's number is put on the stack.
+\seq_new:N    \g_@@_struct_stack_seq
+\seq_gpush:Nn \g_@@_struct_stack_seq {0}
+
+%this variables will hold the top entry and the parent on the stack
+\tl_new:N     \l_@@_struct_stack_parent_tmp_tl
+\tl_new:N     \g_@@_struct_stack_current_tl
+
+% I need at least one structure: the StructTreeRoot
+% normally it should have only one kid, e.g. the document element.
+
+% The data of the StructTreeRoot and the StructElem are in properties:
+% \g_@@_struct_0_prop for the root
+% \g_@@_struct_N_prop, N >=1
+% they have all the keys
+% objnum    - number,
+% Type      - StructTreeRoot or StructElem
+% num - number (identical to the num in the name, or 0 for the root)
+% and the keys from the two following lists
+% (the root has a special set of properties).
+% the values of the prop should be already escaped properly
+% when the entries are created (title,lange,alt,E,actualtext)
+
+
+\seq_const_from_clist:Nn \c_@@_struct_StructTreeRoot_entries_seq
+  {%p. 857/858
+    Type,              % always /StructTreeRoot
+    K,                 % kid, dictionary or array of dictionaries
+    IDTree,            % currently unused
+    ParentTree,        % required,obj ref to the parent tree
+    ParentTreeNextKey, %optional
+    RoleMap,
+    ClassMap
+  }
+
+\seq_const_from_clist:Nn \c_@@_struct_StructElem_entries_seq
+  {%p 858 f
+    Type,              %always /StructElem
+    S,                 %tag/type
+    P,                 %parent
+    ID,                %optional
+    Ref,               %optional, pdf 2.0 Use?
+    Pg,                %obj num of starting page, optional
+    K,                 %kids
+    A,                 %attributes, probably unused
+    C,                 %class ""
+    %R,
+    T,                 %title, value in () or <>
+    Lang,              %language
+    Alt,               % value in () or <>
+    E,                 %abreviation
+    ActualText,
+    AF,                 %pdf 2.0, array of dict, associated files
+    NS,                 %pdf 2.0, dict, namespace
+    PhoneticAlphabet,   %pdf 2.0
+    Phoneme             %pdf 2.0
+  }
+
+% I need an output handler for each prop, to get expandable output
+% see https://tex.stackexchange.com/questions/424208/expandable-version-of-a-expl3-command/424213#424213
+
+\cs_new:Nn \@@_struct_output_prop_aux:nn %#1 num, #2 key
+  {
+    \prop_if_in:cnT
+      { g_@@_struct_#1_prop }
+      { #2 }
+      {
+        \c_space_tl/#2~ \prop_item:cn{ g_@@_struct_#1_prop } { #2 }
+      }
+  }
+
+\cs_new:Nn \@@_new_output_prop_handler:n
+  {
+    \cs_new:cn { @@_struct_output_prop_#1:n }
+      {
+        \@@_struct_output_prop_aux:nn {#1}{##1}
+      }
+  }
+
+
+% the first one, the StructTreeRoot is special, so
+% created manually:
+\@@_prop_new:c { g_@@_struct_0_prop }
+\@@_new_output_prop_handler:n {0}
+\tl_gset:Nn \g_@@_struct_stack_current_tl {0}
+
+\@@_seq_new:c  { g_@@_struct_kids_0_seq }
+
+% deprecated
+%\@@_prop_gput:cno
+%  { g_@@_struct_0_prop }
+%  { objnum}
+%  { \c_@@_tree_obj_structtreeroot_tl }
+
+% new
+\@@_prop_gput:cno
+  { g_@@_struct_0_prop }
+  { objref}
+  { \pdf_object_ref:n { c_@@_struct_0_obj } }
+
+\@@_prop_gput:cno
+  { g_@@_struct_0_prop }
+  { Type }
+  { /StructTreeRoot }
+
+% the constants are defined in the tree code.
+\@@_prop_gput:cnx
+  { g_@@_struct_0_prop }
+  { ParentTree }
+  { \pdf_object_ref:n { c_@@_tree_parenttree_obj } }
+
+\@@_prop_gput:cnx
+  { g_@@_struct_0_prop }
+  { RoleMap }
+  { \pdf_object_ref:n { c_@@_tree_rolemap_obj } }
+
+\@@_prop_gput:cno
+  { g_@@_struct_0_prop }
+  { entries }
+  { StructTreeRoot }
+
+\@@_prop_gput:cno
+  { g_@@_struct_0_prop }
+  { num }
+  { 0 }
+
+% commands to store the kids
+% I don't compare the page objects number yet, but always add the /Pg key, perhaps later
+
+\cs_new:Nn \@@_struct_kid_mc_gput_right:nn %#1 structure num, #2 MCID absnum%
+  {
+    %\@@_store_pdfpageref:Nn \l_tmpa_tl { \@@_ref_value:enn{mcid-#2}{tagabspage}{1} }
+    \@@_seq_gput_right:cx
+      { g_@@_struct_kids_#1_seq }
+      {
+        <<
+        /Type \c_space_tl /MCR \c_space_tl
+        /Pg %\c_space_tl \l_tmpa_tl \c_space_tl 0 \c_space_tl R \c_space_tl
+          \c_space_tl
+          \pdf_pageobject_ref:n { \@@_ref_value:enn{mcid-#2}{tagabspage}{1} }
+        /MCID \c_space_tl \@@_ref_value:enn{mcid-#2}{tagmcid}{1}
+        >>
+      }
+  }
+
+\cs_new:Nn\@@_struct_kid_struct_gput_right:nn %#1 num of parent struct, #2 kid struct
+  {
+    \@@_seq_gput_right:cx
+      { g_@@_struct_kids_#1_seq }
+      {
+        \prop_item:cn
+          { g_@@_struct_#2_prop }
+          { objref }
+      }
+ }
+
+\cs_new:Nn\@@_struct_kid_link_gput_right:nn %#1 num of parent struct, #2 obj reference
+  {
+    \pdf_object_unnamed_write:nx
+      { dict }
+      {
+        /Type \c_space_tl /OBJR \c_space_tl
+        /Obj~#2
+      }
+    \@@_seq_gput_right:cx
+      { g_@@_struct_kids_#1_seq }
+      {
+        \pdf_object_ref_last:
+      }
+  }
+
+\cs_generate_variant:Nn\@@_struct_kid_link_gput_right:nn { nx }
+
+\cs_new:Nn\@@_struct_exchange_kid_command:N %N= seq
+  {
+    \seq_gpop_left:NN #1 \l_tmpa_tl
+    \regex_replace_once:nnN
+      { \c{\@@_mc_insert_mcid_kids:n} }
+      { \c{\@@_mc_insert_mcid_single_kids:n} }
+      \l_tmpa_tl
+   \seq_gput_left:NV #1 \l_tmpa_tl
+  }
+
+\cs_generate_variant:Nn\@@_struct_exchange_kid_command:N { c }
+
+\cs_new:Nn \@@_struct_fill_kid_key:n %#1 is the struct num
+  {
+    \int_case:nnF
+      {
+        \seq_count:c
+          {
+            g_@@_struct_kids_\prop_item:cn{ g_@@_struct_#1_prop }{num}_seq
+          }
+      }
+      {
+        { 0 }
+         { } %no kids, do nothing
+        { 1 } % 1 kid, insert
+         {
+           % in this case we need a special command in
+           %luamode to get the array right. See issue #13
+           \bool_if:NT\g_@@_mode_lua_bool
+             {
+               \@@_struct_exchange_kid_command:c
+                 {g_@@_struct_kids_\prop_item:cn{ g_@@_struct_#1_prop }{num}_seq}
+             }
+           \@@_prop_gput:cnx { g_@@_struct_#1_prop } {K}
+             {
+               \seq_item:cn
+                 {
+                   g_@@_struct_kids_\prop_item:cn{ g_@@_struct_#1_prop }{num}_seq
+                 }
+                 {1}
+             }
+         } %
+      }
+      { %many kids, use an array
+        \@@_prop_gput:cnx { g_@@_struct_#1_prop } {K}
+          {
+            [
+              \seq_use:cn
+                {
+                  g_@@_struct_kids_\prop_item:cn{ g_@@_struct_#1_prop }{num}_seq
+                }
+                {
+                  \c_space_tl
+                }
+            ]
+          }
+      }
+  }
+
+% this command can be used for roots and structure elements
+% #1 is a num
+
+\tl_new:N \l_@@_struct_dict_content_tl
+
+\cs_new:Nn \@@_struct_get_dict_content:n
+  {
+    %\tl_set:Nn \l_@@_struct_dict_content_tl {<<}
+    \tl_clear:N \l_@@_struct_dict_content_tl
+    \seq_map_inline:cn
+      {
+        c_@@_struct_\prop_item:cn{ g_@@_struct_#1_prop }{entries}_entries_seq
+      }
+      {
+        \tl_put_right:Nx
+          \l_@@_struct_dict_content_tl
+          {
+             \prop_if_in:cnT
+               { g_@@_struct_#1_prop }
+               { ##1 }
+               {
+                 \c_space_tl/##1~\prop_item:cn{ g_@@_struct_#1_prop } { ##1 }
+               }
+          }
+      }
+    %\tl_put_right:Nn \l_@@_struct_dict_content_tl { >> }
+  }
+
+
+% #1 is the struct num
+\cs_new:Nn \@@_struct_write_obj:n
+  {
+    \prop_if_in:cnTF
+      { g_@@_struct_#1_prop }
+      { objref }
+      {
+        \@@_struct_fill_kid_key:n { #1 }
+        %\prop_show:c { g_@@_struct_#1_prop }
+        \@@_struct_get_dict_content:n { #1 }
+        \exp_args:Nx
+          \pdf_object_write:nx
+            { c_@@_struct_#1_obj }
+            {
+              \l_@@_struct_dict_content_tl
+            }
+      }
+      {
+        \msg_error:nnn { tag } { struct-no-objnum } { #1}
+      }
+  }
+
+% keys for the user commands
+% should I pass the values (e.g. the tag) through an escape command?
+\keys_define:nn { @@ / struct }
+  {
+    label .tl_set:N      = \l_@@_struct_key_label_tl,
+    stash .bool_set:N    = \l_@@_struct_elem_stash_bool,
+    tag   .code:n        = % S property
+      {%%????????? \pdfescapename??
+        \tl_set:Nx \l_@@_tmpa_tl { #1 }
+        \bool_if:NT \g_@@_check_tags_bool
+          {
+            \@@_check_structure_tag:N \l_@@_tmpa_tl
+          }
+       \@@_prop_gput:cnx
+         { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
+         { S }
+         { /\exp_not:V\l_@@_tmpa_tl }
+      },
+    title .code:n        = % T property
+      {
+        \str_set_convert:Nnon
+          \l_@@_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \@@_prop_gput:cnx
+          { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
+          { T }
+          { <\l_@@_tmpa_str> }
+      },
+    title-o .code:n        = % T property
+      {
+        \str_set_convert:Nnon
+          \l_@@_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \@@_prop_gput:cnx
+          { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
+          { T }
+          { <\l_@@_tmpa_str> }
+      },
+    alttext .code:n      = % Alt property
+      {
+        \str_set_convert:Nnon
+          \l_@@_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \@@_prop_gput:cnx
+          { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
+          { Alt }
+          { <\l_@@_tmpa_str> }
+      },
+    alttext-o .code:n      = % Alt property
+      {
+        \str_set_convert:Noon
+          \l_@@_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \@@_prop_gput:cnx
+          { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
+          { Alt }
+          { <\l_@@_tmpa_str> }
+      },
+    actualtext .code:n  = % ActualText property
+      {
+        \str_set_convert:Nnon
+          \l_@@_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \@@_prop_gput:cnx
+          { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
+          { ActualText }
+          { <\l_@@_tmpa_str>}
+      },
+    actualtext-o .code:n  = % ActualText property
+      {
+        \str_set_convert:Noon
+          \l_@@_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \@@_prop_gput:cnx
+          { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
+          { ActualText }
+          { <\l_@@_tmpa_str>}
+      },
+    lang .code:n        = % Lang property
+      {
+        \@@_prop_gput:cnx
+          { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
+          { Lang }
+          { (#1) }
+      },
+    ref .code:n        = % Lang property
+      {
+        \tl_clear:N\l_@@_tmpa_tl
+        \clist_map_inline:nn {#1}
+          {
+            \tl_put_right:Nx \l_@@_tmpa_tl
+              {~\ref_value:nn{tagpdfstruct-##1}{tagstructobj} }
+          }
+        \@@_prop_gput:cnx
+          { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
+          { Ref }
+          { [\l_@@_tmpa_tl] }
+      },
+    E .code:n        = % E property
+      {
+        \str_set_convert:Nnon
+          \l_@@_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \@@_prop_gput:cnx
+          { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
+          { E }
+          { <\l_@@_tmpa_str> }
+      },
+  }
+
+% keys for AF keys, they rely on l3pdffile!
+% The stream variants use txt as extension to get the mimetype.
+\keys_define:nn { @@ / struct }
+ {
+    AF .code:n        = % T property
+      {
+        \pdf_object_if_exist:nTF {#1}
+          {
+            \@@_prop_gput:cnx
+             { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
+             { AF }
+             { \pdf_object_ref:n {#1} }
+          }
+          {
+
+          }
+      },
+   ,AFinline .code:n =
+     {
+       \group_begin:
+       \exp_args:Ne
+       \pdf_object_if_exist:nF {@@/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 } }
+       \group_end:
+     }
+   ,AFinline-o .code:n =
+     {
+       \group_begin:
+       \exp_args:Ne
+       \pdf_object_if_exist:nF {@@/fileobj\int_use:N\c at g_@@_struct_abs_int}
+        {
+          \pdffile_embed_stream:oxx
+            {#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 } }
+       \group_end:
+     }
+ }
+
+\cs_new_protected:Nn \tag_struct_begin:n
+  {
+    \group_begin:
+    \int_gincr:N \c at g_@@_struct_abs_int
+    \@@_prop_new:c  { g_@@_struct_\int_eval:n { \c at g_@@_struct_abs_int }_prop }
+    \@@_new_output_prop_handler:n {\int_eval:n { \c at g_@@_struct_abs_int }}
+    \@@_seq_new:c  { g_@@_struct_kids_\int_eval:n { \c at g_@@_struct_abs_int }_seq}
+    %\@@_pdfreserveobjnum:N \l_tmpa_tl
+    \exp_args:Ne
+      \pdf_object_new:nn
+        { c_@@_struct_\int_eval:n { \c at g_@@_struct_abs_int }_obj }
+        { dict }
+    \@@_prop_gput:cnx
+      { g_@@_struct_\int_eval:n { \c at g_@@_struct_abs_int }_prop }
+      { objref}
+      {
+        \exp_args:Ne
+          \pdf_object_ref:n
+            {c_@@_struct_\int_eval:n { \c at g_@@_struct_abs_int }_obj}
+      }
+%    \prop_show:c { g_@@_struct_\int_eval:n { \c at g_@@_struct_abs_int }_prop }
+    \@@_prop_gput:cnx
+      { g_@@_struct_\int_eval:n { \c at g_@@_struct_abs_int }_prop }
+      { num}
+      { \int_eval:n { \c at g_@@_struct_abs_int } }
+    \@@_prop_gput:cno
+      { g_@@_struct_\int_eval:n { \c at g_@@_struct_abs_int }_prop }
+      { Type }
+      { /StructElem }
+    \@@_prop_gput:cno
+      { g_@@_struct_\int_eval:n { \c at g_@@_struct_abs_int }_prop }
+      { entries }
+      { StructElem }
+    \keys_set:nn { @@ / struct} { #1 }
+    \@@_check_structure_has_tag:n { \int_eval:n {\c at g_@@_struct_abs_int} }
+    \tl_if_empty:NF
+      \l_@@_struct_key_label_tl
+      {
+        \@@_ref_label:en{tagpdfstruct-\l_@@_struct_key_label_tl}{struct}
+      }
+    %get the potential parent from the stack:
+    \seq_get:NNF
+      \g_@@_struct_stack_seq
+      \l_@@_struct_stack_parent_tmp_tl
+      {
+        \msg_error:nn { tag } { struct-faulty-nesting }
+      }
+    \seq_gpush:NV \g_@@_struct_stack_seq        \c at g_@@_struct_abs_int
+    \tl_gset:NV   \g_@@_struct_stack_current_tl \c at g_@@_struct_abs_int
+    %\seq_show:N   \g_@@_struct_stack_seq
+    \bool_if:NF
+      \l_@@_struct_elem_stash_bool
+      {%set the  parent
+        \@@_prop_gput:cnx
+          { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
+          { P }
+          {
+            \prop_item:cn
+              { g_@@_struct_\l_@@_struct_stack_parent_tmp_tl _prop}
+              { objref }
+          }
+        %record this structure as kid:
+        %\tl_show:N \g_@@_struct_stack_current_tl
+        %\tl_show:N \l_@@_struct_stack_parent_tmp_tl
+        \@@_struct_kid_struct_gput_right:nn
+          { \l_@@_struct_stack_parent_tmp_tl }
+          { \g_@@_struct_stack_current_tl }
+        %\prop_show:c { g_@@_struct_\g_@@_struct_stack_current_tl _prop }
+        %\seq_show:c {g_@@_struct_kids_\l_@@_struct_stack_parent_tmp_tl _seq}
+      }
+    %\prop_show:c { g_@@_struct_\g_@@_struct_stack_current_tl _prop }
+    %\seq_show:c {g_@@_struct_kids_\l_@@_struct_stack_parent_tmp_tl _seq}
+    \group_end:
+  }
+
+%deprecated
+\cs_set_eq:NN  \uftag_struct_begin:n \tag_struct_begin:n
+
+\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_@@_struct_stack_seq
+    \seq_gpop:NNTF \g_@@_struct_stack_seq \l_tmpa_tl
+      {
+        \int_compare:nNnT {\l_@@_loglevel_int} > { 0 }
+          {
+            \@@_check_info_closing_struct:o { \g_@@_struct_stack_current_tl }
+          }
+      }
+      { \@@_check_no_open_struck: }
+    % get the previous one, shouldn't be empty as the root should be there
+    \seq_get:NNTF \g_@@_struct_stack_seq \l_tmpa_tl
+      {
+        \tl_gset:NV   \g_@@_struct_stack_current_tl \l_tmpa_tl
+      }
+      {
+        \@@_check_no_open_struck:
+      }
+  }
+
+%deprecated
+\cs_set_eq:NN  \uftag_struct_end: \tag_struct_end:
+
+\cs_new_protected:Nn \tag_struct_use:n %#1 is the label
+  {
+    \prop_if_exist:cTF
+      { g_@@_struct_\@@_ref_value:enn{tagpdfstruct-#1}{tagstruct}{unknown}_prop } %??????????
+      {
+        \@@_check_struct_used:n {#1}
+        %add the label structure as kid to the current structure (can be the root)
+        \@@_struct_kid_struct_gput_right:nn
+          { \g_@@_struct_stack_current_tl }
+          { \@@_ref_value:enn{tagpdfstruct-#1}{tagstruct}{0} }
+        %add the current structure to the labeled one as parents
+        \@@_prop_gput:cnx
+          { g_@@_struct_\@@_ref_value:enn{tagpdfstruct-#1}{tagstruct}{0}_prop }
+          { P }
+          {
+            \prop_item:cn
+              { g_@@_struct_\g_@@_struct_stack_current_tl _prop}
+              { objref }
+          }
+      }
+      {
+        \msg_warning:nnn{ tag }{struct-label-unknown}{#1}
+      }
+  }
+
+\cs_set_eq:NN  \uftag_struct_use:n \tag_struct_use:n
+
+
+%%%% Code to tag links
+%%%% this works for url, see exp-link.pdf.
+%%%% it must be checked for other links
+
+\cs_new_protected:Nn \@@_struct_finish_link:
+  {
+    \bool_if:NT \g_@@_active_struct_bool
+      {
+        %get the number of the parent link structure:
+        \seq_get:NNF
+          \g_@@_struct_stack_seq
+          \l_@@_struct_stack_parent_tmp_tl
+          {
+            \msg_error:nn { tag } { struct-faulty-nesting }
+          }
+        %put the obj number of link annot in the kid entry:
+        \@@_struct_kid_link_gput_right:nx
+          {
+            \l_@@_struct_stack_parent_tmp_tl
+          }
+          {
+            \pdfannot_link_ref_last:
+          }
+        % add the parent obj number to the parent tree:
+        \@@_parenttree_add_objr:nn
+          {
+            \int_use:N\c at g_@@_parenttree_obj_int
+          }
+          {
+            \prop_item:cn
+              { g_@@_struct_\l_@@_struct_stack_parent_tmp_tl _prop }
+              { objref }
+          }
+        % increase the int:
+        \stepcounter{ g_@@_parenttree_obj_int }
+      }
+  }
+
+%</struct>
+
+%    \end{macrocode}
+%    \begin{macrocode}
+%<*attr>
+\ProvidesExplPackage {tagpdf-attr-code} {2021/02/23} {0.80}
+  {part of tagpdf - code related to attributes and attribute classes}
+
+% the obj is written in tagpdf-tree-code.
+
+\seq_new:N  \g_@@_attr_class_used_seq
+\prop_new:N \g_@@_attr_objref_prop %will contain obj num of used attributes
+
+\prop_new:N \g_@@_attr_entries_prop
+\tl_new:N   \g_@@_attr_class_content_tl
+\tl_new:N   \l_@@_attr_objtmp_tl
+\tl_new:N   \l_@@_attr_value_tl
+
+
+\cs_new_protected:Nn \@@_attr_new_entry:nn %#1:name, #2: content
+  {
+    \prop_gput:Nnn \g_@@_attr_entries_prop
+      {#1}{#2}
+  }
+
+\keys_define:nn { @@ / setup }
+  {
+    newattribute .code:n =
+      {
+        \@@_attr_new_entry:nn #1
+      }
+  }
+
+
+% the key for the structure:
+\keys_define:nn { @@ / struct }
+  {
+    attribute-class .code:n =
+     {
+       \clist_set:No \l_tmpa_clist { #1 }
+       \seq_set_from_clist:NN \l_tmpa_seq \l_tmpa_clist
+       \seq_map_inline:Nn \l_tmpa_seq
+         {
+           \prop_if_in:NnF \g_@@_attr_entries_prop {##1}
+             {
+               \msg_error:nnn { tag } { attr-unknown } { ##1 }
+             }
+           \seq_gput_left:Nn\g_@@_attr_class_used_seq { ##1}
+         }
+       \seq_set_map:NNn \l_tmpb_seq \l_tmpa_seq
+         {
+           /##1
+         }
+       \tl_set:Nx \l_tmpa_tl
+         {
+           \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{[}
+           \seq_use:Nn \l_tmpb_seq  { \c_space_tl  }
+           \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{]}
+         }
+       \int_compare:nT { \seq_count:N \l_tmpa_seq > 0 }
+         {
+           \@@_prop_gput:cnx
+             { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
+             { C }
+             { \l_tmpa_tl }
+          %\prop_show:c  { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
+         }
+    }
+  }
+
+\keys_define:nn { @@ / struct }
+  {
+    attribute .code:n  = % A property (attribute, value currently a dictionary)
+      {
+        \clist_set:No          \l_tmpa_clist { #1 }
+        \seq_set_from_clist:NN \l_tmpa_seq \l_tmpa_clist
+        \tl_set:Nx \l_@@_attr_value_tl
+          {
+            \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{[}%]
+          }
+        \seq_map_inline:Nn \l_tmpa_seq
+          {
+            \prop_if_in:NnF \g_@@_attr_entries_prop {##1}
+              {
+                \msg_error:nnn { tag } { attr-unknown } { ##1 }
+              }
+            \prop_if_in:NnF \g_@@_attr_objref_prop {##1}
+              {%\prop_show:N \g_@@_attr_entries_prop
+                \pdf_object_unnamed_write:nx
+                  { dict }
+                  {
+                    \prop_item:Nn\g_@@_attr_entries_prop {##1}
+                  }
+                \prop_gput:Nnx \g_@@_attr_objref_prop {##1} {\pdf_object_ref_last:}
+              }
+            \tl_put_right:Nx \l_@@_attr_value_tl
+              {
+                \c_space_tl
+                \prop_item:Nn \g_@@_attr_objref_prop {##1}
+              }
+ %     \tl_show:N \l_@@_attr_value_tl
+          }
+        \tl_put_right:Nx \l_@@_attr_value_tl
+          { %[
+            \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{]}%
+          }
+ %     \tl_show:N \l_@@_attr_value_tl
+        \@@_prop_gput:cnx
+          { g_@@_struct_\int_eval:n {\c at g_@@_struct_abs_int}_prop }
+          { A }
+          { \l_@@_attr_value_tl }
+    },
+  }
+%</attr>
+%    \end{macrocode}


Property changes on: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx	                        (rev 0)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx	2021-02-23 22:24:07 UTC (rev 57857)
@@ -0,0 +1,294 @@
+% \iffalse meta-comment
+%
+%% File: tagpdf-tree.dtx
+%
+% Copyright (C) 2019-2020 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.
+%
+% -----------------------------------------------------------------------
+%
+% The development version of the bundle can be found at
+%
+%    https://github.com/u-fischer/tagpdf
+%
+% for those people who are interested.
+%
+% \fi
+%
+%    \begin{macrocode}
+%<@@=tag>
+%<*tree>
+\ProvidesExplPackage {tagpdf-tree-code} {2021/02/23} {0.80}
+ {part of tagpdf - code related to writing trees and dictionaries to the pdf}
+
+%this does the actual finishing:
+%Is \AfterEndDocument the best places??
+\hook_gput_code:nnn{begindocument}{tagpdf}
+  {
+    \bool_if:NT \g_@@_active_tree_bool
+      {
+        \AfterEndDocument { \tag_finish_structure: }
+      }
+  }
+
+
+% the StructTreeRoot
+% we better get the object number in any case:
+% deprecated
+%\@@_pdfreserveobjnum:N \l_tmpa_tl
+%\tl_const:Nx \c_@@_tree_obj_structtreeroot_tl { \l_tmpa_tl }
+
+%new
+\pdf_object_new:nn { c_@@_struct_0_obj }{ dict }
+
+ %need to think about the best place ...
+\hook_gput_code:nnn{begindocument}{tagpdf}
+  {
+    \bool_if:NT \g_@@_active_struct_bool
+      {
+        \pdfmanagement_add:nnx
+          { Catalog }
+          { StructTreeRoot }
+          { \pdf_object_ref:n { c_@@_struct_0_obj } }
+      }
+  }
+\cs_new_protected:Nn \@@_tree_write_structtreeroot:
+  {
+    \@@_struct_write_obj:n { 0 }
+  }
+
+\cs_new_protected:Nn \@@_tree_write_structelements:
+  {
+    \int_step_inline:nnnn {1}{1}{\c at g_@@_struct_abs_int}
+      {
+        %\prop_show:c {g_@@_struct_##1_prop}
+        \@@_struct_write_obj:n { ##1 } %write the object
+      }
+  }
+
+
+%the ParentTree
+% deprecated
+%\@@_pdfreserveobjnum:N \l_tmpa_tl
+%\tl_const:Nx \c_@@_tree_obj_parenttree_tl    { \l_tmpa_tl }
+
+%new
+\pdf_object_new:nn { c_@@_tree_parenttree_obj }{ dict }
+
+% we have two sets of entries in the parent tree:
+% page streams and real objects.
+% The numbers must be distinct and ordered
+% So we rely on abspage and put the real objects at the end
+% I use a counter to have a chance to get the correct number
+% if code is process twice.
+\newcounter  { g_@@_parenttree_obj_int }
+\hook_gput_code:nnn{begindocument}{tagpdf}
+  {
+    \int_gset:Nn
+      \c at g_@@_parenttree_obj_int
+      { \@@_ref_value_lastpage:nn{abspage}{100}  }
+  }
+
+% we need to record the obj references:
+
+\tl_new:N \g_@@_parenttree_objr_tl
+
+\cs_new_protected:Nn \@@_parenttree_add_objr:nn %#1 Structparent number, #2 objref
+  {
+    \tl_gput_right:Nx \g_@@_parenttree_objr_tl
+      {
+        #1 \c_space_tl #2 ^^J
+      }
+  }
+
+\tl_new:N \l_@@_parenttree_content_tl
+
+\cs_new_protected:Nn \@@_tree_fill_parenttree:
+  {
+    \int_step_inline:nnnn{1}{1}{\@@_ref_value_lastpage:nn{abspage}{-1}} %not quite clear if labels are needed. See lua code
+      { %page ##1\par
+        \prop_clear:N \l_tmpa_prop
+        \int_step_inline:nnnn{1}{1}{\@@_ref_value_lastpage:nn{tagmcabs}{-1}}
+          {
+            %mcid####1
+            \int_compare:nT%F
+              {\@@_ref_value:enn{mcid-####1}{tagabspage}{-1}=##1} %mcid is on current page
+              {% yes\par
+                \prop_put:Nxx
+                  \l_tmpa_prop
+                  {\@@_ref_value:enn{mcid-####1}{tagmcid}{-1}}
+                  {\prop_item:Nn \g_@@_mc_parenttree_prop {####1}}
+              }
+          }
+          %\prop_show:N \l_tmpa_prop
+        \tl_put_right:Nx\l_@@_parenttree_content_tl
+          {
+            \int_eval:n {##1-1}\c_space_tl
+            [\c_space_tl %]
+          }
+        \int_step_inline:nnnn
+          {0}
+          {1}
+          { \prop_map_function:NN \l_tmpa_prop\@@_prop_count:nn -1 }
+          {
+            \prop_get:NnNTF \l_tmpa_prop {####1} \l_tmpb_tl
+              {% page#1:mcid##1:\l_tmpb_tl :content
+                \tl_put_right:Nx \l_@@_parenttree_content_tl
+                  {
+                    \prop_item:cn { g_@@_struct_\l_tmpb_tl _prop } {objref}
+                    \c_space_tl
+                  }
+                %\tl_show:N \l_@@_parenttree_content_tl
+              }
+              {
+                \msg_warning:nn { tag } {tree-mcid-index-wrong}
+              }
+          }
+        \tl_put_right:Nn
+          \l_@@_parenttree_content_tl
+          {%[
+            ]^^J
+          }
+      }
+  }
+
+%lua mode must/can do it differently
+\cs_new_protected:Nn \@@_tree_lua_fill_parenttree:
+  {
+    \tl_set:Nn \l_@@_parenttree_content_tl
+      {
+        \directlua
+          {
+            ltx.@@.func.output_parenttree
+              (
+                \int_use:N\g_shipout_readonly_int
+              )
+          }
+      }
+  }
+
+
+
+\cs_new_protected:Nn \@@_tree_write_parenttree:
+  {
+    \bool_if:NTF \g_@@_mode_lua_bool
+      {
+        \@@_tree_lua_fill_parenttree:
+      }
+      {
+        \@@_tree_fill_parenttree:
+      }
+    \tl_put_right:NV \l_@@_parenttree_content_tl\g_@@_parenttree_objr_tl
+    \pdf_object_write:nx  { c_@@_tree_parenttree_obj }
+      {
+        /Nums\c_space_tl [\l_@@_parenttree_content_tl]
+      }
+  }
+
+%the Rolemap tree
+%deprecated
+%\@@_pdfreserveobjnum:N \l_tmpa_tl
+%\tl_const:Nx \c_@@_tree_obj_rolemap_tl { \l_tmpa_tl }
+
+%new
+\pdf_object_new:nn { c_@@_tree_rolemap_obj }{ dict }
+
+\tl_new:N \l_@@_rolemap_content_tl
+
+\cs_new_protected:Nn \@@_tree_fill_rolemap:
+  {
+    \prop_map_inline:Nn \g_@@_role_rolemap_prop
+      {
+        \tl_put_right:Nx \l_@@_rolemap_content_tl
+          {
+            /##1\c_space_tl/##2^^J
+          }
+      }
+  }
+
+\cs_new_protected:Nn \@@_tree_write_rolemap:
+  {
+    \@@_tree_fill_rolemap:
+    \pdf_object_write:nx  { c_@@_tree_rolemap_obj }
+      {
+        \l_@@_rolemap_content_tl
+      }
+  }
+
+%classmap, should only be written, if values has been used
+
+\cs_new_protected:Nn \@@_tree_write_classmap:
+  {
+    \tl_gclear:N \g_@@_attr_class_content_tl
+    \seq_gremove_duplicates:N \g_@@_attr_class_used_seq
+    \seq_set_map:NNn \l_tmpa_seq \g_@@_attr_class_used_seq
+      {
+        /##1\c_space_tl
+        <<
+          \prop_item:Nn
+            \g_@@_attr_entries_prop
+            {##1}
+        >>
+      }
+    \tl_gset:Nx \g_@@_attr_class_content_tl
+      {
+        \seq_use:Nn
+          \l_tmpa_seq
+          { \iow_newline: }
+      }
+    \tl_if_empty:NF
+      \g_@@_attr_class_content_tl
+      {
+        \pdf_object_new:nn { c_@@_tree_classmap_obj }{ dict }
+     %   \@@_pdfreserveobjnum:N \l_tmpa_tl
+     %   \tl_const:Nx \c_@@_tree_obj_classmap_tl { \l_tmpa_tl }
+        \pdf_object_write:nx
+          { c_@@_tree_classmap_obj }
+          { \g_@@_attr_class_content_tl }
+        \@@_prop_gput:cnx
+          { g_@@_struct_0_prop }
+          { ClassMap }
+          { \pdf_object_ref:n { c_@@_tree_classmap_obj }  }
+      }
+  }
+
+
+\cs_new_protected:Nn \tag_finish_structure:
+  {
+    \@@_tree_write_parenttree:
+    \@@_tree_write_rolemap:
+    \@@_tree_write_classmap:
+    \@@_tree_write_structelements: %this is rather slow!!
+    \@@_tree_write_structtreeroot:
+  }
+
+%deprecated
+\cs_set_eq:NN \uftag_finish_structure: \tag_finish_structure:
+
+%StructParents !!! we need a better hook for \g__pdf_BACKEND_thispage_shipout_tl!!
+% No actually
+\hook_gput_code:nnn{begindocument}{tagpdf}
+  {
+    \bool_if:NT\g_@@_active_tree_bool
+      {
+       \hook_gput_code:nnn{shipout/before} { tagpdf/structparents }
+         {
+             \pdfmanagement_add:nnx
+               { Page }
+               {StructParents}
+               {\int_eval:n { \g_shipout_readonly_int}}
+         }
+      }
+  }
+
+%</tree>
+%    \end{macrocode}


Property changes on: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx	                        (rev 0)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx	2021-02-23 22:24:07 UTC (rev 57857)
@@ -0,0 +1,498 @@
+% \iffalse meta-comment
+%
+%% File: tagpdf.dtx
+%
+% Copyright (C) 2019-2020 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.
+%
+% -----------------------------------------------------------------------
+%
+% The development version of the bundle can be found at
+%
+%    https://github.com/u-fischer/tagpdf
+%
+% for those people who are interested.
+%
+% \fi
+%
+%    \begin{macrocode}
+%<@@=tag>
+%<*package>
+\ProvidesExplPackage {tagpdf} {2021/02/23} {0.80}
+  { A package to experiment with pdf tagging }
+
+\bool_if:nF
+  {
+    \bool_lazy_and_p:nn
+      {\cs_if_exist_p:N \pdfmanagement_if_active_p:}
+      { \pdfmanagement_if_active_p: }
+  }
+  {  %error for now, perhaps warning later.
+    \PackageError{tagpdf}
+     {
+       PDF~resource~management~is~no~active!\MessageBreak
+       tagpdf~will~no~work.
+     }
+     {
+       Activate~it~with \MessageBreak
+       \string\RequirePackage{pdfmanagement-testphase}\MessageBreak
+       \string\DeclareDocumentMetadata{<options>}\MessageBreak
+       before~\string\documentclass
+     }
+  }
+
+%\debug_on:n{check-declarations,check-expressions,deprecation}
+
+%map internal tag to package name
+\prop_if_exist:NT \g_msg_module_name_prop
+  {
+    \prop_gput:Nnn \g_msg_module_name_prop { tag }{ tagpdf }
+  }
+
+% storing internal names to my name space:
+\cs_set_eq:NN \@@_tex_global:D              \tex_global:D
+
+%%% package options
+\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 }
+\ExecuteOptions{luamode}
+\ProcessOptions
+
+%%% some packages
+%references use l3ref-tmp
+\RequirePackage{l3ref-tmp}
+ %================
+ % temporary code
+ % ===============
+ % faking the LastPage label:
+ \cs_new_protected:Npn \@@_lastpagelabel:
+   {
+     \legacy_if:nT { @filesw }
+       {
+         \exp_args:NNnx \exp_args:NNx\iow_now:Nn \@auxout
+            {
+              \token_to_str:N \newlabeldata
+                {@@_LastPage}
+                {
+                  {abspage} { \int_use:N \g_shipout_readonly_int}
+                  {tagmcabs}{ \int_use:N \c at g_@@_MCID_abs_int }
+                }
+            }
+       }
+   }
+
+ \AddToHook{enddocument/afterlastpage}
+  {\@@_lastpagelabel:}
+
+ % a command to override the general default. See issue in ref
+ \cs_if_exist:NF \ref_value:nnn
+   {
+     \cs_new:Npn \ref_value:nnn #1#2#3
+       {
+         \exp_args:Nee
+           \__ref_value:nnn
+            { \tl_to_str:n {#1} } { \tl_to_str:n {#2} } {#3}
+       }
+     \cs_new:Npn \__ref_value:nnn #1#2#3
+       {
+         \tl_if_exist:cTF { g__ref_label_ #1 _ #2 _tl }
+           { \tl_use:c { g__ref_label_ #1 _ #2 _tl } }
+           {
+             % test if attribute exist at all?
+             #3
+           }
+       }
+   }
+
+ %=============
+ % attributes
+ %=============
+\ref_attribute_gset:nnnn {tagstruct}    {0}{now}    { \int_use:N \c at g_@@_struct_abs_int }
+\ref_attribute_gset:nnnn {tagstructobj} {}{now}
+ {
+  \exp_args:Ne
+   \pdf_object_if_exist:nT {c__tag_struct_ \int_use:N \c at g__tag_struct_abs_int _obj}
+    {
+      \pdf_object_ref:e{c__tag_struct_ \int_use:N \c at g_@@_struct_abs_int _obj}
+    }
+ }
+ % replace by abspage??
+\ref_attribute_gset:nnnn {tagabspage}{0}{shipout}{ \int_use:N \g_shipout_readonly_int }
+\ref_attribute_gset:nnnn {tagmcabs } {0}{now}    { \int_use:N \c at g_@@_MCID_abs_int }
+\ref_attribute_gset:nnnn {tagmcid }  {0}{now}    { \int_use:N \g_@@_MCID_tmp_bypage_int }
+%============
+% lists
+%============
+\clist_const:Nn \c_@@_refmc_clist     {tagabspage,tagmcabs,tagmcid} %mc is new!!
+\clist_const:Nn \c_@@_refstruct_clist {tagstruct,tagstructobj}
+%=================
+% command to set a label
+%================
+\cs_generate_variant:Nn \ref_label:nn { nv }
+\cs_new_protected:Npn \@@_ref_label:nn #1 #2 %#1 label, #2 name of list mc or struct
+  {
+    \@bsphack
+    \ref_label:nv {#1}{c_@@_ref#2_clist}
+    \@esphack
+  }
+%==============
+% command to retrieve the value
+%===============
+\cs_new:Npn \@@_ref_value:nnn #1 #2 #3 %#1 label, #2 attribute, #3 default
+  {
+    \ref_value:nnn {#1}{#2}{#3}
+  }
+%===============
+% the LastPage label has a different name, so we need a special command for now
+% =============
+\cs_new:Npn \@@_ref_value_lastpage:nn #1 #2
+  {
+    \ref_value:nnn {@@_LastPage}{#1}{#2}
+  }
+
+% as ref doesn't expand label names we need variants:
+\cs_generate_variant:Nn \@@_ref_label:nn {en}
+\cs_generate_variant:Nn \@@_ref_value:nnn {enn}
+
+\RequirePackage{etoolbox}
+%\RequirePackage{l3pdf}
+%\RequirePackage{pdfescape} %check if needed
+%\RequirePackage{pdftexcmds}%check if needed (expandable commands!)
+
+%\RequirePackage{l3str-convert}
+\cs_generate_variant:Nn \str_set_convert:Nnnn {Nonn, Noon, Nnon }
+
+
+
+
+%%% tagpdfsetup,
+%%% TODO: checks need to be improved
+\int_new:N  \l_@@_loglevel_int
+\tl_new:N   \l_@@_tree_tabs_order_tl
+
+\keys_define:nn { @@ / setup }
+  {
+    activate-mc     .bool_gset:N = \g_@@_active_mc_bool,
+    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},
+    check-tags      .bool_gset:N = \g_@@_check_tags_bool,
+    check-tags      .initial:n  = true,
+    log             .choice:,
+    log / none      .code:n = {\int_set:Nn \l_@@_loglevel_int { 0 }},
+    log / v         .code:n = {\int_set:Nn \l_@@_loglevel_int { 1 }},
+    log / vv        .code:n = {\int_set:Nn \l_@@_loglevel_int { 2 }},
+    log / vvv       .code:n = {\int_set:Nn \l_@@_loglevel_int { 3 }},
+    log / all       .code:n = {\int_set:Nn \l_@@_loglevel_int { 10 }},
+    tagunmarked     .bool_gset:N = \g_@@_tagunmarked_bool,
+    tagunmarked     .initial:n  = true,
+    tabsorder       .choice:,
+    tabsorder / row       .code:n = %{\tl_set:Nn \l_@@_tree_tabs_order_tl {/Tabs/R}},
+      \pdfmanagement_add:nnn { Page } {Tabs}{/R},
+    tabsorder / column    .code:n = %{\tl_set:Nn \l_@@_tree_tabs_order_tl {/Tabs/C}},
+      \pdfmanagement_add:nnn { Page } {Tabs}{/C},
+    tabsorder / structure .code:n = %{\tl_set:Nn \l_@@_tree_tabs_order_tl {/Tabs/S}},
+      \pdfmanagement_add:nnn { Page } {Tabs}{/S},
+    tabsorder / none      .code:n = %{\tl_set:Nn \l_@@_tree_tabs_order_tl {}},
+      \pdfmanagement_remove:nn {Page} {Tabs},
+    tabsorder       .initial:n = structure,
+    uncompress      .code:n = {\pdf_uncompress:  },
+  }
+%need to think about the right place ...
+%\AtBeginDocument
+\hook_gput_code:nnn{begindocument}{tagpdf}
+  {
+    \bool_if:NT \g_@@_active_struct_bool
+      {
+         \pdfmanagement_add:nnn { Catalog / MarkInfo } { Marked } { true }
+      }
+  }
+% escape commands are a bit engine specific so have been moved to the backend files.
+% commands to escape strings so that they can be safely used in pdf
+% currently not much used. But will be needed later, when alt and actualtext are added.
+% we probably need the equivalent \pdfescapestring, \pdfescapename \pdfescapehex
+% the commands of pdfescape adds an additional layout to allow for babel shorthands
+%\cs_set_eq:NN \@@_pdf_escape_string:Nn \EdefEscapeString
+%\cs_set_eq:NN \@@_pdf_escape_name:Nn   \EdefEscapeName
+%\cs_set_eq:NN \@@_pdf_escape_hex:Nn    \EdefEscapeHex
+
+%\cs_set_eq:NN \@@_pdf_escape_string:n \EdefEscapeString
+%\cs_set_eq:NN \@@_pdf_escape_name:Nn   \EdefEscapeName
+
+%escape command. They are backend specific as \pdf at escapehex would ignore most chars
+%outside the "pdflatex" range
+
+
+
+
+
+% a hook for later code and an absolute page counter
+% should be executed before counters are resetted.
+% is it used?
+\cs_new:Nn   \@@_finish_page_hook: { }
+
+%\AtBeginShipout
+
+\hook_gput_code:nnn
+  { shipout/before }
+  { tagpdf/cnt }
+  {
+    \@@_finish_page_hook:
+    %\int_gincr:N \g_@@_abspage_int
+  }
+
+
+%testing the engines and loading the backend files
+\sys_if_engine_xetex:T
+  { %lets try with xelatex ...
+    %\PackageError { tagpdf } { xelatex~is~not~supported~-~aborting } {}
+    %\tex_endinput:D
+    \file_input:n {tagpdf-pdftex.def}
+  }
+
+\sys_if_engine_luatex:T
+  {
+    \file_input:n {tagpdf-luatex.def}
+  }
+
+\sys_if_engine_pdftex:T
+  {
+    \file_input:n {tagpdf-pdftex.def}
+  }
+
+\sys_if_output_dvi:T
+  {
+    %\PackageError { tagpdf } { dvi~output~is~not~supported~-~aborting }{}
+    %\tex_endinput:D
+  }
+
+\cs_generate_variant:Nn \@@_prop_gput:Nnn      { Nxn , Nxx, Nnx , cnn, cxn, cnx, cno}
+\cs_generate_variant:Nn \@@_seq_gput_right:Nn  { Nx  , No, cn, cx }
+\cs_generate_variant:Nn \@@_prop_new:N   { c }
+\cs_generate_variant:Nn \@@_seq_new:N    { c }
+\cs_generate_variant:Nn \@@_seq_show:N   { c }
+\cs_generate_variant:Nn \@@_prop_show:N  { c }
+\cs_generate_variant:Nn \prop_gput:Nnn {Nxx}
+\cs_generate_variant:Nn \prop_put:Nnn  {Nxx}
+
+\cs_generate_variant:Nn \pdffile_embed_stream:nnn {nxx,oxx}
+\cs_generate_variant:Nn \pdf_object_ref:n {e}
+
+
+% few temp tl
+\tl_new:N \g_@@_tmpa_tl
+\tl_new:N \l_@@_tmpa_tl
+\tl_new:N \l_@@_tmpb_tl
+\tl_new:N \l_@@_tmpc_tl
+\tl_new:N \l_@@_tmpd_tl
+\tl_new:N \l_@@_tmpe_tl
+\str_new:N \l_@@_tmpa_str
+
+% helper function to get the propcount.
+% use as \prop_map_function:NN PROP { \@@_prop_count:nn -1 }
+\cs_new:Nn\@@_prop_count:nn { + 1 }
+
+%% Loading the tagpdf sub packages
+\RequirePackage { tagpdf-checks-code }
+\RequirePackage { tagpdf-user }
+\RequirePackage { tagpdf-tree-code }
+\RequirePackage { tagpdf-roles-code }
+\RequirePackage { tagpdf-attr-code }
+% mc-code is split:
+\RequirePackage { tagpdf-mc-code-shared }
+\bool_if:NTF \g_@@_mode_lua_bool
+  {
+   \RequirePackage {tagpdf-mc-code-lua}
+  }
+  {
+   \RequirePackage { tagpdf-mc-code-generic } %
+  }
+
+\RequirePackage { tagpdf-struct-code }
+\RequirePackage { tagpdf-space-code }
+%</package>
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+%<*user>
+\ProvidesExplPackage {tagpdf-user} {2021/02/23} {0.80}
+  {tagpdf - user commands}
+
+\NewDocumentCommand \tagpdfsetup { m }
+  {
+    \keys_set:nn { @@ / setup } { #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
+
+%%% stop tagging
+\bool_new:N \l_@@_stop_bool
+
+\prg_new_conditional:Nnn \@@_if_stop: {p,T,F,TF}
+  {
+    \bool_if:NTF \l_@@_stop_bool
+      { \prg_return_true:  }
+      { \prg_return_false: }
+  }
+
+\prg_new_eq_conditional:NNn \tag_if_stop: \@@_if_stop: {p,T,F,TF}
+
+\cs_new_protected:Npn \@@_stop:
+  {
+    \bool_set_true:N \l_@@_stop_bool
+    \cs_set_eq:NN \tag_mc_begin:n     \use_none:n
+    \cs_set_eq:NN \tag_mc_end:        \prg_do_nothing:
+    \cs_set_eq:NN \tag_mc_use:n       \use_none:n
+    \cs_set_eq:NN \tag_struct_begin:n \use_none:n
+    \cs_set_eq:NN \tag_struct_end:    \prg_do_nothing:
+    \cs_set_eq:NN \tag_struct_use:n   \use_none:n
+    %deprecated
+    \cs_set_eq:NN \uftag_mc_begin:n \tag_mc_begin:n
+    \cs_set_eq:NN \uftag_mc_end:    \tag_mc_end:
+    \cs_set_eq:NN \uftag_mc_use:n \tag_mc_use:n
+    \cs_set_eq:NN \uftag_struct_begin:n \tag_struct_begin:n
+    \cs_set_eq:NN \uftag_struct_end: \tag_struct_end:
+    \cs_set_eq:NN  \uftag_struct_use:n \tag_struct_use:n
+  }
+
+\cs_new_protected:Npn \tag_stop_group_begin:
+  {
+    \group_begin:
+    \@@_stop:
+  }
+
+\cs_set_eq:NN \tag_stop_group_end: \group_end:
+
+
+%%% a generic command to retrieve data
+
+\cs_new:Npn \tagpdfget #1   { \use:c {@@_get_data_#1: } }
+\cs_new:Npn \tag_get:n #1   { \use:c {@@_get_data_#1: } }
+%deprecated:
+\cs_new:Npn \uftag_get:n #1 { \use:c {@@_get_data_#1: } }
+
+
+%%%% mc related user commands
+\NewDocumentCommand \tagmcifinTF { m m }
+  {
+    \@@_mc_if_in:TF { #1 } { #2 }
+  }
+
+
+\NewDocumentEnvironment{tagmcartifact}{m}
+ {
+  \tag_mc_artifact_group_begin:n { #1}\ignorespaces
+ }
+ {
+  \tag_mc_artifact_group_end:
+ }
+
+\NewDocumentCommand \tagmcbegin { m }
+  {
+    \tag_mc_begin:n {#1}\ignorespaces
+  }
+
+
+\NewDocumentCommand \tagmcend {  }
+  {
+    \unskip % this unskip appears to mess up some spacing; can we do this in another way?
+    \tag_mc_end:
+  }
+
+\NewDocumentCommand \tagmcuse { m }
+  {
+    \tag_mc_use:n {#1}
+  }
+
+
+%%%% structure related commands
+
+\NewDocumentCommand \tagstructbegin { m }
+  {
+    \tag_struct_begin:n {#1}
+  }
+
+\NewDocumentCommand \tagstructend {  }
+  {
+   \tag_struct_end:
+  }
+
+\NewDocumentCommand \tagstructuse { m }
+  {
+    \tag_struct_use:n {#1}
+  }
+
+
+
+%%%% debug/show commands
+\NewDocumentCommand\showtagpdfmcdata { O {\@@_tag_get_mc_abs_cnt:} }
+  {
+    \bool_if:NT \g_@@_mode_lua_bool
+      {
+        \sys_if_engine_luatex:T
+          {
+            \directlua{ltx.@@.trace.show_all_mc_data(#1)}
+          }
+      }
+  }
+
+\NewDocumentCommand\showtagpdfattributes { }
+  {
+    \bool_if:NT \g_@@_mode_lua_bool
+      {
+        \sys_if_engine_luatex:T
+          {
+            \directlua
+              {
+                ltx.@@.trace.log
+                 (
+                   "showtagpdfattributes:
+                    MC=>abscnt=\@@_get_mc_abs_cnt:
+                    =>attr=\the\l_@@_mc_cnt_attr=>tag="
+                    ..
+                    tostring(ltx.@@.func.get_tag_from (\the\l_@@_mc_type_attr))
+                    ..
+                    "=\the\l_@@_mc_type_attr",0
+                 )
+             }
+            \ignorespaces
+          }
+      }
+   }
+
+\sys_if_engine_luatex:T
+  {
+    \NewDocumentCommand\pdffakespace { }
+      {
+        \@@_fakespace:
+      }
+  }
+
+%</user>
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+%<*deprecated>
+% \uftag_get:n
+% \uftag_mc_if_in:
+% \uftag_mc_begin:n
+% \uftag_mc_end:
+% \uftag_mc_use:n
+% \uftag_struct_begin:n
+% \uftag_struct_end:
+% \uftag_finish_structure:
+%</deprecated>
+%    \end{macrocode}


Property changes on: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.ins	                        (rev 0)
+++ trunk/Master/texmf-dist/source/latex/tagpdf/tagpdf.ins	2021-02-23 22:24:07 UTC (rev 57857)
@@ -0,0 +1,100 @@
+\iffalse meta-comment
+
+File: tagpdf.ins
+
+Copyright (C) 2019 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.
+
+The released version of this bundle is available from CTAN.
+
+-----------------------------------------------------------------------
+
+The development version of the bundle can be found at
+
+   https://github.com/u-fischer/tagpdf
+
+for those people who are interested.
+
+-----------------------------------------------------------------------
+
+\fi
+
+\input l3docstrip.tex
+\askforoverwritefalse
+
+\let\MetaPrefix\relax
+\preamble
+
+Copyright (C) 2019 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.
+
+\endpreamble
+\let\MetaPrefix\DoubleperCent
+% stop docstrip adding \endinput
+\postamble
+\endpostamble
+
+\keepsilent
+
+\generate
+  {\file{tagpdf.sty}           {\from{tagpdf.dtx}{package}}}
+\generate
+  {\file{tagpdf-user.sty}      {\from{tagpdf.dtx}{user}}}
+\generate
+  {\file{tagpdf-deprecated.def}{\from{tagpdf.dtx}{deprecated}}}
+
+\generate
+  {\file{tagpdf-luatex.def}{\from{tagpdf-backend.dtx}{luatex}}}
+\generate
+  {\file{tagpdf-pdftex.def}{\from{tagpdf-backend.dtx}{pdftex}}}
+
+\generate
+  {\file{tagpdf-mc-code-shared.sty}{\from{tagpdf-mc.dtx}{shared}}}
+\generate
+  {\file{tagpdf-mc-code-generic.sty}{\from{tagpdf-mc.dtx}{generic}}}
+\generate
+  {\file{tagpdf-mc-code-lua.sty}{\from{tagpdf-mc.dtx}{luamode}}}
+
+\generate
+  {\file{tagpdf-struct-code.sty}{\from{tagpdf-struct.dtx}{struct}}}
+\generate
+  {\file{tagpdf-attr-code.sty}{\from{tagpdf-struct.dtx}{attr}}}
+
+\generate
+  {\file{tagpdf-checks-code.sty}{\from{tagpdf-checks.dtx}{checks}}}
+
+\generate
+  {\file{tagpdf-roles-code.sty}{\from{tagpdf-roles.dtx}{roles}}}
+
+\generate
+  {\file{tagpdf-space-code.sty}{\from{tagpdf-space.dtx}{space}}}
+
+\generate
+  {\file{tagpdf-tree-code.sty}{\from{tagpdf-tree.dtx}{tree}}}
+  
+\def\MetaPrefix{-- }
+\def\defaultpostamble{%
+  \MetaPrefix^^J%
+  \MetaPrefix\space End of File `\outFileName'.%
+}
+\def\currentpostamble{\defaultpostamble}%
+\generate{\file{tagpdf.lua}   {\from{tagpdf-backend.dtx}{lua}}}
+\endbatchfile

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-attr-code.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-attr-code.sty	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-attr-code.sty	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,110 +1,129 @@
-\ProvidesExplPackage {tagpdf-attr-code} {2019/07/02} {0.61}
- {part of tagpdf - code related to attributes and attribute classes}
+%%
+%% This is file `tagpdf-attr-code.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tagpdf-struct.dtx  (with options: `attr')
+%% 
+%% Copyright (C) 2019 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-struct.dtx
 
-% the obj is written in tagpdf-tree-code.
+\ProvidesExplPackage {tagpdf-attr-code} {2021/02/23} {0.80}
+  {part of tagpdf - code related to attributes and attribute classes}
 
-\seq_new:N  \g__uftag_attr_class_used_seq
-\prop_new:N \g__uftag_attr_objnum_prop %will contain obj num of used attributes
 
-\prop_new:N \g__uftag_attr_entries_prop
-\tl_new:N   \g__uftag_attr_class_content_tl
-\tl_new:N   \l__uftag_attr_objtmp_tl
-\tl_new:N   \l__uftag_attr_value_tl
+\seq_new:N  \g__tag_attr_class_used_seq
+\prop_new:N \g__tag_attr_objref_prop %will contain obj num of used attributes
 
+\prop_new:N \g__tag_attr_entries_prop
+\tl_new:N   \g__tag_attr_class_content_tl
+\tl_new:N   \l__tag_attr_objtmp_tl
+\tl_new:N   \l__tag_attr_value_tl
 
-\cs_new_protected:Nn \__uftag_attr_new_entry:nn %#1:name, #2: content
- {
-  \prop_gput:Nnn \g__uftag_attr_entries_prop
-   {#1}{#2}
- }
+\cs_new_protected:Nn \__tag_attr_new_entry:nn %#1:name, #2: content
+  {
+    \prop_gput:Nnn \g__tag_attr_entries_prop
+      {#1}{#2}
+  }
 
-\keys_define:nn { uftag / setup }
- {
-  newattribute .code:n =
-   {
-    \__uftag_attr_new_entry:nn #1
-   }
- }
-
-
-% the key for the structure:
-\keys_define:nn { uftag / struct }
-{
- attribute-class .code:n =
- {
-   \clist_set:No \l_tmpa_clist { #1 }
-   \seq_set_from_clist:NN \l_tmpa_seq \l_tmpa_clist
-   \seq_map_inline:Nn \l_tmpa_seq
-    {
-     \prop_if_in:NnF \g__uftag_attr_entries_prop {##1}
+\keys_define:nn { __tag / setup }
+  {
+    newattribute .code:n =
       {
-       \msg_error:nnn { uftag } { attr-unknown } { ##1 }
+        \__tag_attr_new_entry:nn #1
       }
-     \seq_gput_left:Nn\g__uftag_attr_class_used_seq { ##1}
+  }
+
+\keys_define:nn { __tag / struct }
+  {
+    attribute-class .code:n =
+     {
+       \clist_set:No \l_tmpa_clist { #1 }
+       \seq_set_from_clist:NN \l_tmpa_seq \l_tmpa_clist
+       \seq_map_inline:Nn \l_tmpa_seq
+         {
+           \prop_if_in:NnF \g__tag_attr_entries_prop {##1}
+             {
+               \msg_error:nnn { tag } { attr-unknown } { ##1 }
+             }
+           \seq_gput_left:Nn\g__tag_attr_class_used_seq { ##1}
+         }
+       \seq_set_map:NNn \l_tmpb_seq \l_tmpa_seq
+         {
+           /##1
+         }
+       \tl_set:Nx \l_tmpa_tl
+         {
+           \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{[}
+           \seq_use:Nn \l_tmpb_seq  { \c_space_tl  }
+           \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{]}
+         }
+       \int_compare:nT { \seq_count:N \l_tmpa_seq > 0 }
+         {
+           \__tag_prop_gput:cnx
+             { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
+             { C }
+             { \l_tmpa_tl }
+          %\prop_show:c  { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
+         }
     }
-   \seq_set_map:NNn \l_tmpb_seq \l_tmpa_seq
-   {
-     /##1
-   }
-  \tl_set:Nx \l_tmpa_tl
-   {
-    \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{[}
-    \seq_use:Nn \l_tmpb_seq  { \c_space_tl  }
-    \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{]}
-   }
-   \int_compare:nT { \seq_count:N \l_tmpa_seq > 0 }
-    {
-      \__uftag_prop_gput:cnx
-       { g__uftag_struct_\int_eval:n {\c at g__uftag_struct_abs_int}_prop }
-       { C }
-       { \l_tmpa_tl }
-      %\prop_show:c  { g__uftag_struct_\int_eval:n {\c at g__uftag_struct_abs_int}_prop }
-    }
-   }
-}
+  }
 
-\keys_define:nn { uftag / struct }
- {
-  attribute .code:n  = % A property (attribute, value currently a dictionary)
-   {
-    \clist_set:No          \l_tmpa_clist { #1 }
-    \seq_set_from_clist:NN \l_tmpa_seq \l_tmpa_clist
-    \tl_set:Nx \l__uftag_attr_value_tl
-    {
-     \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{[}
-    }
-    \seq_map_inline:Nn \l_tmpa_seq
-    {
-     \prop_if_in:NnF \g__uftag_attr_entries_prop {##1}
+\keys_define:nn { __tag / struct }
+  {
+    attribute .code:n  = % A property (attribute, value currently a dictionary)
       {
-       \msg_error:nnn { uftag } { attr-unknown } { ##1 }
-      }
-     \prop_if_in:NnF \g__uftag_attr_objnum_prop {##1}
-      {
-       \__uftag_pdfreserveobjnum:N \l_tmpa_tl
-       \__uftag_pdfuseobjnum:Nx    \l_tmpa_tl
-        {
-          \prop_item:Nn\g__uftag_attr_entries_prop {##1}
-        }
-        \prop_gput:NnV \g__uftag_attr_objnum_prop {##1} {\l_tmpa_tl}
-      }
-     \tl_put_right:Nx \l__uftag_attr_value_tl
-      {
-       \c_space_tl
-       \prop_item:Nn \g__uftag_attr_objnum_prop {##1}
-       \c_space_tl 0 \c_space_tl R
-      }
- %    \tl_show:N \l__uftag_attr_value_tl
-    }
-    \tl_put_right:Nx \l__uftag_attr_value_tl
-     {
-      \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{]}
-     }
- %   \tl_show:N \l__uftag_attr_value_tl
-    \__uftag_prop_gput:cnx
-     { g__uftag_struct_\int_eval:n {\c at g__uftag_struct_abs_int}_prop }
-     { A }
-     { \l__uftag_attr_value_tl }
-   },
- }
-\endinput
+        \clist_set:No          \l_tmpa_clist { #1 }
+        \seq_set_from_clist:NN \l_tmpa_seq \l_tmpa_clist
+        \tl_set:Nx \l__tag_attr_value_tl
+          {
+            \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{[}%]
+          }
+        \seq_map_inline:Nn \l_tmpa_seq
+          {
+            \prop_if_in:NnF \g__tag_attr_entries_prop {##1}
+              {
+                \msg_error:nnn { tag } { attr-unknown } { ##1 }
+              }
+            \prop_if_in:NnF \g__tag_attr_objref_prop {##1}
+              {%\prop_show:N \g__tag_attr_entries_prop
+                \pdf_object_unnamed_write:nx
+                  { dict }
+                  {
+                    \prop_item:Nn\g__tag_attr_entries_prop {##1}
+                  }
+                \prop_gput:Nnx \g__tag_attr_objref_prop {##1} {\pdf_object_ref_last:}
+              }
+            \tl_put_right:Nx \l__tag_attr_value_tl
+              {
+                \c_space_tl
+                \prop_item:Nn \g__tag_attr_objref_prop {##1}
+              }
+ %     \tl_show:N \l__tag_attr_value_tl
+          }
+        \tl_put_right:Nx \l__tag_attr_value_tl
+          { %[
+            \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{]}%
+          }
+ %     \tl_show:N \l__tag_attr_value_tl
+        \__tag_prop_gput:cnx
+          { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
+          { A }
+          { \l__tag_attr_value_tl }
+    },
+  }
+%% 
+%%
+%% End of file `tagpdf-attr-code.sty'.

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,188 +1,208 @@
-\ProvidesExplPackage {tagpdf-checks-code} {2019/07/02} {0.61}
+%%
+%% This is file `tagpdf-checks-code.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tagpdf-checks.dtx  (with options: `checks')
+%% 
+%% Copyright (C) 2019 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-checks.dtx
+\ProvidesExplPackage {tagpdf-checks-code} {2021/02/23} {0.80}
  {part of tagpdf - code related to checks and messages}
 
 
-%messages
+\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} { label~#1~unknown~-~rerun }
+\msg_new:nnn { tag } {mc-used-twice}    { mc~#1~has~been~already~used }
+\msg_new:nnn { tag } {mc-not-open}      { there~is~no~mc~to~end~at~#1 }
 
-% mc
-\msg_new:nnn {uftag} {mc-nested}        { nested~marked~content~found~-~mcid~#1 }
-\msg_new:nnn {uftag} {mc-tag-missing}   { required~tag~missing~-~mcid~#1 }
-\msg_new:nnn {uftag} {mc-label-unknown} { label~#1~unknown~-~rerun }
-\msg_new:nnn {uftag} {mc-used-twice}    { mc~#1~has~been~already~used }
-\msg_new:nnn {uftag} {mc-not-open}      { there~is~no~mc~to~end~at~#1 }
+\msg_new:nnn { tag } {struct-no-objnum}      { objnum~missing~for~structure~#1 }
+\msg_new:nnn { tag } {struct-faulty-nesting} { there~is~no~open~structure~on~the~stack }
+\msg_new:nnn { tag } {struct-missing-tag}    { a~structure~must~have~a~tag! }
+\msg_new:nnn { tag } {struct-show-closing}   { closing~structure~#1~tagged~\prop_item:cn{g__tag_struct_#1_prop}{S} }
+\msg_new:nnn { tag } {struct-used-twice}     { structure~with~label~#1~has~already~been~used}
+\msg_new:nnn { tag } {struct-label-unknown}  { structure~with~label~#1~is~unknown~rerun}
 
-% structures
-\msg_new:nnn {uftag} {struct-no-objnum}      { objnum~missing~for~structure~#1 }
-\msg_new:nnn {uftag} {struct-faulty-nesting} { there~is~no~open~structure~on~the~stack }
-\msg_new:nnn {uftag} {struct-missing-tag}    { a~structure~must~have~a~tag! }
-\msg_new:nnn {uftag} {struct-show-closing}   { closing~structure~#1~tagged~\prop_item:cn{g__uftag_struct_#1_prop}{S} }
-\msg_new:nnn {uftag} {struct-used-twice}     { structure~with~label~#1~has~already~been~used}
-\msg_new:nnn {uftag} {struct-label-unknown}  { structure~with~label~#1~is~unknown~rerun}
+\msg_new:nnn { tag } {attr-unknown}  { attribute~#1~is~unknown}
 
-% attributes
-\msg_new:nnn {uftag} {attr-unknown}  { attribute~#1~is~unknown}
+\msg_new:nnn { tag } {role-missing}     { tag~#1~has~no~role~assigned  }
+\msg_new:nnn { tag } {role-unknown}     { role~#1~is~not~known  }
+\msg_new:nnn { tag } {role-unknown-tag} { tag~#1~is~not~known  }
+\msg_new:nnn { tag } {role-new-tag}     { adding~new~tag~#1~mapped~to~role~#2  }
 
+\msg_new:nnn { tag } {tree-mcid-index-wrong} {something~is~wrong~with~the~mcid}
 
-%Roles
-\msg_new:nnn {uftag} {role-missing}     { tag~#1~has~no~role~assigned  }
-\msg_new:nnn {uftag} {role-unknown}     { role~#1~is~not~known  }
-\msg_new:nnn {uftag} {role-unknown-tag} { tag~#1~is~not~known  }
-\msg_new:nnn {uftag} {role-new-tag}     { adding~new~tag~#1~mapped~to~role~#2  }
+\msg_new:nnn { tag } {obj-write-num} {write~obj~#1~to~pdf}
 
+\msg_new:nnn { tag } {sys-no-interwordspace} {engine~#1~doesn't~support~the~interword~spaces}
 
-% trees
-\msg_new:nnn {uftag} {tree-mcid-index-wrong} {something~is~wrong~with~the~mcid}
 
-% obj
-\msg_new:nnn {uftag} {obj-write-num} {write~obj~#1~to~pdf}
+\cs_new:Nn \__tag_check_structure_has_tag:n %#1 struct num %_protected?
+  {
+    \prop_if_in:cnF { g__tag_struct_#1_prop }
+      {S}
+      {
+        \msg_error:nn { tag } {struct-missing-tag}
+      }
+  }
 
+\cs_new:Nn \__tag_check_structure_tag:N            %_protected?
+  {
+    \prop_if_in:NoF \g__tag_role_tags_prop {#1}
+      {
+        \msg_warning:nnx { tag } {role-unknown-tag} {#1}
+      }
+  }
 
-%checks
-%structures
+\cs_new_protected:Nn \__tag_check_info_closing_struct:n %#1 struct num
+  {
+    \msg_info:nnn { tag } {struct-show-closing} {#1}
+  }
 
-\cs_new:Nn \__uftag_check_structure_has_tag:n %#1 struct num
- {
-  \prop_if_in:cnF { g__uftag_struct_#1_prop }
-   {S}
-   {
-    \msg_error:nn {uftag} {struct-missing-tag}
-   }
- }
+\cs_generate_variant:Nn \__tag_check_info_closing_struct:n {o,x}
 
-\cs_new:Nn \__uftag_check_structure_tag:N
- {
-  \prop_if_in:NoF \g__uftag_role_tags_prop {#1}
-   {
-    \msg_warning:nnx {uftag} {role-unknown-tag} {#1}
-   }
- }
+\cs_new_protected:Nn \__tag_check_no_open_struck:
+  {
+    \msg_error:nn { tag } {struct-faulty-nesting}
+  }
 
-\cs_new:Nn \__uftag_check_info_closing_struct:n %#1 struct num
- {
-  \msg_info:nnn {uftag} {struct-show-closing} {#1}
- }
+\cs_new_protected:Nn \__tag_check_struct_used:n %#1 label
+  {
+    \prop_get:cnNT
+      {g__tag_struct_\__tag_ref_value:enn{tagpdfstruct-#1}{tagstruct}{unknown}_prop}
+      {P}
+      \l_tmpa_tl
+      {
+        \msg_warning:nnn { tag } {struct-used-twice} {#1}
+      }
+  }
 
-\cs_generate_variant:Nn \__uftag_check_info_closing_struct:n {o,x}
 
-\cs_new:Nn \__uftag_check_no_open_struck:
- {
-  \msg_error:nn {uftag} {struct-faulty-nesting}
- }
+\cs_new_protected:Nn \__tag_check_add_tag_role:nn %#1 tag, #2 role
+  {
+    \tl_if_empty:nTF {#2}
+      {
+        \msg_warning:nnn { tag } {role-missing} {#1}
+      }
+      {
+        \prop_get:NnNTF \g__tag_role_tags_prop {#2} \l_tmpa_tl
+          {
+            \msg_info:nnnn { tag } {role-new-tag} {#1} {#2}
+          }
+          {
+            \msg_warning:nnn { tag } {role-unknown} {#2}
+          }
+      }
+  }
 
-\cs_new:Nn \__uftag_check_struct_used:n %#1 label
- {
-  \prop_get:cnNT
-   {g__uftag_struct_\zref at extractdefault{tagpdfstruct-#1}{tagstruct}{unknown}_prop}
-   {P}
-   \l_tmpa_tl
-   { \msg_warning:nnn {uftag} {struct-used-twice} {#1} }
- }
+\cs_new_protected:Nn \__tag_check_mc_if_nested:
+  {
+    \__tag_mc_if_in:T
+      {
+        \msg_warning:nnx { tag } {mc-nested} { \__tag_get_mc_abs_cnt: }
+      }
+  }
 
-%roles
-
-\cs_new:Nn \__uftag_check_add_tag_role:nn %#1 tag, #2 role
- {
-  \tl_if_empty:nTF {#2}
+\cs_new_protected:Nn \__tag_check_mc_if_open:
   {
-   \msg_warning:nnn {uftag} {role-missing} {#1}
+    \__tag_mc_if_in:F
+      {
+        \msg_warning:nnx { tag } {mc-not-open} { \__tag_get_mc_abs_cnt: }
+      }
   }
+
+\cs_new:Nn \__tag_check_mc_tag:N %protected??
   {
-   \prop_get:NnNF \g__uftag_role_tags_prop {#2} \l_tmpa_tl
-    {
-     \msg_warning:nnn {uftag} {role-unknown} {#2}
-    }
-    {
-     \msg_info:nnnn {uftag} {role-new-tag} {#1} {#2}
-    }
+    \tl_if_empty:NT #1
+      {
+        \msg_error:nnx { tag } {mc-tag-missing} { \__tag_get_mc_abs_cnt: }
+      }
+   \prop_if_in:NoF \g__tag_role_tags_prop {#1}
+     {
+       \msg_warning:nnx { tag } {role-unknown-tag} {#1}
+     }
   }
- }
 
-%mc
-\cs_new:Nn \__uftag_check_mc_if_nested:
- {
-  \__uftag_mc_if_in:T
-   {
-    \msg_warning:nnx {uftag} {mc-nested} { \__uftag_get_mc_abs_cnt: }
-   }
- }
-
-\cs_new:Nn \__uftag_check_mc_if_open:
- {
-  \__uftag_mc_if_in:F
-   {
-    \msg_warning:nnx {uftag} {mc-not-open} { \__uftag_get_mc_abs_cnt: }
-   }
- }
-
-\cs_new:Nn \__uftag_check_mc_tag:N
- {
-  \tl_if_empty:NT #1
-   {
-    \msg_error:nnx {uftag} {mc-tag-missing} { \__uftag_get_mc_abs_cnt: }
-   }
-   \prop_if_in:NoF \g__uftag_role_tags_prop {#1}
-   {
-    \msg_warning:nnx {uftag} {role-unknown-tag} {#1}
-   }
- }
-
-\seq_new:N \g__uftag_check_mc_used_seq
-\cs_new:Nn \__uftag_check_mc_used:n
- {
-  \seq_if_in:NnTF \g__uftag_check_mc_used_seq {#1}
-   {
-    \msg_warning:nnn {uftag} {mc-used-twice} {#1}
-   }
-   {
-    \seq_gput_right:Nx \g__uftag_check_mc_used_seq {#1}
-   }
- }
-
-
-
-\cs_new:Nn \__uftag_check_show_MCID_by_page:
- {
-  \tl_set:Nx \l__uftag_tmpa_tl
+\seq_new:N \g__tag_check_mc_used_seq
+\cs_new_protected:Nn \__tag_check_mc_used:n
   {
-   \zref at extractdefault
-    {LastPage} {abspage} {-1}
+    \seq_if_in:NnTF \g__tag_check_mc_used_seq {#1}
+      {
+        \msg_warning:nnn { tag } {mc-used-twice} {#1}
+      }
+      {
+        \seq_gput_right:Nx \g__tag_check_mc_used_seq {#1}
+      }
   }
-  \int_step_inline:nnnn {1}{1}
+
+\cs_new_protected:Nn \__tag_check_show_MCID_by_page:
   {
-   \l__uftag_tmpa_tl
+    \tl_set:Nx \l__tag_tmpa_tl
+      {
+        \__tag_ref_value_lastpage:nn
+          {abspage}
+          {-1}
+      }
+    \int_step_inline:nnnn {1}{1}
+      {
+        \l__tag_tmpa_tl
+      }
+      {
+        \seq_clear:N \l_tmpa_seq
+        \int_step_inline:nnnn
+          {1}
+          {1}
+          {
+            \__tag_ref_value_lastpage:nn
+              {tagmcabs}
+              {-1}
+          }
+          {
+            \int_compare:nT
+              {
+                \__tag_ref_value:enn
+                  {mcid-####1}
+                  {tagabspage}
+                  {-1}
+                =
+                ##1
+             }
+             {
+               \seq_gput_right:Nx \l_tmpa_seq
+                 {
+                   Page##1-####1-
+                   \__tag_ref_value:enn
+                     {mcid-####1}
+                     {tagmcid}
+                     {-1}
+                 }
+             }
+          }
+          \seq_show:N \l_tmpa_seq
+      }
   }
+
+\cs_new:Nn \__tag_check_record_pdfobj_num:n %protected?
   {
-   \seq_clear:N \l_tmpa_seq
-   \int_step_inline:nnnn {1}{1}
-    {
-     \zref at extractdefault
-     {LastPage} {tagmcabs} {-1}
-    }
-    {
-     \int_compare:nT
-     {
-      \zref at extractdefault
-      {mcid-####1} {tagabspage} {-1}
-      = ##1
-     }
-     {
-      \seq_gput_right:Nx \l_tmpa_seq
+    \int_compare:nT { \l__tag_loglevel_int >= 3 }
       {
-       Page##1-####1-\zref at extractdefault
-       {mcid-####1} {tagmcid} {-1}
+        \msg_info:nnx { tag } {obj-write-num} {#1}
       }
-     }
-    }
-    \seq_show:N \l_tmpa_seq
   }
- }
 
-\cs_new:Nn \__uftag_check_record_pdfobj_num:n
- {
-  \int_compare:nT { \l__uftag_loglevel_int >= 3 }
-   {
-    \msg_info:nnx {uftag} {obj-write-num} {#1}
-   }
- }
-
-\endinput
+%% 
+%%
+%% End of file `tagpdf-checks-code.sty'.

Added: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-deprecated.def
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-deprecated.def	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-deprecated.def	2021-02-23 22:24:07 UTC (rev 57857)
@@ -0,0 +1,24 @@
+%%
+%% This is file `tagpdf-deprecated.def',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tagpdf.dtx  (with options: `deprecated')
+%% 
+%% Copyright (C) 2019 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
+%% 
+%%
+%% End of file `tagpdf-deprecated.def'.


Property changes on: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-deprecated.def
___________________________________________________________________
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	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,19 +1,35 @@
-\ProvidesExplFile {tagpdf-luatex.def} {2019/07/02} {0.61}
+%%
+%% This is file `tagpdf-luatex.def',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tagpdf-backend.dtx  (with options: `luatex')
+%% 
+%% Copyright (C) 2019 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-backend.dtx
+\ProvidesExplFile {tagpdf-luatex.def} {2021/02/23} {0.80}
   {tagpdf~driver~for~luatex}
 
-%\newattribute \g__uftag_mc_type_attr     %the value represent the type
-%\newattribute \g__uftag_mc_cnt_attr      %will hold the \c at g__uftag_MCID_abs_int value
+\newattribute \l__tag_mc_type_attr     %the value represent the type
+\newattribute \l__tag_mc_cnt_attr      %will hold the \c at g__tag_MCID_abs_int value
 
-\newattribute \l__uftag_mc_type_attr     %the value represent the type
-\newattribute \l__uftag_mc_cnt_attr      %will hold the \c at g__uftag_MCID_abs_int value
+\newattribute \g__tag_interwordspace_attr
+\newattribute \g__tag_interwordfont_attr
 
-\newattribute \g__uftag_interwordspace_attr
-\newattribute \g__uftag_interwordfont_attr
-
-% The lua code
-% ensure that 10pt font has been loaded:
 {
- \fontencoding{TU}\fontfamily{lmr}\fontseries{m}\fontshape{n}\fontsize{10pt}{10pt}\selectfont
+  \fontencoding{TU}\fontfamily{lmr}\fontseries{m}\fontshape{n}\fontsize{10pt}{10pt}\selectfont
 }
 \directlua { tagpdf=require('tagpdf.lua') }
 
@@ -20,177 +36,66 @@
 %%%% driver (lualatex) commands
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-% these should be in expl3!!!
-\cs_new:Nn \__uftag_pdf_startlink:{ \pdfextension startlink }
-\cs_new:Nn \__uftag_pdf_endlink:  { \pdfextension endlink }
-\cs_new_protected:Nn \__uftag_pdf_lastlink: { \numexpr\pdffeedback lastlink\relax }
-\cs_new:Nn \__uftag_pdf_catalog:  { \pdfextension catalog }
 
-% needed for \str_set_convert:Nnon
-\tl_new:N   \g__uftag_inputencoding_tl
-\tl_gset:Nn \g__uftag_inputencoding_tl {}
+\cs_new:Nn \__tag_luatex_get_table_name:Nn
+  {
+    \tl_set_rescan:Nnn #1  { \char_set_catcode_ignore:N \\ } { #2 }
+  }
 
+\cs_new:Nn \__tag_prop_new:N
+  {
+    \prop_new:N #1
+    \__tag_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
+    \directlua { ltx.__tag.tables.\l_tmpa_tl = {} }
+  }
 
-% literals
-\cs_new:Nn \__uftag_pdfliteral_page:n {\__uftag_tex_pdfextension:D literal~page {#1}}
-\cs_new:Nn \__uftag_pdfcatalog:n      {\__uftag_tex_pdfextension:D catalog {#1}}
+\cs_new:Nn \__tag_seq_new:N
+  {
+    \seq_new:N #1
+    \__tag_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
+    \directlua { ltx.__tag.tables.\l_tmpa_tl = {} }
+  }
 
-%reserve an object num
-\cs_new:Nn \__uftag_pdfreserveobjnum:N
- {
-  % #1 = macro name to be populated with object number
-  \__uftag_tex_pdfextension:D~obj~reserveobjnum
-  \tl_set:Nx #1 { \__uftag_tex_pdffeedback:D lastobj }%
- }
+\cs_new:Nn \__tag_prop_gput:Nnn
+  {
+    \prop_gput:Nnn #1 { #2 } { #3 }
+    \__tag_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
+    \directlua { ltx.__tag.tables.\l_tmpa_tl["#2"] = "#3" }
+  }
 
-% use an object num
-\cs_new:Nn \__uftag_pdfuseobjnum:Nn
- {
- % #1 = macro with object number to be populated
- % #2 = object contents, as valid PDF
- % should #2 be filtered through  \pdfstringdef  ???
-  \__uftag_tex_immediate:D \__uftag_tex_pdfextension:D~obj~useobjnum~#1~{ #2 }%
- }
+\cs_new:Nn \__tag_seq_gput_right:Nn
+  {
+    \seq_gput_right:Nn #1 { #2 }
+    \__tag_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
+    \directlua { table.insert(ltx.__tag.tables.\l_tmpa_tl, "#2") }
+  }
 
-\cs_new:Nn \__uftag_pdfuseobjnum:nn
- {
- % #1 = a number
- % #2 = object contents, as valid PDF
- % should #2 be filtered through  \pdfstringdef  ???
-  \__uftag_tex_immediate:D \__uftag_tex_pdfextension:D~obj~useobjnum~#1~{ #2 }%
- }
 
-% obj num of the dictionary for a page:
-% the page count starts by 1
-% pages can referenced before they are actually created
-% no error if the page later doesn't exist
+\cs_new:Npn \__tag_seq_item:cn #1 #2
+  {
+    \directlua { tex.print(ltx.__tag.tables.#1[#2]) }
+  }
 
-\cs_new:Nn \__uftag_store_pdfpageref:Nn
- {
- % #1 = macro name to be populated with current page object number
- % #2 = number or counter identifying the required page
-  \tl_set:Nx #1 { \__uftag_tex_pdffeedback:D pageref~#2 }%
- }
+\cs_new:Npn \__tag_prop_item:cn #1 #2
+  {
+    \directlua { tex.print(ltx.__tag.tables.#1["#2"]) }
+  }
 
-% a global version of the command
-\cs_new:Nn \__uftag_gstore_pdfpageref:Nn
- {
-  \tl_gset:Nx #1 { \__uftag_tex_pdffeedback:D pageref~#2 }%
- }
+\cs_new:Nn \__tag_seq_show:N
+  {
+    \seq_show:N #1
+    \__tag_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
+    \directlua { ltx.__tag.trace.log ("lua~sequence~array~\l_tmpa_tl",1) }
+    \directlua { ltx.__tag.trace.show_seq (ltx.__tag.tables.\l_tmpa_tl) }
+  }
 
-\cs_new:Nn \__uftag_pdfobj:Nn
- {
- % #1 = macro name to refer to this object
- % #2 = object contents, as valid PDF
- % should #2 be filtered through  \pdfstringdef  ???
-  \__uftag_tex_immediate:D \__uftag_tex_pdfextension:D~obj~{ #2 }
-  \tl_set:Nx #1 { \__uftag_tex_pdffeedback:D~lastobj }%
+\cs_new:Nn \__tag_prop_show:N
+  {
+    \prop_show:N #1
+    \__tag_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
+    \directlua {ltx.__tag.trace.log  ("lua~property~table~\l_tmpa_tl",1) }
+    \directlua {ltx.__tag.trace.show_prop (ltx.__tag.tables.\l_tmpa_tl) }
  }
-
-%  pdfpage**s**attr: for all pages
-%% is global needed? Yes. Without it the setting is lost if issued in a group
-%
-\cs_new:Nn \__uftag_gset_pdfpagesattr:n
- {
-  \__uftag_tex_global:D \__uftag_tex_pdfvariable:D~pagesattr { #1 }
- }
-
-\cs_new:Nn \__uftag_gadd_pdfpagesattr:n
- {
-  \exp_args:No \__uftag_gset_pdfpagesattr:n { \__uftag_tex_the:D \__uftag_tex_pdfvariable:D~pagesattr #1}
- }
-
-% pdfpageattr for one page
-% do we need an immediate version??
-\cs_new:Nn \__uftag_gset_pdfpageattr:n
- {
-  \__uftag_tex_global:D \__uftag_tex_pdfvariable:D~pageattr  { #1 }
- }
-
-\cs_new:Nn \__uftag_gadd_pdfpageattr:n
- {
-  \exp_args:No \__uftag_gset_pdfpageattr:n { \__uftag_tex_the:D \__uftag_tex_pdfvariable:D~pageattr #1}
- }
-
-\cs_new:Nn \__uftag_get_pdfpageattr:N
- {
-  \tl_set:No #1 { \__uftag_tex_the:D \__uftag_tex_pdfvariable:D~pageattr }
- }
-
-
-% I probably want also lua tables
-% I put them in the uftag.tables namespaces
-% The tables will be named like the variables but without backslash
-% To access such a table with a dynamical name create a string and then use
-% uftag.tables[string]
-% Old code, I'm not quite sure if this was a good idea. Now I have mix of table in
-% utftag.tables and uftag.mc/struct. And a lot is probably not needed.
-
-\cs_new:Nn \__uftag_luatex_get_table_name:Nn
- {
-  \tl_set_rescan:Nnn #1  { \char_set_catcode_ignore:N \\ } { #2 }
- }
-
-
-\cs_new:Nn \__uftag_prop_new:N
- {
-  \prop_new:N #1
-  \__uftag_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
-  \directlua { uftag.tables.\l_tmpa_tl = {} }
- }
-
-
-\cs_new:Nn \__uftag_seq_new:N
- {
-  \seq_new:N #1
-  \__uftag_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
-  \directlua { uftag.tables.\l_tmpa_tl = {} }
- }
-
-
-\cs_new:Nn \__uftag_prop_gput:Nnn
- {
-  \prop_gput:Nnn #1 { #2 } { #3 }
-  \__uftag_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
-  \directlua { uftag.tables.\l_tmpa_tl["#2"] = "#3" }
- }
-
-
-\cs_new:Nn \__uftag_seq_gput_right:Nn
- {
-  \seq_gput_right:Nn #1 { #2 }
-  \__uftag_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
-  \directlua { table.insert(uftag.tables.\l_tmpa_tl, "#2") }
- }
-
-%Hm not quite sure about the naming
-
-\cs_new:Npn \__uftag_seq_item:cn #1 #2
- {
-  \directlua { tex.print(uftag.tables.#1[#2]) }
- }
-
-\cs_new:Npn \__uftag_prop_item:cn #1 #2
- {
-  \directlua { tex.print(uftag.tables.#1["#2"]) }
- }
-
-%for debugging commands that show both the seq/prop and the lua tables
-\cs_new:Nn \__uftag_seq_show:N
- {
-   \seq_show:N #1
-   \__uftag_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
-   \directlua { uftag.trace.log ("lua~sequence~array~\l_tmpa_tl",1) }
-   \directlua { uftag.trace.show_seq (uftag.tables.\l_tmpa_tl) }
- }
-
-\cs_new:Nn \__uftag_prop_show:N
- {
-   \prop_show:N #1
-   \__uftag_luatex_get_table_name:Nn \l_tmpa_tl { #1 }
-   \directlua {uftag.trace.log  ("lua~property~table~\l_tmpa_tl",1) }
-   \directlua {uftag.trace.show_prop (uftag.tables.\l_tmpa_tl) }
- }
-
-
-\endinput
+%% 
+%%
+%% End of file `tagpdf-luatex.def'.

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	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,285 +1,287 @@
-\ProvidesExplPackage {tagpdf-mc-code-generic} {2019/07/02} {0.61}
+%%
+%% This is file `tagpdf-mc-code-generic.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tagpdf-mc.dtx  (with options: `generic')
+%% 
+%% Copyright (C) 2019 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-mc-code-generic} {2021/02/23} {0.80}
  {part of tagpdf - code related to marking chunks - generic mode}
 
-% for the label system
-% tagmcid is the id which should be also in the pdf
-% it will be (hopefully) reset by page
 
-\int_new:N \g__uftag_MCID_tmp_bypage_int
-\zref at newprop {tagmcid}   [0] { \int_use:N \g__uftag_MCID_tmp_bypage_int }
-\zref at addprop {uftagzrl}  {tagmcid}
+\__tag_prop_new:N \g__tag_MCID_byabspage_prop
 
-% will hold the current maximum on a page
-% it will contain key-value of type "abspagenum=max mcid on this page"
-\__uftag_prop_new:N \g__uftag_MCID_byabspage_prop
+\bool_new:N \g__tag_in_mc_bool
 
-%to test nesting mc:
-\bool_new:N \g__uftag_in_mc_bool
+\prg_new_conditional:Nnn \__tag_mc_if_in: {p,T,F,TF}
+  {
+    \bool_if:NTF \g__tag_in_mc_bool
+      { \prg_return_true:  }
+      { \prg_return_false: }
+  }
 
-\prg_new_conditional:Nnn \__uftag_mc_if_in: {p,T,F,TF}
- {
-  \bool_if:NTF \g__uftag_in_mc_bool
-   { \prg_return_true:  }
-   { \prg_return_false: }
- }
+\prg_new_eq_conditional:NNn \tag_mc_if_in: \__tag_mc_if_in: {p,T,F,TF}
 
-\prg_new_eq_conditional:NNn \uftag_mc_if_in: \__uftag_mc_if_in: {p,T,F,TF}
+\prg_new_eq_conditional:NNn \uftag_mc_if_in: \__tag_mc_if_in: {p,T,F,TF}
 
+\cs_new_protected:Nn \__tag_mc_bmc:n
+  {
+    \pdf_bmc:n {#1}
+  }
 
-% this are the low level mc command.
-% they insert literals and so a are specific to generic mode
-% checking if the type is defined will done somewhere else
-% #1 is the type/tag
-% change 04.08.2018: I don't try to escape the name, but assume that it is valid.
-% Checks/conversions should perhaps be done on a higher level
-\cs_new:Nn \__uftag_mc_bmc:n
- {
-  \__uftag_pdfliteral_page:n
-   {
-    /#1\c_space_tl BMC
-   }
- }
+\cs_new_protected:Nn \__tag_mc_emc:
+  {
+    \pdf_emc:
+    %\__tag_pdfliteral_page:n
+  }
 
-\cs_new:Nn \__uftag_mc_emc:
- {
-  \__uftag_pdfliteral_page:n
-   {
-    EMC
-   }
- }
+\cs_new_protected:Nn \__tag_mc_bdc:nn
+  {
+    \pdf_bdc:nn { #1 } { #2 }
+  }
 
-% #1 tag, #2 properties
-% change 04.08.2018: I don't escape the name. Also the dictionary content
-% must imho be done at a higher level
-\cs_new:Nn \__uftag_mc_bdc:nn
- {
-  \__uftag_pdfliteral_page:n
-   {
-    /#1\c_space_tl<<#2>>~BDC
-   }
+\cs_generate_variant:Nn \__tag_mc_bdc:nn {nx}
+
+\tl_new:N \l__tag_mc_ref_abspage_tl %will store the abspage value of label
+\tl_new:N \l__tag_mc_tmp_tl
+
+\cs_new:Nn \__tag_mc_bdc_mcid:nn
+  {
+    \int_gincr:N \c at g__tag_MCID_abs_int
+    \tl_set:Nx \l__tag_mc_ref_abspage_tl
+      {
+        \__tag_ref_value:enn %3 args
+          {
+            mcid-\int_use:N \c at g__tag_MCID_abs_int
+          }
+          { tagabspage }
+          {-1}
+      }
+    \prop_get:NoNTF
+      \g__tag_MCID_byabspage_prop
+      {
+        \l__tag_mc_ref_abspage_tl
+      }
+      \l__tag_mc_tmp_tl
+      {
+        %key already present, use value for MCID and add 1 for the next
+        \int_gset:Nn \g__tag_MCID_tmp_bypage_int { \l__tag_mc_tmp_tl }
+        \__tag_prop_gput:Nxx
+          \g__tag_MCID_byabspage_prop
+          { \l__tag_mc_ref_abspage_tl }
+          { \int_eval:n {\l__tag_mc_tmp_tl +1} }
+      }
+      {
+        %key not present, set MCID to 0 and insert 1
+        \int_gzero:N \g__tag_MCID_tmp_bypage_int
+        \__tag_prop_gput:Nxx
+          \g__tag_MCID_byabspage_prop
+          { \l__tag_mc_ref_abspage_tl }
+          {1}
+      }
+    \__tag_ref_label:en
+      {
+        mcid-\int_use:N \c at g__tag_MCID_abs_int
+      }
+      { mc }
+   %\exp_args:Nnx
+     \__tag_mc_bdc:nx
+       {#1}
+       { /MCID~\int_eval:n { \g__tag_MCID_tmp_bypage_int }~ \exp_not:n { #2 } }
  }
 
+\cs_new:Nn \__tag_mc_bdc_mcid:n
+  {
+    \__tag_mc_bdc_mcid:nn {#1} {}
+  }
 
-% bdc with /MCID + more properties
-% we need a ref-label system to ensure that the cnt restarts at 0 on a new page
+\cs_new:Nn  \__tag_mc_bmc_artifact:
+  {
+    \__tag_mc_bmc:n {Artifact}
+  }
 
-\tl_new:N \l__uftag_mc_ref_abspage_tl %will store the abspage value of label
-\tl_new:N \l__uftag_mc_tmp_tl
+\cs_new:Nn \__tag_mc_bmc_artifact:n
+  {
+    \__tag_mc_bdc:nn {Artifact}{/Type/#1}
+  }
 
-\cs_new:Nn \__uftag_mc_bdc_mcid:nn
- {
-  \int_gincr:N \c at g__uftag_MCID_abs_int
-  \tl_set:Nx \l__uftag_mc_ref_abspage_tl
-   {
-    \zref at extractdefault %3 args
-    {
-     mcid-\int_use:N \c at g__uftag_MCID_abs_int
-    }
-    {tagabspage}
-    {-1}
-   }
-  \prop_get:NoNTF
-   \g__uftag_MCID_byabspage_prop
-   {
-    \l__uftag_mc_ref_abspage_tl
-   }
-   \l__uftag_mc_tmp_tl
-   {
-    %key already present, use value for MCID and add 1 for the next
-    \int_gset:Nn \g__uftag_MCID_tmp_bypage_int { \l__uftag_mc_tmp_tl }
-    \__uftag_prop_gput:Nxx
-     \g__uftag_MCID_byabspage_prop
-     { \l__uftag_mc_ref_abspage_tl }
-     { \int_eval:n {\l__uftag_mc_tmp_tl +1} }
-   }
-   {
-    %key not present, set MCID to 0 and insert 1
-    \int_gzero:N \g__uftag_MCID_tmp_bypage_int
-    \__uftag_prop_gput:Nxx
-     \g__uftag_MCID_byabspage_prop
-     { \l__uftag_mc_ref_abspage_tl }
-     {1}
-   }
-  \zref at labelbylist
-   {
-    mcid-\int_use:N \c at g__uftag_MCID_abs_int
-   }
-   {uftagzrl}
-  \__uftag_mc_bdc:nn
-   {#1}
-   { /MCID~\int_eval:n { \g__uftag_MCID_tmp_bypage_int }~#2 }
- }
 
-% only /MCID
-\cs_new:Nn \__uftag_mc_bdc_mcid:n
- {
-  \__uftag_mc_bdc_mcid:nn {#1} {}
- }
 
-%artifact without type
-\cs_new:Nn  \__uftag_mc_bmc_artifact:
- {
-  \__uftag_mc_bmc:n {Artifact}
- }
+\tl_new:N \l__tag_mc_key_tag_tl
+\tl_new:N \g__tag_mc_key_tag_tl %for "outside" queries
+\tl_new:N \l__tag_mc_key_properties_tl
 
-%artifact with a type:
-\cs_new:Nn \__uftag_mc_bmc_artifact:n
- {
-  \__uftag_mc_bdc:nn {Artifact}{/Type\c_space_tl/#1}
- }
+\keys_define:nn { __tag / mc }
+  {
+    tag .code:n = % the name (H,P,Spa) etc
+      {
+         %%????????? \pdfescapename??
+        \tl_set:Nx   \l__tag_mc_key_tag_tl { #1 }
+        \tl_gset:Nx  \g__tag_mc_key_tag_tl { #1 }
+      },
+    raw  .code:n =
+      {
+        \tl_put_right:Nx \l__tag_mc_key_properties_tl { #1 }
+      },
+    alttext .code:n = % Alt property
+      {
+        \str_set_convert:Nnon
+          \l__tag_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \tl_put_right:Nn \l__tag_mc_key_properties_tl { /Alt~< }
+        \tl_put_right:No \l__tag_mc_key_properties_tl { \l__tag_tmpa_str>~ }
+      },
+    alttext-o .code:n      = % Alt property
+      {
+        \str_set_convert:Noon
+          \l__tag_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \tl_put_right:Nn \l__tag_mc_key_properties_tl { /Alt~< }
+        \tl_put_right:No \l__tag_mc_key_properties_tl { \l__tag_tmpa_str>~ }
+      },
+    actualtext .code:n      = % ActualText property
+      {
+        \str_set_convert:Nnon
+          \l__tag_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \tl_put_right:Nn \l__tag_mc_key_properties_tl { /ActualText~< }
+        \tl_put_right:No \l__tag_mc_key_properties_tl { \l__tag_tmpa_str>~ }
+      },
+    actualtext-o .code:n      = % ActualText property
+      {
+        \str_set_convert:Noon
+          \l__tag_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \tl_put_right:Nn \l__tag_mc_key_properties_tl { /ActualText~< }
+        \tl_put_right:No \l__tag_mc_key_properties_tl { \l__tag_tmpa_str>~ }
+      },
+    label .tl_set:N        = \l__tag_mc_key_label_tl,
+    artifact .code:n       =
+      {
+        \exp_args:Nnx
+          \keys_set:nn
+            { __tag / mc }
+            { artifact-bool, artifact-type=#1 }
+      },
+    artifact .default:n    = {notype}
+  }
 
-% perhaps later: more properties for artifacts
+\cs_new:Nn \__tag_mc_handle_artifact:N %#1 contains the artifact type
+  {
+    \tl_if_empty:NTF #1
+      { \__tag_mc_bmc_artifact: }
+      { \exp_args:No\__tag_mc_bmc_artifact:n {#1} }
+  }
 
+\cs_new:Nn \__tag_mc_handle_mcid:nn %#1 tag, #2 properties
+  {
+    \__tag_mc_bdc_mcid:nn {#1} {#2}
+  }
 
-% keyval definitions for the user commands:
+\cs_generate_variant:Nn \__tag_mc_handle_mcid:nn {VV}
 
-\tl_new:N \l__uftag_mc_key_tag_tl
-\tl_new:N \g__uftag_mc_key_tag_tl %for "outside" queries
-\tl_new:N \l__uftag_mc_key_properties_tl
-%Attention! definitions are different in luamode.
-% tag and raw are expanded as \directlua in lua does it too.
-\keys_define:nn { uftag / mc }
- {
-  tag .code:n = % the name (H,P,Span etc
-   {
-    %%????????? \pdfescapename??
-    \tl_set:Nx  \l__uftag_mc_key_tag_tl { #1 }
-    \tl_gset:Nx  \g__uftag_mc_key_tag_tl { #1 }
-   },
-  raw  .code:n =
-   {
-    \tl_put_right:Nx \l__uftag_mc_key_properties_tl { #1 }
-   }
-    ,
-  alttext .code:n      = % Alt property
-   {
-    \str_set_convert:Nnon
-     \l__uftag_tmpa_str
-     { #1 }
-     { \g__uftag_inputencoding_tl }
-     { utf16/hex }
-    \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< }
-    \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ }
-   },
-   alttext-o .code:n      = % Alt property
-   {
-    \str_set_convert:Noon
-     \l__uftag_tmpa_str
-     { #1 }
-     { \g__uftag_inputencoding_tl }
-     { utf16/hex }
-    \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< }
-    \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ }
-   },
-   actualtext .code:n      = % ActualText property
-   {
-    \str_set_convert:Nnon
-     \l__uftag_tmpa_str
-     { #1 }
-     { \g__uftag_inputencoding_tl }
-     { utf16/hex }
-    \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /ActualText~< }
-    \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ }
-   },
-   actualtext-o .code:n      = % ActualText property
-   {
-    \str_set_convert:Noon
-     \l__uftag_tmpa_str
-     { #1 }
-     { \g__uftag_inputencoding_tl }
-     { utf16/hex }
-    \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /ActualText~< }
-    \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ }
-   },
-  label .tl_set:N        = \l__uftag_mc_key_label_tl,
-  artifact .code:n       = { \exp_args:Nnx \keys_set:nn { uftag / mc } { artifact-bool, artifact-type=#1 } },
-  artifact .default:n    = {notype}
- }
+\cs_new:Nn \__tag_mc_handle_stash:n %1 mcidnum
+  {
+    \__tag_check_mc_used:n {#1}
+    \__tag_struct_kid_mc_gput_right:nn
+      { \g__tag_struct_stack_current_tl }
+      {#1}
+   \prop_gput:Nxx \g__tag_mc_parenttree_prop
+     {#1}
+     { \g__tag_struct_stack_current_tl }
+  }
 
-\cs_new:Nn \__uftag_mc_handle_artifact:N %#1 contains the artifact type
- {
-  \tl_if_empty:NTF #1
-   { \__uftag_mc_bmc_artifact: }
-   { \exp_args:No\__uftag_mc_bmc_artifact:n {#1} }
- }
+\cs_new_protected:Nn \tag_mc_begin:n
+  {
+    \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
+      }
+      { %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
+        \tl_if_empty:NF {\l__tag_mc_key_label_tl}
+          {
+            \__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:n { \int_use:N \c at g__tag_MCID_abs_int }
+          }
+      }
+    \group_end:
+  }
 
-\cs_new:Nn \__uftag_mc_handle_mcid:nn %#1 tag, #2 properties
- {
-  \__uftag_mc_bdc_mcid:nn {#1} {#2}
- }
+\cs_set_eq:NN \uftag_mc_begin:n \tag_mc_begin:n
 
+\cs_new_protected:Nn \tag_mc_end:
+  {
+    \__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:
+  }
 
-% puts the absolute number of an mcid in the current structure
-\cs_new:Nn \__uftag_mc_handle_stash:n %1 mcidnum
- {
-  \__uftag_check_mc_used:n {#1}
-  \__uftag_struct_kid_mc_gput_right:nn
-   { \g__uftag_struct_stack_current_tl }
-   {#1}
-  \prop_gput:Nxx \g__uftag_mc_parenttree_prop
-   {#1}
-   { \g__uftag_struct_stack_current_tl }
- }
+\cs_set_eq:NN \uftag_mc_end: \tag_mc_end:
 
-\cs_new_protected:Nn \uftag_mc_begin:n
- {
-  \group_begin:
-   \__uftag_check_mc_if_nested:
-   \bool_gset_true:N \g__uftag_in_mc_bool
-   \keys_set:nn { uftag / mc } {#1}
-   \bool_if:NTF \l__uftag_mc_artifact_bool
-    { %handle artifact
-     \__uftag_mc_handle_artifact:N \l__uftag_mc_artifact_type_tl
-    }
-    { %handle mcid type
-     \__uftag_check_mc_tag:N  \l__uftag_mc_key_tag_tl
-     \__uftag_mc_handle_mcid:nn { \l__uftag_mc_key_tag_tl }{\l__uftag_mc_key_properties_tl}
-     \tl_if_empty:NF {\l__uftag_mc_key_label_tl}
+\cs_new_protected:Nn \tag_mc_use:n %#1: label name
+  {
+    \tl_set:Nx  \l_tmpa_tl { \__tag_ref_value:enn{tagpdf-#1}{tagmcabs}{} }
+    \tl_if_empty:NTF\l_tmpa_tl
       {
-       \__uftag_mc_handle_mc_label:n { \l__uftag_mc_key_label_tl }
+        \msg_warning:nnn {tag} {mc-label-unknown} {#1}
       }
-     \bool_if:NF \l__uftag_mc_key_stash_bool
-     {
-      \__uftag_mc_handle_stash:n { \int_use:N \c at g__uftag_MCID_abs_int }
-     }
-    }
-  \group_end:
- }
+      {
+        \prop_gput:Nxx
+          \g__tag_mc_parenttree_prop
+          {
+            \__tag_ref_value:enn {tagpdf-#1} {tagmcabs} {}
+          }
+          {
+            \g__tag_struct_stack_current_tl
+          }
+        \__tag_struct_kid_mc_gput_right:nn
+          {
+            \g__tag_struct_stack_current_tl
+          }
+          {
+            \__tag_ref_value:enn {tagpdf-#1} {tagmcabs} {}
+          }
+       }
+  }
 
-\cs_new_protected:Nn \uftag_mc_end:
- {
-  \__uftag_check_mc_if_open:
-  \bool_gset_false:N \g__uftag_in_mc_bool
-  \tl_gset:Nn  \g__uftag_mc_key_tag_tl { }
-  \__uftag_mc_emc:
- }
+\cs_set_eq:NN \uftag_mc_use:n \tag_mc_use:n
 
-\cs_new_protected:Nn \uftag_mc_use:n %#1: label name
- {
-  \tl_set:Nx  \l_tmpa_tl { \zref at extractdefault{tagpdf-#1}{tagmcabs}{} }
-  \tl_if_empty:NTF\l_tmpa_tl
-   {
-    \msg_warning:nnn {uftag} {mc-label-unknown} {#1}
-   }
-   {
-    \prop_gput:Nxx
-     \g__uftag_mc_parenttree_prop
-     {
-      \zref at extractdefault {tagpdf-#1} {tagmcabs} {}
-     }
-     {
-      \g__uftag_struct_stack_current_tl
-     }
-    \__uftag_struct_kid_mc_gput_right:nn
-     {
-      \g__uftag_struct_stack_current_tl
-     }
-     {
-      \zref at extractdefault {tagpdf-#1} {tagmcabs} {}
-     }
-   }
- }
+\cs_new:Nn \__tag_get_data_mc_tag: { \g__tag_mc_key_tag_tl }
 
-\cs_new:Nn \__uftag_get_data_mc_tag: { \g__uftag_mc_key_tag_tl }
-
-\endinput
+%% 
+%%
+%% End of file `tagpdf-mc-code-generic.sty'.

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	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,280 +1,327 @@
-\ProvidesExplPackage {tagpdf-mc-code-lua} {2019/07/02} {0.61}
+%%
+%% This is file `tagpdf-mc-code-lua.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tagpdf-mc.dtx  (with options: `luamode')
+%% 
+%% Copyright (C) 2019 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-mc-code-lua} {2021/02/23} {0.80}
   {tagpdf - mc code only for the luamode }
 
-% the two attibutes are defined in the driver file.
-% it also load the lua (as it can also contain functions needed by generic mode.
-% (new) attributes for mc are local:
-% \newattribute \l__uftag_mc_type_attr     %the value represent the type
-% \newattribute \l__uftag_mc_cnt_attr      %will hold the \c at g__uftag_MCID_abs_int value
 
 
-% An attribute for the current structure probably doesn't make sense as mc chunks can be used later.
-% \newattribute \g__uftag_struct_type_attr %represent the current structure type. Not sure if needed
-% \newattribute \g__uftag_struct_cnt_attr  %will hold \c at g__uftag_struct_abs_int a cnt
 
-% handling attribute needs a different system to number the page wise mcid's:
-% a tagmcbegin ... tagmcend pair no longer surrounds exactly one mc chunk: it can be split
-% at page breaks. We know the included mcid(s) only after the ship out. So for the struct-> mcid mapping we
-% need to record struct -> mc-cnt (in \g__uftag_mc_parenttree_prop and/or a lua table
-% and at shipout mc-cnt-> {mcid, mcid, ...} (in a table?)
-% and when building the trees connect both
 
-% key definitions are overwritten for luatex to store that data in tables
-% the data for the mc are in uftag.mc[absnum]
-% the fields of the table are
-% tag : the type (a string)
-% raw : more properties (string)
-% label: a string. Do we need a way to retrieve the num from the label from lua??
-% artifact: the presence indicates an artifact, the value (string) is the type.
-% kids: a array of tables {1={kid=num2,page=pagenum1}, 2={kid=num2,page=pagenum2},...},
-% this describes the chunks the mc has been split to by the traversing code
-% parent: the number of the structure it is in. Needed to build the parent tree.
+\hook_gput_code:nnn{begindocument}{tagpdf/mc}
+  {
+    \bool_if:NT\g__tag_active_mc_bool
+      {
+        \directlua
+          {
+            if~luatexbase.callbacktypes.pre_shipout_filter~then~
+              luatexbase.add_to_callback("pre_shipout_filter", function(TAGBOX)~
+              ltx.__tag.func.mark_shipout(TAGBOX)~return~true~
+              end, "tagpdf")~
+            end
+          }
+       \directlua
+         {
+           if~luatexbase.callbacktypes.pre_shipout_filter~then~
+           token.get_next()~
+           end
+         }\@secondoftwo\@gobble
+           {
+             \hook_gput_code:nnn{shipout/before}{tagpdf/lua}
+               {
+                 \directlua
+                   { ltx.__tag.func.mark_shipout (tex.box["ShipoutBox"]) }
+               }
+           }
+      }
+  }
 
-% The main function which wanders through the shipout box to inject the literals.
-\AtBeginDocument
- {
-  \bool_if:NT\g_uftag_active_mc_bool
-   {
-    \AtBeginShipout
-     {
-      \directlua{uftag.func.mark_shipout ()}
-     }
-   }
- }
+\prg_new_conditional:Nnn \__tag_mc_if_in: {p,T,F,TF}
+  {
+    \int_compare:nNnTF { -2147483647 }={ \l__tag_mc_type_attr }
+      { \prg_return_false:  }
+      { \prg_return_true: }
+  }
 
-\prg_new_conditional:Nnn \__uftag_mc_if_in: {p,T,F,TF}
- {
-  \int_compare:nNnTF {-2147483647}={\l__uftag_mc_type_attr}
-   { \prg_return_true:  }
-   { \prg_return_false: }
- }
+\prg_new_eq_conditional:NNn \tag_mc_if_in: \__tag_mc_if_in: {p,T,F,TF}
 
-\prg_new_eq_conditional:NNn \uftag_mc_if_in: \__uftag_mc_if_in: {p,T,F,TF}
+\prg_new_eq_conditional:NNn \uftag_mc_if_in: \__tag_mc_if_in: {p,T,F,TF}
 
-% the keys
-\tl_new:N \l__uftag_mc_key_tag_tl
-\tl_new:N \l__uftag_mc_key_label_tl
-\tl_new:N \l__uftag_mc_key_properties_tl
+\tl_new:N \l__tag_mc_key_tag_tl
+\tl_new:N \l__tag_mc_key_label_tl
+\tl_new:N \l__tag_mc_key_properties_tl
 
-\keys_define:nn { uftag / mc }
- {
-  tag .code:n = %
-   {%%????????? \pdfescapename??
-    \tl_set:Nx  \l__uftag_mc_key_tag_tl { #1 }
-    \directlua
-     {
-      uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"tag","#1")
-     }
-   },
-  raw .code:n =
-   {
-    \tl_put_right:Nx \l__uftag_mc_key_properties_tl { #1 }
-    \directlua
-     {
-      uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"raw","#1")
-     }
-   },
-  alttext .code:n      = % Alt property
-   {
-    \str_set_convert:Nnon
-     \l__uftag_tmpa_str
-     { #1 }
-     { \g__uftag_inputencoding_tl }
-     { utf16/hex }
-    \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< }
-    \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ }
-    \directlua
-     {
-      uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"alt","/Alt~<\str_use:N \l__uftag_tmpa_str>")
-     }
-   },
-  alttext-o .code:n      = % Alt property
-   {
-    \str_set_convert:Noon
-     \l__uftag_tmpa_str
-     { #1 }
-     { \g__uftag_inputencoding_tl }
-     { utf16/hex }
-    \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< }
-    \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ }
-    \directlua
-     {
-      uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"alt","/Alt~<\str_use:N \l__uftag_tmpa_str>")
-     }
-   },
-  actualtext .code:n      = % Alt property
-   {
-    \str_set_convert:Nnon
-     \l__uftag_tmpa_str
-     { #1 }
-     { \g__uftag_inputencoding_tl }
-     { utf16/hex }
-    \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< }
-    \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ }
-    \directlua
-     {
-      uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"actualtext","/ActualText~<\str_use:N \l__uftag_tmpa_str>")
-     }
-   },
-  actualtext-o .code:n      = % Alt property
-   {
-    \str_set_convert:Noon
-     \l__uftag_tmpa_str
-     { #1 }
-     { \g__uftag_inputencoding_tl }
-     { utf16/hex }
-    \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< }
-    \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ }
-    \directlua
-     {
-      uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"actualtext","/ActualText~<\str_use:N \l__uftag_tmpa_str>")
-     }
-   },
-  label .code:n =
-   {
-    \tl_set:Nn\l__uftag_mc_key_label_tl { #1 }
-    \directlua {uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"label","#1")}
-   },
-  __artifact-store .code:n =
-   {
-    \directlua {uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"artifact","#1")}
-   },
-  artifact .code:n       =
-    {
-     \exp_args:Nnx \keys_set:nn {uftag / mc} { artifact-bool, artifact-type=#1, tag=Artifact }
-     \exp_args:Nnx \keys_set:nn {uftag / mc }{ __artifact-store=\l__uftag_mc_artifact_type_tl }
-    },
-  artifact .default:n    = { notype }
- }
+\keys_define:nn { __tag / mc }
+  {
+    tag .code:n = %
+      {%%????????? \pdfescapename??
+        \tl_set:Nx  \l__tag_mc_key_tag_tl { #1 }
+        \directlua
+          {
+            ltx.__tag.func.store_mc_data(\__tag_get_mc_abs_cnt:,"tag","#1")
+          }
+      },
+    raw .code:n =
+      {
+        \tl_put_right:Nx \l__tag_mc_key_properties_tl { #1 }
+        \directlua
+          {
+            ltx.__tag.func.store_mc_data(\__tag_get_mc_abs_cnt:,"raw","#1")
+          }
+      },
+    alttext .code:n      = % Alt property
+      {
+        \str_set_convert:Nnon
+          \l__tag_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \tl_put_right:Nn \l__tag_mc_key_properties_tl { /Alt~< }
+        \tl_put_right:No \l__tag_mc_key_properties_tl { \l__tag_tmpa_str>~ }
+        \directlua
+          {
+            ltx.__tag.func.store_mc_data
+              (
+                 \__tag_get_mc_abs_cnt:,"alt","/Alt~<\str_use:N \l__tag_tmpa_str>"
+              )
+          }
+      },
+    alttext-o .code:n      = % Alt property
+      {
+        \str_set_convert:Noon
+          \l__tag_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \tl_put_right:Nn \l__tag_mc_key_properties_tl { /Alt~< }
+        \tl_put_right:No \l__tag_mc_key_properties_tl { \l__tag_tmpa_str>~ }
+        \directlua
+          {
+            ltx.__tag.func.store_mc_data
+              (
+                \__tag_get_mc_abs_cnt:,"alt","/Alt~<\str_use:N \l__tag_tmpa_str>"
+              )
+          }
+      },
+    actualtext .code:n      = % Alt property
+      {
+        \str_set_convert:Nnon
+          \l__tag_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \tl_put_right:Nn \l__tag_mc_key_properties_tl { /Alt~< }
+        \tl_put_right:No \l__tag_mc_key_properties_tl { \l__tag_tmpa_str>~ }
+        \directlua
+          {
+            ltx.__tag.func.store_mc_data
+              (
+                \__tag_get_mc_abs_cnt:,"actualtext","/ActualText~<\str_use:N \l__tag_tmpa_str>"
+              )
+         }
+      },
+    actualtext-o .code:n      = % Alt property
+      {
+        \str_set_convert:Noon
+          \l__tag_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \tl_put_right:Nn \l__tag_mc_key_properties_tl { /Alt~< }
+        \tl_put_right:No \l__tag_mc_key_properties_tl { \l__tag_tmpa_str>~ }
+        \directlua
+          {
+            ltx.__tag.func.store_mc_data
+              (
+                \__tag_get_mc_abs_cnt:,
+                "actualtext",
+                "/ActualText~<\str_use:N \l__tag_tmpa_str>"
+              )
+          }
+      },
+    label .code:n =
+      {
+        \tl_set:Nn\l__tag_mc_key_label_tl { #1 }
+        \directlua
+          {
+            ltx.__tag.func.store_mc_data
+              (
+                \__tag_get_mc_abs_cnt:,"label","#1"
+              )
+          }
+      },
+    __artifact-store .code:n =
+      {
+        \directlua
+          {
+            ltx.__tag.func.store_mc_data
+              (
+                \__tag_get_mc_abs_cnt:,"artifact","#1"
+              )
+          }
+      },
+    artifact .code:n       =
+      {
+        \exp_args:Nnx
+          \keys_set:nn
+            { __tag / mc}
+            { artifact-bool, artifact-type=#1, tag=Artifact }
+        \exp_args:Nnx
+          \keys_set:nn
+            { __tag / mc }
+            { __artifact-store=\l__tag_mc_artifact_type_tl }
+      },
+    artifact .default:n    = { notype }
+  }
 
 
-% attributes
-% set the mc from a tag name
+\cs_set_protected:Npn \__tag_attribute_gset:Nn #1 #2
+  {
+    \tex_global:D \setattribute #1 #2
+  }
 
-\cs_set_protected:Npn \__uftag_attribute_gset:Nn #1 #2
- {
-  \tex_global:D \setattribute #1 #2
- }
+\cs_set_protected:Npn \__tag_attribute_set:Nn #1 #2
+  {
+    \setattribute #1 #2
+  }
 
-\cs_set_protected:Npn \__uftag_attribute_set:Nn #1 #2
- {
-  \setattribute #1 #2
- }
+\cs_set_protected:Npn \__tag_attribute_gunset:N #1
+  {
+    \tex_global:D \unsetattribute #1
+  }
 
-\cs_set_protected:Npn \__uftag_attribute_gunset:N #1
- {
-  \tex_global:D \unsetattribute #1
- }
+\cs_set_protected:Npn \__tag_attribute_unset:N #1
+  {
+    \unsetattribute #1
+  }
 
-\cs_set_protected:Npn \__uftag_attribute_unset:N #1
- {
-   \unsetattribute #1
- }
+\cs_new:Nn \__tag_mc_lua_set_mc_type_attr:n % #1 is a tag name
+  {
+    \__tag_attribute_set:Nn \l__tag_mc_type_attr
+      {
+        \directlua { ltx.__tag.func.output_num_from ("#1") }
+      }
+    \__tag_attribute_set:Nn \l__tag_mc_cnt_attr  { \__tag_get_mc_abs_cnt: }
+  }
 
+\cs_generate_variant:Nn\__tag_mc_lua_set_mc_type_attr:n { o }
 
-\cs_new:Nn \__uftag_mc_lua_set_mc_type_attr:n % #1 is a tag name
- {
-  \__uftag_attribute_set:Nn \l__uftag_mc_type_attr { \directlua {uftag.func.output_num_from ("#1") } }
-  \__uftag_attribute_set:Nn \l__uftag_mc_cnt_attr  { \__uftag_get_mc_abs_cnt: }
- }
+\cs_new:Nn \__tag_mc_lua_unset_mc_type_attr:
+  {
+    \__tag_attribute_unset:N \l__tag_mc_type_attr
+    \__tag_attribute_unset:N \l__tag_mc_cnt_attr
+  }
 
-\cs_generate_variant:Nn\__uftag_mc_lua_set_mc_type_attr:n { o }
+\cs_new:Nn \__tag_mc_insert_mcid_kids:n
+  {
+    \directlua { ltx.__tag.func.mc_insert_kids (#1,0) }
+  }
 
-\cs_new:Nn \__uftag_mc_lua_unset_mc_type_attr:
- {
-  \__uftag_attribute_unset:N \l__uftag_mc_type_attr
-  \__uftag_attribute_unset:N \l__uftag_mc_cnt_attr
- }
+\cs_new:Nn \__tag_mc_insert_mcid_single_kids:n
+  {
+    \directlua {ltx.__tag.func.mc_insert_kids (#1,1) }
+  }
 
 
+\cs_new:Nn \__tag_mc_handle_stash:n %1 mcidnum
+  {
+    \__tag_check_mc_used:n { #1 }
+    \seq_gput_right:cn % Don't fill a lua table due to the command in the item,
+                       % so use the kernel command
+      { g__tag_struct_kids_\g__tag_struct_stack_current_tl _seq }
+      {
+        \__tag_mc_insert_mcid_kids:n {#1}%
+      }
+    \directlua
+      {
+        ltx.__tag.func.store_struct_mcabs
+          (
+            \g__tag_struct_stack_current_tl,#1
+          )
+      }
+    \prop_gput:Nxx
+      \g__tag_mc_parenttree_prop
+      { #1 }
+      { \g__tag_struct_stack_current_tl }
+  }
 
-%This command will in the finish code replace the dummy for a mc by the real mcid kids
-%we need a variant for the case that it is the only kid, to get the array right
-\cs_new:Nn \__uftag_mc_insert_mcid_kids:n
- {
-  \directlua {uftag.func.mc_insert_kids (#1,0) }
- }
+\cs_generate_variant:Nn \__tag_mc_handle_stash:n { o }
 
-\cs_new:Nn \__uftag_mc_insert_mcid_single_kids:n
- {
-  \directlua {uftag.func.mc_insert_kids (#1,1) }
- }
+\cs_new_protected:Nn \tag_mc_begin:n
+  {
+    %\group_begin:
+    %\__tag_check_mc_if_nested:
+    %\bool_gset_true:N \g__tag_in_mc_bool
+    \bool_set_false:N\l__tag_mc_artifact_bool
+    \int_gincr:N \c at g__tag_MCID_abs_int
+    \tl_clear:N \l__tag_mc_key_properties_tl
+    \keys_set:nn { __tag / mc }{ label={}, #1 }
+    %check that a tag or artifact has been used
+    \__tag_check_mc_tag:N \l__tag_mc_key_tag_tl
+    %set the attributes:
+    \__tag_mc_lua_set_mc_type_attr:o  { \l__tag_mc_key_tag_tl }
+    \bool_if:NF \l__tag_mc_artifact_bool
+      { % store the absolute num name in a label:
+        \tl_if_empty:NF {\l__tag_mc_key_label_tl}
+          {
+            \__tag_mc_handle_mc_label:n { \l__tag_mc_key_label_tl }
+          }
+       % if not stashed record the absolute number
+        \bool_if:NF \l__tag_mc_key_stash_bool
+          {
+            \exp_args:Nx \__tag_mc_handle_stash:n { \__tag_get_mc_abs_cnt: }
+          }
+      }
+    %\bool_set_false:N\l__tag_mc_artifact_bool
+    %\group_end:
+  }
 
+\cs_set_eq:NN \uftag_mc_begin:n \tag_mc_begin:n
 
-% we need to pass the info if the kids are alone or already in an array
-% so we add a second argument, which should == 1 if the kids are single
+\cs_new_protected:Nn \tag_mc_end:
+  {
+    %\__tag_check_mc_if_open:
+    %\bool_gset_false:N \g__tag_in_mc_bool
+    \bool_set_false:N\l__tag_mc_artifact_bool
+    \__tag_mc_lua_unset_mc_type_attr:
+    \tl_set:Nn  \l__tag_mc_key_tag_tl { }
+  }
 
+\cs_set_eq:NN \uftag_mc_end: \tag_mc_end:
 
-% puts an mcid absolute number in the current structure
-\cs_new:Nn \__uftag_mc_handle_stash:n %1 mcidnum
- {
-  \__uftag_check_mc_used:n { #1 }
-  \seq_gput_right:cn % Don't fill a lua table due to the command in the item, so the kernel command
-   { g__uftag_struct_kids_\g__uftag_struct_stack_current_tl _seq }
-   {
-    \__uftag_mc_insert_mcid_kids:n {#1}%
-   }
-  \directlua
-   {
-    uftag.func.store_struct_mcabs(\g__uftag_struct_stack_current_tl,#1)
-   }
-  \prop_gput:Nxx
-   \g__uftag_mc_parenttree_prop
-   { #1 }
-   { \g__uftag_struct_stack_current_tl }
- }
-
-\cs_generate_variant:Nn \__uftag_mc_handle_stash:n { o }
-
-\cs_new_protected:Nn \uftag_mc_begin:n
- {
-   %\group_begin:
-   %\__uftag_check_mc_if_nested:
-   %\bool_gset_true:N \g__uftag_in_mc_bool
-   \int_gincr:N \c at g__uftag_MCID_abs_int
-   \tl_clear:N\l__uftag_mc_key_properties_tl
-   \keys_set:nn { uftag / mc }{ label={}, #1 }
-   %check that a tag or artifact has been used
-   \__uftag_check_mc_tag:N \l__uftag_mc_key_tag_tl
-   %set the attributes:
-   \__uftag_mc_lua_set_mc_type_attr:o  { \l__uftag_mc_key_tag_tl }
-   \bool_if:NF \l__uftag_mc_artifact_bool
-    { % store the absolute num name in a label:
-      \tl_if_empty:NF {\l__uftag_mc_key_label_tl}
-       {
-        \__uftag_mc_handle_mc_label:n { \l__uftag_mc_key_label_tl }
-       }
-      % if not stashed record the absolute number
-      \bool_if:NF \l__uftag_mc_key_stash_bool
+\cs_new_protected:Nn \tag_mc_use:n %#1: label name
+  {
+    \tl_set:Nx  \l_tmpa_tl { \__tag_ref_value:enn{tagpdf-#1}{tagmcabs}{} }
+    \tl_if_empty:NTF\l_tmpa_tl
       {
-        \exp_args:Nx \__uftag_mc_handle_stash:n { \__uftag_get_mc_abs_cnt: }
+        \msg_warning:nnn {tag} {mc-label-unknown} { #1 }
       }
-    }
-   \bool_set_false:N\l__uftag_mc_artifact_bool
-  %\group_end:
- }
+      {
+        \__tag_mc_handle_stash:o { \l_tmpa_tl }
+      }
+  }
 
-\cs_new_protected:Nn \uftag_mc_end:
- {
-  %\__uftag_check_mc_if_open:
-  %\bool_gset_false:N \g__uftag_in_mc_bool
-  \__uftag_mc_lua_unset_mc_type_attr:
-  \tl_set:Nn  \l__uftag_mc_key_tag_tl { }
- }
+\cs_set_eq:NN \uftag_mc_use:n \tag_mc_use:n
 
-\cs_new_protected:Nn \uftag_mc_use:n %#1: label name
- {
-  \tl_set:Nx  \l_tmpa_tl { \zref at extractdefault{tagpdf-#1}{tagmcabs}{} }
-  \tl_if_empty:NTF\l_tmpa_tl
-   {
-    \msg_warning:nnn {uftag} {mc-label-unknown} { #1 }
-   }
-   {
-    \__uftag_mc_handle_stash:o { \l_tmpa_tl }
-   }
- }
-
-\cs_new:Nn \__uftag_get_data_mc_tag: { \l__uftag_mc_key_tag_tl }
-
-
-\endinput
+\cs_new:Nn \__tag_get_data_mc_tag: { \l__tag_mc_key_tag_tl }
+%% 
+%%
+%% End of file `tagpdf-mc-code-lua.sty'.

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-shared.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-shared.sty	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-shared.sty	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,47 +1,86 @@
-\ProvidesExplPackage {tagpdf-mc-code-shared} {2019/07/02} {0.61}
- {part of tagpdf - code related to marking chunks - code shared by generic and luamode }
+%%
+%% This is file `tagpdf-mc-code-shared.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tagpdf-mc.dtx  (with options: `shared')
+%% 
+%% Copyright (C) 2019 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-mc-code-shared} {2021/02/23} {0.80}
+  {part of tagpdf - code related to marking chunks -
+   code shared by generic and luamode }
 
-% I use a latex counter for the absolute count, so that it is added to
-% \cl@@ckpt and restored e.g. in tabulars and align
-% \int_new:N  \c at g__uftag_MCID_int and
-% \tl_put_right:Nn\cl@@ckpt{\@elt{g_uf_test_int}}
-% would work too, but as the name is not expl3 then too, why bother?
-% the absolute counter can be used to label and to check if the page
-% counter needs a reset.
+\newcounter { g__tag_MCID_abs_int }
+\cs_new:Nn \__tag_get_mc_abs_cnt: { \int_use:N \c at g__tag_MCID_abs_int }
 
-\newcounter { g__uftag_MCID_abs_int }
-\cs_new:Nn \__uftag_get_mc_abs_cnt: { \int_use:N \c at g__uftag_MCID_abs_int }
 
-% tagmcabs is the label name of the absolute count which is used to identify the chunk
-\zref at newprop {tagmcabs}  [0] { \int_use:N \c at g__uftag_MCID_abs_int }
-\zref at addprop {uftagzrl}   {tagmcabs}
-\zref at addprop {LastPage} {tagmcabs}
+\cs_new:Nn \__tag_mc_handle_mc_label:n
+  {
+    \__tag_ref_label:en{tagpdf-#1}{mc}
+  }
 
-%stores labels of mcid.
-\cs_new:Nn \__uftag_mc_handle_mc_label:n
- {
-  \zref at labelbylist{tagpdf-#1}{uftagzrl}
- }
+\__tag_prop_new:N \g__tag_mc_parenttree_prop
 
-% will hold the structure numbers for the parenttree
-% key:   absolute number of the mc (tagmcabs)
-% value: the structure number the mc is in
-\__uftag_prop_new:N \g__uftag_mc_parenttree_prop
+\tl_new:N \l__tag_mc_artifact_type_tl
 
-%shared keys
-%the rest are in the splitted code
-\tl_new:N \l__uftag_mc_artifact_type_tl
+\keys_define:nn { __tag / mc }
+  {
+    stash                  .bool_set:N    = \l__tag_mc_key_stash_bool,
+    artifact-bool          .bool_set:N    = \l__tag_mc_artifact_bool,
+    artifact-type          .choice:,
+    artifact-type / pagination .code:n    =
+      {
+        \tl_set:Nn \l__tag_mc_artifact_type_tl { Pagination }
+      },
+    artifact-type / layout     .code:n    =
+      {
+        \tl_set:Nn \l__tag_mc_artifact_type_tl { Layout }
+      },
+    artifact-type / page       .code:n    =
+      {
+        \tl_set:Nn \l__tag_mc_artifact_type_tl { Page }
+      },
+    artifact-type / background .code:n    =
+      {
+        \tl_set:Nn \l__tag_mc_artifact_type_tl { Background }
+      },
+    artifact-type / notype     .code:n    =
+      {
+        \tl_set:Nn \l__tag_mc_artifact_type_tl {}
+      },
+     artifact-type /      .code:n    =
+      {
+        \tl_set:Nn \l__tag_mc_artifact_type_tl {}
+      },
+  }
 
-\keys_define:nn { uftag / mc }
+\cs_new_protected:Npn \tag_mc_artifact_group_begin:n #1
  {
-  stash                  .bool_set:N    = \l__uftag_mc_key_stash_bool,
-  artifact-bool          .bool_set:N    = \l__uftag_mc_artifact_bool,
-  artifact-type              .choice:,
-  artifact-type / pagination .code:n    = {\tl_set:Nn \l__uftag_mc_artifact_type_tl { Pagination }},
-  artifact-type / layout     .code:n    = {\tl_set:Nn \l__uftag_mc_artifact_type_tl { Layout     }},
-  artifact-type / page       .code:n    = {\tl_set:Nn \l__uftag_mc_artifact_type_tl { Page }},
-  artifact-type / background .code:n    = {\tl_set:Nn \l__uftag_mc_artifact_type_tl { Background }},
-  artifact-type / notype     .code:n    = {\tl_set:Nn \l__uftag_mc_artifact_type_tl {}},
+  \tag_mc_begin:n {artifact=#1}
+  \tag_stop_group_begin:
  }
 
-\endinput
+\cs_new_protected:Npn \tag_mc_artifact_group_end:
+ {
+  \tag_stop_group_end:
+  \tag_mc_end:
+ }
+
+\int_new:N \g__tag_MCID_tmp_bypage_int
+
+%% 
+%%
+%% End of file `tagpdf-mc-code-shared.sty'.

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,4 +1,25 @@
-\ProvidesExplFile {tagpdf-pdftex.def} {2019/07/02} {0.61}
+%%
+%% This is file `tagpdf-pdftex.def',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tagpdf-backend.dtx  (with options: `pdftex')
+%% 
+%% Copyright (C) 2019 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-backend.dtx
+\ProvidesExplFile {tagpdf-pdftex.def} {2021/02/23} {0.80}
   {tagpdf~driver~for~pdftex}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -5,124 +26,22 @@
 %%%% driver (pdflatex) commands
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-% these should be in expl3!!!
-\cs_new:Nn \__uftag_pdf_startlink:{ \pdfstartlink }
-\cs_new:Nn \__uftag_pdf_endlink:  { \pdfendlink }
-\cs_new:Nn \__uftag_pdf_lastlink:  { \pdflastlink }
-\cs_new:Nn \__uftag_pdf_catalog:  { \pdfcatalog }
+\cs_set_eq:NN \__tag_prop_new:N     \prop_new:N
 
+\cs_set_eq:NN \__tag_seq_new:N      \seq_new:N
 
-% needed for \str_set_convert:Nnon
-\tl_new:N \g__uftag_inputencoding_tl
-\tl_gset:Nn \g__uftag_inputencoding_tl {utf8}
+\cs_set_eq:NN \__tag_prop_gput:Nnn  \prop_gput:Nnn
 
+\cs_set_eq:NN \__tag_seq_gput_right:Nn \seq_gput_right:Nn
 
-%literal
-\cs_new:Nn  \__uftag_pdfliteral_page:n { \__uftag_tex_pdfliteral:D page { #1} }
-\cs_new:Nn  \__uftag_pdfcatalog:n      { \__uftag_tex_pdfcatalog:D { #1 } }
+\cs_set_eq:NN \__tag_seq_item:cn    \seq_item:cn
 
-% reserve an object num and store the number
-\cs_new:Nn \__uftag_pdfreserveobjnum:N % #1 = macro name to be populated with object number
- {
-  \__uftag_tex_pdfobj:D reserveobjnum
-  \tl_set:Nx #1 { \int_use:N \__uftag_tex_pdflastobj:D }%
- }
+\cs_set_eq:NN \__tag_prop_item:cn   \prop_item:cn
 
-% add content to an object num stored in a macro
-\cs_new:Nn \__uftag_pdfuseobjnum:Nn
- {
- % #1 = macro containing the object number
- % #2 = object contents, as valid PDF
- % should #2 be filtered through  \pdfstringdef  ???
-  \__uftag_tex_immediate:D \__uftag_tex_pdfobj:D useobjnum~#1~{#2}%
- }
+\cs_set_eq:NN \__tag_seq_show:N     \seq_show:N
 
-\cs_new:Nn \__uftag_pdfuseobjnum:nn
- {
- % #1 = a number the object number
- % #2 = object contents, as valid PDF
- % should #2 be filtered through  \pdfstringdef  ???
-  \__uftag_check_record_pdfobj_num:n {#1}
-  \__uftag_tex_immediate:D \__uftag_tex_pdfobj:D useobjnum~#1~{#2}%
- }
+\cs_set_eq:NN \__tag_prop_show:N    \prop_show:N
 
-% obj num of the dictionary for a page:
-% the page count starts by 1
-% pages can referenced before they are actually created
-% no error if the page later doesn't exist
-\cs_new:Nn \__uftag_store_pdfpageref:Nn
- {
- % #1 = macro name to be populated with current page object number
- % #2 = number or counter identifying the required page
-  \tl_set:Nx #1 { \__uftag_tex_pdfpageref:D #2}%
- }
-
-% a global version of the command
-\cs_new:Nn \__uftag_gstore_pdfpageref:Nn
- {
-  \tl_gset:Nx #1 { \__uftag_tex_pdfpageref:D #2}%
- }
-
-\cs_new:Nn \__uftag_pdfobj:Nn
- {
- % #1 = macro name to refer to this object
- % #2 = object contents, as valid PDF
- % should #2 be filtered through  \pdfstringdef  ???
-  \__uftag_tex_immediate:D \__uftag_tex_pdfobj:D { #2 }
-  \tl_set:Nx #1 {\int_use:N \__uftag_tex_pdflastobj:D }%
- }
-
-%  pdfpage**s**attr: for all pages
-%% is global needed? Yes. Without it the setting is lost if issued in a group
-%
-\cs_new:Nn \__uftag_gset_pdfpagesattr:n
- {
-  \__uftag_tex_global:D \__uftag_tex_pdfpagesattr:D { #1 }
- }
-
-\cs_new:Nn \__uftag_gadd_pdfpagesattr:n
- {
-  \exp_args:No \__uftag_gset_pdfpagesattr:n { \__uftag_tex_the:D \__uftag_tex_pdfpagesattr:D #1 }
- }
-
-% pdfpageattr for one page
-% I must avoid to overwrite other entries,
-% And I must avoid to add more and more /StructParens
-% do we need an immediate version??
-\cs_new:Nn \__uftag_gset_pdfpageattr:n
- {
-  \__uftag_tex_global:D \__uftag_tex_pdfpageattr:D  { #1 }
- }
-
-\cs_new:Nn \__uftag_gadd_pdfpageattr:n
- {
-   \exp_args:No \__uftag_gset_pdfpageattr:n { \__uftag_tex_the:D \__uftag_tex_pdfpageattr:D #1}
- }
-
-\cs_new:Nn \__uftag_get_pdfpageattr:N
- {
-  \tl_set:No #1 { \__uftag_tex_the:D \__uftag_tex_pdfpageattr:D }
- }
-
-
-% These commands are only aliases for pdflatex but are defined differently with luatex
-% to get also lua tables.
-\cs_set_eq:NN \__uftag_prop_new:N     \prop_new:N
-
-\cs_set_eq:NN \__uftag_seq_new:N      \seq_new:N
-
-\cs_set_eq:NN \__uftag_prop_gput:Nnn  \prop_gput:Nnn
-
-\cs_set_eq:NN \__uftag_seq_gput_right:Nn \seq_gput_right:Nn
-
-\cs_set_eq:NN \__uftag_seq_item:cn    \seq_item:cn
-
-\cs_set_eq:NN \__uftag_prop_item:cn   \prop_item:cn
-
-\cs_set_eq:NN \__uftag_seq_show:N     \seq_show:N
-
-\cs_set_eq:NN \__uftag_prop_show:N    \prop_show:N
-
-
-
-\endinput
+%% 
+%%
+%% End of file `tagpdf-pdftex.def'.

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-roles-code.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-roles-code.sty	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-roles-code.sty	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,126 +1,142 @@
-\ProvidesExplPackage {tagpdf-roles-code} {2019/07/02} {0.61}
+%%
+%% This is file `tagpdf-roles-code.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tagpdf-roles.dtx  (with options: `roles')
+%% 
+%% Copyright (C) 2019 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-roles.dtx
+\ProvidesExplPackage {tagpdf-roles-code} {2021/02/23} {0.80}
  {part of tagpdf - code related to roles and structure names}
 
-\__uftag_seq_new:N     \g__uftag_role_tags_seq  %to get names from numbers
-\__uftag_prop_new:N    \g__uftag_role_tags_prop %to get numbers from names
+\__tag_seq_new:N     \g__tag_role_tags_seq  %to get names from numbers
+\__tag_prop_new:N    \g__tag_role_tags_prop %to get numbers from names
 
-%The list of standard adobe tags.
-\clist_const:Nn \c__uftag_role_sttags_clist
- {%possible root elements
-  Document,   %A complete document. This is the root element of any structure tree containing
-              %multiple parts or multiple articles.
-  Part,       %A large-scale division of a document.
-  Art,        %A relatively self-contained body of text constituting a single narrative or exposition
-  %subelements
-  Sect,       %A container for grouping related content elements.
-  Div,        %A generic block-level element or group of elements
-  BlockQuote, %A portion of text consisting of one or more paragraphs attributed to someone other
-              %than the author of the  surrounding text.
-  Caption,    %A brief portion of text describing a table or figure.
-  TOC,        %A list made up of table of contents item entries (structure tag TOCI; see below)
-              %and/or other nested table of contents entries
-  TOCI,       %An individual member of a table of contents. This entry's children can be any of
-              %the following structure  tags:
-              %Lbl,Reference,NonStruct,P,TOC
-  Index,
-  NonStruct,  %probably not needed
-  H,
-  H1,
-  H2,
-  H3,
-  H4,
-  H5,
-  H6,
-  P,
-  L,           %list
-  LI,          %list item (around label and list item body)
-  Lbl,         %list label
-  LBody,       %list item body
-  Table,
-  TR,          %table row
-  TH,          %table header cell
-  TD,          %table data cell
-  THead,       %table header (n rows)
-  TBody,       %table rows
-  TFoot,       %table footer
-  Span,        %generic inline marker
-  Quote,       %inline quote
-  Note,        % footnote, endnote. Lbl can be child
-  Reference,   % A citation to content elsewhere in the document.
-  BibEntry,    %bibentry
-  Code,        %
-  Link,        %
-  Annot,
-  Figure,
-  Formula,
-  Form,
-  Artifact
- }
+\clist_const:Nn \c__tag_role_sttags_clist
+  {%possible root elements
+    Document,   %A complete document. This is the root element of any structure tree containing
+                %multiple parts or multiple articles.
+    Part,       %A large-scale division of a document.
+    Art,        %A relatively self-contained body of text constituting a single narrative or exposition
+    %subelements
+    Sect,       %A container for grouping related content elements.
+    Div,        %A generic block-level element or group of elements
+    BlockQuote, %A portion of text consisting of one or more paragraphs attributed to someone other
+                %than the author of the  surrounding text.
+    Caption,    %A brief portion of text describing a table or figure.
+    TOC,        %A list made up of table of contents item entries (structure tag TOCI; see below)
+                %and/or other nested table of contents entries
+    TOCI,       %An individual member of a table of contents. This entry's children can be any of
+                %the following structure  tags:
+                %Lbl,Reference,NonStruct,P,TOC
+    Index,
+    NonStruct,  %probably not needed
+    H,
+    H1,
+    H2,
+    H3,
+    H4,
+    H5,
+    H6,
+    P,
+    L,           %list
+    LI,          %list item (around label and list item body)
+    Lbl,         %list label
+    LBody,       %list item body
+    Table,
+    TR,          %table row
+    TH,          %table header cell
+    TD,          %table data cell
+    THead,       %table header (n rows)
+    TBody,       %table rows
+    TFoot,       %table footer
+    Span,        %generic inline marker
+    Quote,       %inline quote
+    Note,        % footnote, endnote. Lbl can be child
+    Reference,   % A citation to content elsewhere in the document.
+    BibEntry,    %bibentry
+    Code,        %
+    Link,        %
+    Annot,
+    Figure,
+    Formula,
+    Form,
+    Artifact
+  }
 
-% get tag name from number: \seq_item:Nn \g__uftag_role_tags_seq { n }
-%\seq_gset_from_clist:NN \g__uftag_role_tags_seq \c__uftag_role_tags_clist
 
-\clist_map_inline:Nn \c__uftag_role_sttags_clist
- {
-  \__uftag_seq_gput_right:Nn \g__uftag_role_tags_seq { #1 }
- }
+\clist_map_inline:Nn \c__tag_role_sttags_clist
+  {
+    \__tag_seq_gput_right:Nn \g__tag_role_tags_seq { #1 }
+  }
 
+\int_step_inline:nnnn { 1 }{ 1 }{ \seq_count:N \g__tag_role_tags_seq }
+  {
+    \__tag_prop_gput:Nxn \g__tag_role_tags_prop
+      {
+        \seq_item:Nn \g__tag_role_tags_seq  { #1 }
+      }
+      { #1 }
+  }
 
-% get tag number from name: \prop_item:Nn \g__uftag_role_tags_prop { name }
-\int_step_inline:nnnn { 1 }{ 1 }{ \seq_count:N \g__uftag_role_tags_seq }
- {
-  \__uftag_prop_gput:Nxn \g__uftag_role_tags_prop
-   {
-    \seq_item:Nn \g__uftag_role_tags_seq  { #1 }
-   }
-   { #1 }
- }
+\cs_new:Nn \__tag_role_get_tag_from_index:nn
+  {
+    \__tag_seq_item:cn { #1_seq } { #2 }
+  }
 
-\cs_new:Nn \__uftag_role_get_tag_from_index:nn
- {
-  \__uftag_seq_item:cn { #1_seq } { #2 }
- }
+\cs_new:Nn \__tag_role_get_index_from_tag:nn
+  {
+    \__tag_prop_item:cn { #1_prop } { #2 }
+  }
 
-\cs_new:Nn \__uftag_role_get_index_from_tag:nn
- {
-  \__uftag_prop_item:cn { #1_prop } { #2 }
- }
 
-% new tags and the rolemap
+\__tag_prop_new:N \g__tag_role_rolemap_prop
 
-\__uftag_prop_new:N \g__uftag_role_rolemap_prop
+\cs_new_protected:Nn \__tag_role_add_tag:nn %new name, reference to old
+  {
+    \__tag_seq_gput_right:Nn \g__tag_role_tags_seq { #1 }
+    \__tag_prop_gput:Nnx \g__tag_role_tags_prop    { #1 }
+      {
+        \seq_count:N \g__tag_role_tags_seq
+      }
+    \__tag_check_add_tag_role:nn {#1}{#2}
+    \tl_if_empty:nF { #2 }
+      {
+        \__tag_prop_gput:Nnn \g__tag_role_rolemap_prop
+          { #1 } { #2 }
+      }
+  }
 
-\cs_new:Nn \__uftag_role_add_tag:nn %new name, reference to old
- {
-  \__uftag_seq_gput_right:Nn \g__uftag_role_tags_seq { #1 }
-  \__uftag_prop_gput:Nnx \g__uftag_role_tags_prop    { #1 }
-   {
-    \seq_count:N \g__uftag_role_tags_seq
-   }
-  \__uftag_check_add_tag_role:nn {#1}{#2}
-  \tl_if_empty:nF { #2 }
-   {
-    \__uftag_prop_gput:Nnn \g__uftag_role_rolemap_prop
-     { #1 } { #2 }
-   }
- }
+\cs_generate_variant:Nn \__tag_role_add_tag:nn {xx}
 
-\cs_generate_variant:Nn \__uftag_role_add_tag:nn {xx}
-
-\keys_define:nn { uftag / setup }
- {
-  add-new-tag .code:n =
-   {
-    \seq_set_split:Nnn \l_tmpa_seq { / } {#1/}
-    \__uftag_role_add_tag:xx
+\keys_define:nn { __tag / setup }
+  {
+    add-new-tag .code:n =
      {
-      \seq_item:Nn \l_tmpa_seq {1}
+       \seq_set_split:Nnn \l_tmpa_seq { / } {#1/}
+       \__tag_role_add_tag:xx
+         {
+           \seq_item:Nn \l_tmpa_seq {1}
+         }
+         {
+           \seq_item:Nn \l_tmpa_seq {2}
+         }
      }
-     {
-      \seq_item:Nn \l_tmpa_seq {2}
-     }
-   }
- }
+  }
 
-
-\endinput
+%% 
+%%
+%% End of file `tagpdf-roles-code.sty'.

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-space-code.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-space-code.sty	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-space-code.sty	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,45 +1,79 @@
-\ProvidesExplPackage {tagpdf-space-code} {2019/07/02} {0.61}
+%%
+%% This is file `tagpdf-space-code.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tagpdf-space.dtx  (with options: `space')
+%% 
+%% Copyright (C) 2019 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-space.dtx
+\ProvidesExplPackage {tagpdf-space-code} {2021/02/23} {0.80}
  {part of tagpdf - code related to real space chars}
-% luatex uses an attribute (declared in the driver file) and some luacode in tagpdf.lua
-% perhaps I will split the code by engine in the future
 
 \sys_if_engine_pdftex:T
-{
- \pdfglyphtounicode{space}{0020}
- \keys_define:nn { uftag / setup }
   {
-    interwordspace .choices:nn = { true, on }  { \pdfinterwordspaceon },
-    interwordspace .choices:nn = { false, off }{ \pdfinterwordspaceon },
-    show-spaces .bool_set:N = \l__uftag_showspaces_bool
+    \pdfglyphtounicode{space}{0020}
+    \keys_define:nn { __tag / setup }
+      {
+        interwordspace .choices:nn = { true, on }  { \pdfinterwordspaceon },
+        interwordspace .choices:nn = { false, off }{ \pdfinterwordspaceon },
+        show-spaces .bool_set:N = \l__tag_showspaces_bool
+      }
   }
 
-}
-
-
 \sys_if_engine_luatex:T
-{
- \keys_define:nn { uftag / setup }
   {
-    interwordspace .choices:nn = { true, on }
-                                 { \directlua{uftag.func.markspaceon()} },
+    \keys_define:nn { __tag / setup }
+      {
+        interwordspace .choices:nn =
+                                 { true, on }
+                                 { \directlua{ltx.__tag.func.markspaceon()} },
+        interwordspace .choices:nn =
+                                 { false, off }
+                                 {\directlua{ltx.__tag.func.markspaceoff()} },
+        show-spaces      .choice:,
+        show-spaces  / true  .code:n =
+                                 {\directlua{ltx.__tag.trace.showspaces=true}},
+        show-spaces  / false .code:n =
+                                 {\directlua{ltx.__tag.trace.showspaces=nil}},
+        show-spaces .default:n = true
+      }
 
-    interwordspace .choices:nn = { false, off }
-                                 {\directlua{uftag.func.markspaceoff()} },
-    show-spaces      .choice:,
-    show-spaces  / true  .code:n = {\directlua{uftag.trace.showspaces=true}},
-    show-spaces  / false .code:n = {\directlua{uftag.trace.showspaces=nil}},
-    show-spaces .default:n = true
+    \cs_new_protected:Nn \__tag_fakespace:
+      {
+        \group_begin:
+        \setattribute\g__tag_interwordspace_attr{1}
+        \setattribute\g__tag_interwordfont_attr
+          {
+            \directlua{tex.print(\the\catcodetable at latex, font.current())}
+          }
+        \skip_horizontal:n{\c_zero_skip}
+        \group_end:
+      }
   }
- \cs_new_protected:Nn \__uftag_fakespace:
+
+\sys_if_engine_xetex:T
   {
-   \group_begin:
-    \setattribute\g__uftag_interwordspace_attr{1}
-    \setattribute\g__uftag_interwordfont_attr{\directlua{tex.print(\the\catcodetable at latex, font.current())}}
-    \skip_horizontal:n{\c_zero_skip}
-   \group_end:
+    \keys_define:nn { __tag / setup }
+      {
+        interwordspace .choices:nn = { true, on }  { \msg_warning:nnn {tag}{sys-no-interwordspace}{xetex}  },
+        interwordspace .choices:nn = { false, off }{ \msg_warning:nnn {tag}{sys-no-interwordspace}{xetex}  },
+        show-spaces .bool_set:N = \l__tag_showspaces_bool
+      }
   }
-}
 
-
-
-\endinput
+%% 
+%%
+%% End of file `tagpdf-space-code.sty'.

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-struct-code.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-struct-code.sty	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-struct-code.sty	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,523 +1,623 @@
-\ProvidesExplPackage {tagpdf-struct-code} {2019/07/02} {0.61}
+%%
+%% This is file `tagpdf-struct-code.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tagpdf-struct.dtx  (with options: `struct')
+%% 
+%% Copyright (C) 2019 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-struct.dtx
+\ProvidesExplPackage {tagpdf-struct-code} {2021/02/23} {0.80}
  {part of tagpdf - code related to storing structure}
 
-% I will use a latex counter for the structure count
-% to have a chance to avoid double structures in align etc
 
-\newcounter  { g__uftag_struct_abs_int }
-\int_gzero:N \c at g__uftag_struct_abs_int
+\newcounter  { g__tag_struct_abs_int }
+\int_gzero:N \c at g__tag_struct_abs_int
 
 
-\zref at newprop {tagstruct} [0] { \int_use:N \c at g__uftag_struct_abs_int }
-\zref at newlist {uftagzrlstruct}
-\zref at addprop {uftagzrlstruct}{tagstruct}
 
-% a sequence stores structnum -> the obj numbers
-% to allow easy mapping over the structures
+\__tag_seq_new:N  \g__tag_struct_objR_seq
 
-\__uftag_seq_new:N  \g__uftag_struct_objR_seq
+\seq_new:N    \g__tag_struct_stack_seq
+\seq_gpush:Nn \g__tag_struct_stack_seq {0}
 
-% a sequence for the structure stack. When a sequence is opened it's number is put on the stack.
-\seq_new:N    \g__uftag_struct_stack_seq
-\seq_gpush:Nn \g__uftag_struct_stack_seq {0}
+\tl_new:N     \l__tag_struct_stack_parent_tmp_tl
+\tl_new:N     \g__tag_struct_stack_current_tl
 
-%this variables will hold the top entry and the parent on the stack
-\tl_new:N     \l__uftag_struct_stack_parent_tmp_tl
-\tl_new:N     \g__uftag_struct_stack_current_tl
 
-% I need at least one structure: the StructTreeRoot
-% normally it should have only one kid, e.g. the document element.
 
-% The data of the StructTreeRoot and the StructElem are in properties:
-% \g__uftag_struct_0_prop for the root
-% \g__uftag_struct_N_prop, N >=1
-% they have all the keys
-% objnum    - number,
-% Type      - StructTreeRoot or StructElem
-% num - number (identical to the num in the name, or 0 for the root)
-% and the keys from the two following lists
-% (the root has a special set of properties).
-% the values of the prop should be already escaped properly
-% when the entries are created (title,lange,alt,E,actualtext)
+\seq_const_from_clist:Nn \c__tag_struct_StructTreeRoot_entries_seq
+  {%p. 857/858
+    Type,              % always /StructTreeRoot
+    K,                 % kid, dictionary or array of dictionaries
+    IDTree,            % currently unused
+    ParentTree,        % required,obj ref to the parent tree
+    ParentTreeNextKey, %optional
+    RoleMap,
+    ClassMap
+  }
 
+\seq_const_from_clist:Nn \c__tag_struct_StructElem_entries_seq
+  {%p 858 f
+    Type,              %always /StructElem
+    S,                 %tag/type
+    P,                 %parent
+    ID,                %optional
+    Ref,               %optional, pdf 2.0 Use?
+    Pg,                %obj num of starting page, optional
+    K,                 %kids
+    A,                 %attributes, probably unused
+    C,                 %class ""
+    %R,
+    T,                 %title, value in () or <>
+    Lang,              %language
+    Alt,               % value in () or <>
+    E,                 %abreviation
+    ActualText,
+    AF,                 %pdf 2.0, array of dict, associated files
+    NS,                 %pdf 2.0, dict, namespace
+    PhoneticAlphabet,   %pdf 2.0
+    Phoneme             %pdf 2.0
+  }
 
-\seq_const_from_clist:Nn \c__uftag_struct_StructTreeRoot_entries_seq
- {%p. 857/858
-  Type,              % always /StructTreeRoot
-  K,                 % kid, dictionary or array of dictionaries
-  IDTree,            % currently unused
-  ParentTree,        % required,obj ref to the parent tree
-  ParentTreeNextKey, %optional
-  RoleMap,
-  ClassMap
- }
 
-\seq_const_from_clist:Nn \c__uftag_struct_StructElem_entries_seq
- {%p 858 f
-  Type,              %always /StructElem
-  S,                 %tag/type
-  P,                 %parent
-  ID,                %optional
-  Pg,                %obj num of starting page, optional
-  K,                 %kids
-  A,                 %attributes, probably unused
-  C,                 %class ""
-  %R,
-  T,                 %title, value in () or <>
-  Lang,              %language
-  Alt,               % value in () or <>
-  E,                 %abreviation
-  ActualText
+\cs_new:Nn \__tag_struct_output_prop_aux:nn %#1 num, #2 key
+  {
+    \prop_if_in:cnT
+      { g__tag_struct_#1_prop }
+      { #2 }
+      {
+        \c_space_tl/#2~ \prop_item:cn{ g__tag_struct_#1_prop } { #2 }
+      }
   }
 
-% I need an output handler for each prop, to get expandable output
-% see https://tex.stackexchange.com/questions/424208/expandable-version-of-a-expl3-command/424213#424213
+\cs_new:Nn \__tag_new_output_prop_handler:n
+  {
+    \cs_new:cn { __tag_struct_output_prop_#1:n }
+      {
+        \__tag_struct_output_prop_aux:nn {#1}{##1}
+      }
+  }
 
-\cs_new:Nn \__uftag_struct_output_prop_aux:nn %#1 num, #2 key
- {
-  \prop_if_in:cnT
-   { g__uftag_struct_#1_prop }
-   { #2 }
-   {
-     \c_space_tl/#2~ \prop_item:cn{ g__uftag_struct_#1_prop } { #2 }
-   }
- }
+\__tag_prop_new:c { g__tag_struct_0_prop }
+\__tag_new_output_prop_handler:n {0}
+\tl_gset:Nn \g__tag_struct_stack_current_tl {0}
 
-\cs_new:Nn \__uftag_new_output_prop_handler:n
- {
-  \cs_new:cn { __uftag_struct_output_prop_#1:n }
-   {
-    \__uftag_struct_output_prop_aux:nn {#1}{##1}
-   }
- }
+\__tag_seq_new:c  { g__tag_struct_kids_0_seq }
 
 
-% the first one, the StructTreeRoot is special, so
-% created manually:
-\__uftag_prop_new:c { g__uftag_struct_0_prop }
-\__uftag_new_output_prop_handler:n {0}
-\tl_gset:Nn \g__uftag_struct_stack_current_tl {0}
+\__tag_prop_gput:cno
+  { g__tag_struct_0_prop }
+  { objref}
+  { \pdf_object_ref:n { c__tag_struct_0_obj } }
 
-\__uftag_seq_new:c  { g__uftag_struct_kids_0_seq}
+\__tag_prop_gput:cno
+  { g__tag_struct_0_prop }
+  { Type }
+  { /StructTreeRoot }
 
-\__uftag_prop_gput:cno
- { g__uftag_struct_0_prop }
- { objnum}
- { \c_uftag_tree_obj_structtreeroot_tl }
+\__tag_prop_gput:cnx
+  { g__tag_struct_0_prop }
+  { ParentTree }
+  { \pdf_object_ref:n { c__tag_tree_parenttree_obj } }
 
-\__uftag_prop_gput:cno
- { g__uftag_struct_0_prop }
- { Type }
- { /StructTreeRoot }
+\__tag_prop_gput:cnx
+  { g__tag_struct_0_prop }
+  { RoleMap }
+  { \pdf_object_ref:n { c__tag_tree_rolemap_obj } }
 
-% the constants are defined in the tree code.
-\__uftag_prop_gput:cnx
- { g__uftag_struct_0_prop }
- { ParentTree }
- { \c__uftag_tree_obj_parenttree_tl\c_space_tl 0\c_space_tl R }
+\__tag_prop_gput:cno
+  { g__tag_struct_0_prop }
+  { entries }
+  { StructTreeRoot }
 
-\__uftag_prop_gput:cnx
- { g__uftag_struct_0_prop }
- { RoleMap }
- { \c__uftag_tree_obj_rolemap_tl\c_space_tl 0\c_space_tl R }
+\__tag_prop_gput:cno
+  { g__tag_struct_0_prop }
+  { num }
+  { 0 }
 
-\__uftag_prop_gput:cno
- { g__uftag_struct_0_prop }
- { entries }
- { StructTreeRoot }
 
-\__uftag_prop_gput:cno
- { g__uftag_struct_0_prop }
- { num }
- { 0 }
+\cs_new:Nn \__tag_struct_kid_mc_gput_right:nn %#1 structure num, #2 MCID absnum%
+  {
+    %\__tag_store_pdfpageref:Nn \l_tmpa_tl { \__tag_ref_value:enn{mcid-#2}{tagabspage}{1} }
+    \__tag_seq_gput_right:cx
+      { g__tag_struct_kids_#1_seq }
+      {
+        <<
+        /Type \c_space_tl /MCR \c_space_tl
+        /Pg %\c_space_tl \l_tmpa_tl \c_space_tl 0 \c_space_tl R \c_space_tl
+          \c_space_tl
+          \pdf_pageobject_ref:n { \__tag_ref_value:enn{mcid-#2}{tagabspage}{1} }
+        /MCID \c_space_tl \__tag_ref_value:enn{mcid-#2}{tagmcid}{1}
+        >>
+      }
+  }
 
-% commands to store the kids
-% I don't compare the page objects number yet, but always add the /Pg key, perhaps later
-
-\cs_new:Nn \__uftag_struct_kid_mc_gput_right:nn %#1 structure num, #2 MCID absnum%
- {
-  \__uftag_store_pdfpageref:Nn \l_tmpa_tl { \zref at extractdefault{mcid-#2}{tagabspage}{1} }
-  \__uftag_seq_gput_right:cx
-   { g__uftag_struct_kids_#1_seq }
-   { <<
-     /Type\c_space_tl/MCR\c_space_tl
-     /Pg\c_space_tl\l_tmpa_tl\c_space_tl0\c_space_tl R\c_space_tl
-     /MCID\c_space_tl\zref at extractdefault{mcid-#2}{tagmcid}{1}
-    >>
-   }
+\cs_new:Nn\__tag_struct_kid_struct_gput_right:nn %#1 num of parent struct, #2 kid struct
+  {
+    \__tag_seq_gput_right:cx
+      { g__tag_struct_kids_#1_seq }
+      {
+        \prop_item:cn
+          { g__tag_struct_#2_prop }
+          { objref }
+      }
  }
 
-\cs_new:Nn\__uftag_struct_kid_struct_gput_right:nn %#1 num of parent struct, #2 kid struct
- {
-  \__uftag_seq_gput_right:cx
-  { g__uftag_struct_kids_#1_seq }
+\cs_new:Nn\__tag_struct_kid_link_gput_right:nn %#1 num of parent struct, #2 obj reference
   {
-   \prop_item:cn
-    { g__uftag_struct_#2_prop }
-    { objnum }
-   \c_space_tl 0 \c_space_tl R
+    \pdf_object_unnamed_write:nx
+      { dict }
+      {
+        /Type \c_space_tl /OBJR \c_space_tl
+        /Obj~#2
+      }
+    \__tag_seq_gput_right:cx
+      { g__tag_struct_kids_#1_seq }
+      {
+        \pdf_object_ref_last:
+      }
   }
- }
 
-\cs_new:Nn\__uftag_struct_kid_link_gput_right:nn %#1 num of parent struct, #2 obj number of link
- {
-  \__uftag_pdfobj:Nn \l__uftag_tmpa_tl
+\cs_generate_variant:Nn\__tag_struct_kid_link_gput_right:nn { nx }
+
+\cs_new:Nn\__tag_struct_exchange_kid_command:N %N= seq
   {
-    <<
-     /Type \c_space_tl /OBJR \c_space_tl
-     /Obj  \c_space_tl #2 \c_space_tl 0 \c_space_tl R
-   >>
+    \seq_gpop_left:NN #1 \l_tmpa_tl
+    \regex_replace_once:nnN
+      { \c{\__tag_mc_insert_mcid_kids:n} }
+      { \c{\__tag_mc_insert_mcid_single_kids:n} }
+      \l_tmpa_tl
+   \seq_gput_left:NV #1 \l_tmpa_tl
   }
-  \__uftag_seq_gput_right:cx
-   { g__uftag_struct_kids_#1_seq }
-   {
-    \l__uftag_tmpa_tl \c_space_tl 0 \c_space_tl R
-   }
- }
 
-\cs_generate_variant:Nn\__uftag_struct_kid_link_gput_right:nn { nx}
+\cs_generate_variant:Nn\__tag_struct_exchange_kid_command:N { c }
 
-\cs_new:Nn\__uftag_struct_exchange_kid_command:N %N= seq
- {
-  \seq_gpop_left:NN #1 \l_tmpa_tl
-  \regex_replace_once:nnN
-   {\c{\__uftag_mc_insert_mcid_kids:n}}
-   {\c{\__uftag_mc_insert_mcid_single_kids:n}}
-   \l_tmpa_tl
-  \seq_gput_left:NV #1 \l_tmpa_tl
- }
-\cs_generate_variant:Nn\__uftag_struct_exchange_kid_command:N { c }
+\cs_new:Nn \__tag_struct_fill_kid_key:n %#1 is the struct num
+  {
+    \int_case:nnF
+      {
+        \seq_count:c
+          {
+            g__tag_struct_kids_\prop_item:cn{ g__tag_struct_#1_prop }{num}_seq
+          }
+      }
+      {
+        { 0 }
+         { } %no kids, do nothing
+        { 1 } % 1 kid, insert
+         {
+           % in this case we need a special command in
+           %luamode to get the array right. See issue #13
+           \bool_if:NT\g__tag_mode_lua_bool
+             {
+               \__tag_struct_exchange_kid_command:c
+                 {g__tag_struct_kids_\prop_item:cn{ g__tag_struct_#1_prop }{num}_seq}
+             }
+           \__tag_prop_gput:cnx { g__tag_struct_#1_prop } {K}
+             {
+               \seq_item:cn
+                 {
+                   g__tag_struct_kids_\prop_item:cn{ g__tag_struct_#1_prop }{num}_seq
+                 }
+                 {1}
+             }
+         } %
+      }
+      { %many kids, use an array
+        \__tag_prop_gput:cnx { g__tag_struct_#1_prop } {K}
+          {
+            [
+              \seq_use:cn
+                {
+                  g__tag_struct_kids_\prop_item:cn{ g__tag_struct_#1_prop }{num}_seq
+                }
+                {
+                  \c_space_tl
+                }
+            ]
+          }
+      }
+  }
 
-\cs_new:Nn \__uftag_struct_fill_kid_key:n %#1 is the struct num
- {
-  \int_case:nnF
+
+\tl_new:N \l__tag_struct_dict_content_tl
+
+\cs_new:Nn \__tag_struct_get_dict_content:n
   {
-   \seq_count:c
-    {
-     g__uftag_struct_kids_\prop_item:cn{ g__uftag_struct_#1_prop }{num}_seq
-    }
+    %\tl_set:Nn \l__tag_struct_dict_content_tl {<<}
+    \tl_clear:N \l__tag_struct_dict_content_tl
+    \seq_map_inline:cn
+      {
+        c__tag_struct_\prop_item:cn{ g__tag_struct_#1_prop }{entries}_entries_seq
+      }
+      {
+        \tl_put_right:Nx
+          \l__tag_struct_dict_content_tl
+          {
+             \prop_if_in:cnT
+               { g__tag_struct_#1_prop }
+               { ##1 }
+               {
+                 \c_space_tl/##1~\prop_item:cn{ g__tag_struct_#1_prop } { ##1 }
+               }
+          }
+      }
+    %\tl_put_right:Nn \l__tag_struct_dict_content_tl { >> }
   }
+
+\cs_new:Nn \__tag_struct_write_obj:n
   {
-   { 0 }
-    { } %no kids, do nothing
-   { 1 } % 1 kid, insert
-    {
-     % in this case we in luamode need a special command in luamode to get the array right. See issue #13
-     \bool_if:NT\g__uftag_mode_lua_bool
+    \prop_if_in:cnTF
+      { g__tag_struct_#1_prop }
+      { objref }
       {
-       \__uftag_struct_exchange_kid_command:c
-        {g__uftag_struct_kids_\prop_item:cn{ g__uftag_struct_#1_prop }{num}_seq}
+        \__tag_struct_fill_kid_key:n { #1 }
+        %\prop_show:c { g__tag_struct_#1_prop }
+        \__tag_struct_get_dict_content:n { #1 }
+        \exp_args:Nx
+          \pdf_object_write:nx
+            { c__tag_struct_#1_obj }
+            {
+              \l__tag_struct_dict_content_tl
+            }
       }
-     \__uftag_prop_gput:cnx { g__uftag_struct_#1_prop } {K}
       {
-       \seq_item:cn
-        {
-         g__uftag_struct_kids_\prop_item:cn{ g__uftag_struct_#1_prop }{num}_seq
-        }{1}
+        \msg_error:nnn { tag } { struct-no-objnum } { #1}
       }
-    } %
   }
-  { %many kids, use an array
-   \__uftag_prop_gput:cnx { g__uftag_struct_#1_prop } {K}
-    {
-     [
-      \seq_use:cn
-       {
-        g__uftag_struct_kids_\prop_item:cn{ g__uftag_struct_#1_prop }{num}_seq
-       }
-       {
-        \c_space_tl
-       }
-     ]
-    }
+
+\keys_define:nn { __tag / struct }
+  {
+    label .tl_set:N      = \l__tag_struct_key_label_tl,
+    stash .bool_set:N    = \l__tag_struct_elem_stash_bool,
+    tag   .code:n        = % S property
+      {%%????????? \pdfescapename??
+        \tl_set:Nx \l__tag_tmpa_tl { #1 }
+        \bool_if:NT \g__tag_check_tags_bool
+          {
+            \__tag_check_structure_tag:N \l__tag_tmpa_tl
+          }
+       \__tag_prop_gput:cnx
+         { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
+         { S }
+         { /\exp_not:V\l__tag_tmpa_tl }
+      },
+    title .code:n        = % T property
+      {
+        \str_set_convert:Nnon
+          \l__tag_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \__tag_prop_gput:cnx
+          { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
+          { T }
+          { <\l__tag_tmpa_str> }
+      },
+    title-o .code:n        = % T property
+      {
+        \str_set_convert:Nnon
+          \l__tag_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \__tag_prop_gput:cnx
+          { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
+          { T }
+          { <\l__tag_tmpa_str> }
+      },
+    alttext .code:n      = % Alt property
+      {
+        \str_set_convert:Nnon
+          \l__tag_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \__tag_prop_gput:cnx
+          { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
+          { Alt }
+          { <\l__tag_tmpa_str> }
+      },
+    alttext-o .code:n      = % Alt property
+      {
+        \str_set_convert:Noon
+          \l__tag_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \__tag_prop_gput:cnx
+          { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
+          { Alt }
+          { <\l__tag_tmpa_str> }
+      },
+    actualtext .code:n  = % ActualText property
+      {
+        \str_set_convert:Nnon
+          \l__tag_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \__tag_prop_gput:cnx
+          { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
+          { ActualText }
+          { <\l__tag_tmpa_str>}
+      },
+    actualtext-o .code:n  = % ActualText property
+      {
+        \str_set_convert:Noon
+          \l__tag_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \__tag_prop_gput:cnx
+          { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
+          { ActualText }
+          { <\l__tag_tmpa_str>}
+      },
+    lang .code:n        = % Lang property
+      {
+        \__tag_prop_gput:cnx
+          { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
+          { Lang }
+          { (#1) }
+      },
+    ref .code:n        = % Lang property
+      {
+        \tl_clear:N\l__tag_tmpa_tl
+        \clist_map_inline:nn {#1}
+          {
+            \tl_put_right:Nx \l__tag_tmpa_tl
+              {~\ref_value:nn{tagpdfstruct-##1}{tagstructobj} }
+          }
+        \__tag_prop_gput:cnx
+          { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
+          { Ref }
+          { [\l__tag_tmpa_tl] }
+      },
+    E .code:n        = % E property
+      {
+        \str_set_convert:Nnon
+          \l__tag_tmpa_str
+          { #1 }
+          { default }
+          { utf16/hex }
+        \__tag_prop_gput:cnx
+          { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
+          { E }
+          { <\l__tag_tmpa_str> }
+      },
   }
- }
 
-% this command can be used for roots and structure elements
-% #1 is a num
+\keys_define:nn { __tag / struct }
+ {
+    AF .code:n        = % T property
+      {
+        \pdf_object_if_exist:nTF {#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_new:N \l_uftag_struct_dict_content_tl
-
-\cs_new:Nn \__uftag_struct_get_dict_content:n
- {
-  \tl_set:Nn \l_uftag_struct_dict_content_tl {<<}
-  \seq_map_inline:cn
-   {
-    c__uftag_struct_\prop_item:cn{ g__uftag_struct_#1_prop }{entries}_entries_seq
-   }
-   {
-    \tl_put_right:Nx
-    \l_uftag_struct_dict_content_tl
-    {
-     \prop_if_in:cnT
-     { g__uftag_struct_#1_prop }
-     { ##1 }
+          }
+      },
+   ,AFinline .code:n =
      {
-      \c_space_tl/##1~\prop_item:cn{ g__uftag_struct_#1_prop } { ##1 }
+       \group_begin:
+       \exp_args:Ne
+       \pdf_object_if_exist:nF {__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 } }
+       \group_end:
      }
-    }
-   }
-  \tl_put_right:Nn \l_uftag_struct_dict_content_tl { >> }
- }
-
-
-% #1 is the struct num
-\cs_new:Nn \__uftag_struct_write_obj:n
- {
-  \prop_if_in:cnTF
-   { g__uftag_struct_#1_prop }
-   { objnum }
-   {
-    \__uftag_struct_fill_kid_key:n { #1 }
-    %\prop_show:c { g__uftag_struct_#1_prop }
-    \__uftag_struct_get_dict_content:n { #1 }
-    \__uftag_pdfuseobjnum:xx
-     { \prop_item:cn { g__uftag_struct_#1_prop } {objnum} }
+   ,AFinline-o .code:n =
      {
-      \l_uftag_struct_dict_content_tl
+       \group_begin:
+       \exp_args:Ne
+       \pdf_object_if_exist:nF {__tag/fileobj\int_use:N\c at g__tag_struct_abs_int}
+        {
+          \pdffile_embed_stream:oxx
+            {#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 } }
+       \group_end:
      }
-   }
-   {
-   \msg_error:nnn {uftag} { struct-no-objnum } { #1}
-   }
  }
 
-% keys for the user commands
-% should I pass the values (e.g. the tag) through an escape command?
-\keys_define:nn { uftag / struct }
- {
-  label .tl_set:N      = \l__uftag_struct_key_label_tl,
-  stash .bool_set:N    = \l__uftag_struct_elem_stash_bool,
-  tag   .code:n        = % S property
-   {%%????????? \pdfescapename??
-    \tl_set:Nx \l__uftag_tmpa_tl { #1 }
-    \bool_if:NT \g__uftag_check_tags_bool
-     {
-      \__uftag_check_structure_tag:N \l__uftag_tmpa_tl
-     }
-    \__uftag_prop_gput:cnx
-     { g__uftag_struct_\int_eval:n {\c at g__uftag_struct_abs_int}_prop }
-     { S }
-     { /\exp_not:V\l__uftag_tmpa_tl }
-   },
-  title .code:n        = % T property
-   {
-    \str_set_convert:Nnon
-     \l__uftag_tmpa_str
-     { #1 }
-     { \g__uftag_inputencoding_tl }
-     { utf16/hex }
-    \__uftag_prop_gput:cnx
-     { g__uftag_struct_\int_eval:n {\c at g__uftag_struct_abs_int}_prop }
-     { T }
-     { <\l__uftag_tmpa_str> }
-   },
-  title-o .code:n        = % T property
-   {
-    \str_set_convert:Nnon
-     \l__uftag_tmpa_str
-     { #1 }
-     { \g__uftag_inputencoding_tl }
-     { utf16/hex }
-    \__uftag_prop_gput:cnx
-     { g__uftag_struct_\int_eval:n {\c at g__uftag_struct_abs_int}_prop }
-     { T }
-     { <\l__uftag_tmpa_str> }
-   },
-  alttext .code:n      = % Alt property
-   {
-    \str_set_convert:Nnon
-     \l__uftag_tmpa_str
-     { #1 }
-     { \g__uftag_inputencoding_tl }
-     { utf16/hex }
-    \__uftag_prop_gput:cnx
-     { g__uftag_struct_\int_eval:n {\c at g__uftag_struct_abs_int}_prop }
-     { Alt }
-     { <\l__uftag_tmpa_str> }
-   },
-   alttext-o .code:n      = % Alt property
-   {
-    \str_set_convert:Noon
-     \l__uftag_tmpa_str
-     { #1 }
-     { \g__uftag_inputencoding_tl }
-     { utf16/hex }
-    \__uftag_prop_gput:cnx
-     { g__uftag_struct_\int_eval:n {\c at g__uftag_struct_abs_int}_prop }
-     { Alt }
-     { <\l__uftag_tmpa_str> }
-   },
-   actualtext .code:n  = % ActualText property
-   {
-    \str_set_convert:Nnon
-    \l__uftag_tmpa_str
-    { #1 }
-    { \g__uftag_inputencoding_tl }
-    { utf16/hex }
-    \__uftag_prop_gput:cnx
-     { g__uftag_struct_\int_eval:n {\c at g__uftag_struct_abs_int}_prop }
-     { ActualText }
-     { <\l__uftag_tmpa_str>}
-   },
-   actualtext-o .code:n  = % ActualText property
-   {
-    \str_set_convert:Noon
-    \l__uftag_tmpa_str
-    { #1 }
-    { \g__uftag_inputencoding_tl }
-    { utf16/hex }
-    \__uftag_prop_gput:cnx
-     { g__uftag_struct_\int_eval:n {\c at g__uftag_struct_abs_int}_prop }
-     { ActualText }
-     { <\l__uftag_tmpa_str>}
-   },
-}
+\cs_new_protected:Nn \tag_struct_begin:n
+  {
+    \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}
+    %\__tag_pdfreserveobjnum:N \l_tmpa_tl
+    \exp_args:Ne
+      \pdf_object_new:nn
+        { c__tag_struct_\int_eval:n { \c at g__tag_struct_abs_int }_obj }
+        { dict }
+    \__tag_prop_gput:cnx
+      { g__tag_struct_\int_eval:n { \c at g__tag_struct_abs_int }_prop }
+      { objref}
+      {
+        \exp_args:Ne
+          \pdf_object_ref:n
+            {c__tag_struct_\int_eval:n { \c at g__tag_struct_abs_int }_obj}
+      }
+    \__tag_prop_gput:cnx
+      { g__tag_struct_\int_eval:n { \c at g__tag_struct_abs_int }_prop }
+      { num}
+      { \int_eval:n { \c at g__tag_struct_abs_int } }
+    \__tag_prop_gput:cno
+      { g__tag_struct_\int_eval:n { \c at g__tag_struct_abs_int }_prop }
+      { Type }
+      { /StructElem }
+    \__tag_prop_gput:cno
+      { g__tag_struct_\int_eval:n { \c at g__tag_struct_abs_int }_prop }
+      { entries }
+      { 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_tmp_tl
+      {
+        \msg_error:nn { tag } { struct-faulty-nesting }
+      }
+    \seq_gpush:NV \g__tag_struct_stack_seq        \c at g__tag_struct_abs_int
+    \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 }
+          {
+            \prop_item:cn
+              { g__tag_struct_\l__tag_struct_stack_parent_tmp_tl _prop}
+              { objref }
+          }
+        %record this structure as kid:
+        %\tl_show:N \g__tag_struct_stack_current_tl
+        %\tl_show:N \l__tag_struct_stack_parent_tmp_tl
+        \__tag_struct_kid_struct_gput_right:nn
+          { \l__tag_struct_stack_parent_tmp_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_tmp_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_tmp_tl _seq}
+    \group_end:
+  }
 
+\cs_set_eq:NN  \uftag_struct_begin:n \tag_struct_begin:n
 
-\cs_new_protected:Nn \uftag_struct_begin:n
- {
-  \group_begin:
-  \int_gincr:N \c at g__uftag_struct_abs_int
-  \__uftag_prop_new:c  { g__uftag_struct_\int_eval:n { \c at g__uftag_struct_abs_int }_prop }
-  \__uftag_new_output_prop_handler:n {\int_eval:n { \c at g__uftag_struct_abs_int }}
-  \__uftag_seq_new:c  { g__uftag_struct_kids_\int_eval:n { \c at g__uftag_struct_abs_int }_seq}
-  \__uftag_pdfreserveobjnum:N \l_tmpa_tl
-  \__uftag_prop_gput:cno
-   { g__uftag_struct_\int_eval:n { \c at g__uftag_struct_abs_int }_prop }
-   { objnum}
-   { \l_tmpa_tl }
-  \__uftag_prop_gput:cnx
-   { g__uftag_struct_\int_eval:n { \c at g__uftag_struct_abs_int }_prop }
-   { num}
-   { \int_eval:n { \c at g__uftag_struct_abs_int } }
-  \__uftag_prop_gput:cno
-   { g__uftag_struct_\int_eval:n { \c at g__uftag_struct_abs_int }_prop }
-   { Type }
-   { /StructElem }
-  \__uftag_prop_gput:cno
-   { g__uftag_struct_\int_eval:n { \c at g__uftag_struct_abs_int }_prop }
-   { entries }
-   { StructElem }
-  \keys_set:nn {uftag / struct} { #1 }
-  \__uftag_check_structure_has_tag:n { \int_eval:n {\c at g__uftag_struct_abs_int} }
-  \tl_if_empty:NF
-   {\l__uftag_struct_key_label_tl}
-   {
-     \zref at labelbylist{tagpdfstruct-\l__uftag_struct_key_label_tl}{uftagzrlstruct}
-   }
-   %get the potential parent from the stack:
-   \seq_get:NNF
-    \g__uftag_struct_stack_seq
-    \l__uftag_struct_stack_parent_tmp_tl
-    {
-     \msg_error:nn { uftag } { struct-faulty-nesting }
-    }
-   \seq_gpush:NV \g__uftag_struct_stack_seq        \c at g__uftag_struct_abs_int
-   \tl_gset:NV   \g__uftag_struct_stack_current_tl \c at g__uftag_struct_abs_int
-   %\seq_show:N   \g__uftag_struct_stack_seq
-   \bool_if:NF
-    \l__uftag_struct_elem_stash_bool
-    {%set the  parent
-     \__uftag_prop_gput:cnx
-      { g__uftag_struct_\int_eval:n {\c at g__uftag_struct_abs_int}_prop }
-      { P }
+\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
+    \seq_gpop:NNTF \g__tag_struct_stack_seq \l_tmpa_tl
       {
-       \prop_item:cn { g__uftag_struct_\l__uftag_struct_stack_parent_tmp_tl _prop} { objnum }~0~R
+        \int_compare:nNnT {\l__tag_loglevel_int} > { 0 }
+          {
+            \__tag_check_info_closing_struct:o { \g__tag_struct_stack_current_tl }
+          }
       }
-     %record this structure as kid:
-     %\tl_show:N \g__uftag_struct_stack_current_tl
-     %\tl_show:N \l__uftag_struct_stack_parent_tmp_tl
-    \__uftag_struct_kid_struct_gput_right:nn
-     { \l__uftag_struct_stack_parent_tmp_tl }
-     { \g__uftag_struct_stack_current_tl }
-     %\prop_show:c { g__uftag_struct_\g__uftag_struct_stack_current_tl _prop }
-     %\seq_show:c {g__uftag_struct_kids_\l__uftag_struct_stack_parent_tmp_tl _seq}
-    }
-    %\prop_show:c { g__uftag_struct_\g__uftag_struct_stack_current_tl _prop }
-    %\seq_show:c {g__uftag_struct_kids_\l__uftag_struct_stack_parent_tmp_tl _seq}
-  \group_end:
- }
+      { \__tag_check_no_open_struck: }
+    % get the previous one, shouldn't be empty as the root should be there
+    \seq_get:NNTF \g__tag_struct_stack_seq \l_tmpa_tl
+      {
+        \tl_gset:NV   \g__tag_struct_stack_current_tl \l_tmpa_tl
+      }
+      {
+        \__tag_check_no_open_struck:
+      }
+  }
 
-\cs_new_protected:Nn \uftag_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__uftag_struct_stack_seq
-  \seq_gpop:NNTF \g__uftag_struct_stack_seq \l_tmpa_tl
-   {
-    \int_compare:nNnT {\l__uftag_loglevel_int} > { 0 }
-     {
-      \__uftag_check_info_closing_struct:o { \g__uftag_struct_stack_current_tl }
-     }
-   }
-   { \__uftag_check_no_open_struck: }
-  % get the previous one, shouldn't be empty as the root should be there
-  \seq_get:NNTF \g__uftag_struct_stack_seq \l_tmpa_tl
-   {
-    \tl_gset:NV   \g__uftag_struct_stack_current_tl \l_tmpa_tl
-   }
-   {
-    \__uftag_check_no_open_struck:
-   }
- }
+\cs_set_eq:NN  \uftag_struct_end: \tag_struct_end:
 
-\cs_new_protected:Nn \uftag_struct_use:n %#1 is the label
- {
-  \prop_if_exist:cTF
-   { g__uftag_struct_\zref at extractdefault{tagpdfstruct-#1}{tagstruct}{unknown}_prop } %??????????
-   {
-    \__uftag_check_struct_used:n {#1}
-    %add the label structure as kid to the current structure (can be the root)
-    \__uftag_struct_kid_struct_gput_right:nn
-     { \g__uftag_struct_stack_current_tl }
-     { \zref at extractdefault{tagpdfstruct-#1}{tagstruct}{0} }
-     %add the current structure to the labeled one as parents
-    \__uftag_prop_gput:cnx
-     { g__uftag_struct_\zref at extractdefault{tagpdfstruct-#1}{tagstruct}{0}_prop }
-     { P }
-     {
-      \prop_item:cn { g__uftag_struct_\g__uftag_struct_stack_current_tl _prop} { objnum }~0~R
-     }
-   }
-   {\msg_warning:nnn{uftag}{struct-label-unknown}{#1}}
- }
+\cs_new_protected:Nn \tag_struct_use:n %#1 is the label
+  {
+    \prop_if_exist:cTF
+      { g__tag_struct_\__tag_ref_value:enn{tagpdfstruct-#1}{tagstruct}{unknown}_prop } %??????????
+      {
+        \__tag_check_struct_used:n {#1}
+        %add the label structure as kid to the current structure (can be the root)
+        \__tag_struct_kid_struct_gput_right:nn
+          { \g__tag_struct_stack_current_tl }
+          { \__tag_ref_value:enn{tagpdfstruct-#1}{tagstruct}{0} }
+        %add the current structure to the labeled one as parents
+        \__tag_prop_gput:cnx
+          { g__tag_struct_\__tag_ref_value:enn{tagpdfstruct-#1}{tagstruct}{0}_prop }
+          { P }
+          {
+            \prop_item:cn
+              { g__tag_struct_\g__tag_struct_stack_current_tl _prop}
+              { objref }
+          }
+      }
+      {
+        \msg_warning:nnn{ tag }{struct-label-unknown}{#1}
+      }
+  }
 
+\cs_set_eq:NN  \uftag_struct_use:n \tag_struct_use:n
 
 %%%% Code to tag links
 %%%% this works for url, see exp-link.pdf.
 %%%% it must be checked for other links
 
-\cs_new_protected:Nn \__uftag_struct_finish_link:
-{
- \bool_if:NT \g_uftag_active_struct_bool
- {
- %get the number of the parent link structure:
- \seq_get:NNF
-    \g__uftag_struct_stack_seq
-    \l__uftag_struct_stack_parent_tmp_tl
-    {
-     \msg_error:nn { uftag } { struct-faulty-nesting }
-    }
-  %put the obj number of link annot in the kid entry:
-  \__uftag_struct_kid_link_gput_right:nx
+\cs_new_protected:Nn \__tag_struct_finish_link:
   {
-   \l__uftag_struct_stack_parent_tmp_tl
+    \bool_if:NT \g__tag_active_struct_bool
+      {
+        %get the number of the parent link structure:
+        \seq_get:NNF
+          \g__tag_struct_stack_seq
+          \l__tag_struct_stack_parent_tmp_tl
+          {
+            \msg_error:nn { tag } { struct-faulty-nesting }
+          }
+        %put the obj number of link annot in the kid entry:
+        \__tag_struct_kid_link_gput_right:nx
+          {
+            \l__tag_struct_stack_parent_tmp_tl
+          }
+          {
+            \pdfannot_link_ref_last:
+          }
+        % add the parent obj number to the parent tree:
+        \__tag_parenttree_add_objr:nn
+          {
+            \int_use:N\c at g__tag_parenttree_obj_int
+          }
+          {
+            \prop_item:cn
+              { g__tag_struct_\l__tag_struct_stack_parent_tmp_tl _prop }
+              { objref }
+          }
+        % increase the int:
+        \stepcounter{ g__tag_parenttree_obj_int }
+      }
   }
-  {
-   \int_use:N\__uftag_pdf_lastlink:
-  }
- % add the parent obj number to the parent tree:
-  \__uftag_parenttree_add_objr:nn
-  {
-   \int_use:N\c at g__uftag_parenttree_obj_int
-  }
-  {
-   \prop_item:cn{ g__uftag_struct_\l__uftag_struct_stack_parent_tmp_tl _prop }
-   { objnum }
-  }
- % increase the int:
- \stepcounter{ g__uftag_parenttree_obj_int }
- }
-}
 
-\endinput
+
+%% 
+%%
+%% End of file `tagpdf-struct-code.sty'.

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-tree-code.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-tree-code.sty	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-tree-code.sty	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,210 +1,252 @@
-\ProvidesExplPackage {tagpdf-tree-code} {2019/07/02} {0.61}
+%%
+%% This is file `tagpdf-tree-code.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tagpdf-tree.dtx  (with options: `tree')
+%% 
+%% Copyright (C) 2019 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-tree.dtx
+\ProvidesExplPackage {tagpdf-tree-code} {2021/02/23} {0.80}
  {part of tagpdf - code related to writing trees and dictionaries to the pdf}
 
-%this does the actual finishing:
-\AtBeginDocument
- {
-  \bool_if:NT \g_uftag_active_tree_bool
-   {
-    \AfterEndDocument { \uftag_finish_structure: }
-   }
- }
+\hook_gput_code:nnn{begindocument}{tagpdf}
+  {
+    \bool_if:NT \g__tag_active_tree_bool
+      {
+        \AfterEndDocument { \tag_finish_structure: }
+      }
+  }
 
 
-% the StructTreeRoot
-% we better get the object number in any case:
-\__uftag_pdfreserveobjnum:N \l_tmpa_tl
-\tl_const:Nx \c_uftag_tree_obj_structtreeroot_tl { \l_tmpa_tl }
+\pdf_object_new:nn { c__tag_struct_0_obj }{ dict }
 
+ %need to think about the best place ...
+\hook_gput_code:nnn{begindocument}{tagpdf}
+  {
+    \bool_if:NT \g__tag_active_struct_bool
+      {
+        \pdfmanagement_add:nnx
+          { Catalog }
+          { StructTreeRoot }
+          { \pdf_object_ref:n { c__tag_struct_0_obj } }
+      }
+  }
+\cs_new_protected:Nn \__tag_tree_write_structtreeroot:
+  {
+    \__tag_struct_write_obj:n { 0 }
+  }
 
-\cs_new:Nn \__uftag_tree_write_structtreeroot:
- {
-  \__uftag_pdfcatalog:n { /StructTreeRoot~\c_uftag_tree_obj_structtreeroot_tl\c_space_tl0~R }
-  \__uftag_struct_write_obj:n { 0 }
- }
+\cs_new_protected:Nn \__tag_tree_write_structelements:
+  {
+    \int_step_inline:nnnn {1}{1}{\c at g__tag_struct_abs_int}
+      {
+        %\prop_show:c {g__tag_struct_##1_prop}
+        \__tag_struct_write_obj:n { ##1 } %write the object
+      }
+  }
 
-\cs_new:Nn \__uftag_tree_write_structelements:
- {
-  \int_step_inline:nnnn {1}{1}{\c at g__uftag_struct_abs_int}
-   {
-     %\prop_show:c {g__uftag_struct_##1_prop}
-     \__uftag_struct_write_obj:n { ##1 } %write the object
-   }
- }
 
+\pdf_object_new:nn { c__tag_tree_parenttree_obj }{ dict }
 
-%the ParentTree
-\__uftag_pdfreserveobjnum:N \l_tmpa_tl
-\tl_const:Nx \c__uftag_tree_obj_parenttree_tl    { \l_tmpa_tl }
+\newcounter  { g__tag_parenttree_obj_int }
+\hook_gput_code:nnn{begindocument}{tagpdf}
+  {
+    \int_gset:Nn
+      \c at g__tag_parenttree_obj_int
+      { \__tag_ref_value_lastpage:nn{abspage}{100}  }
+  }
 
-% we have two sets of entries in the parent tree:
-% page streams and real objects.
-% The numbers must be distinct and ordered
-% So we rely on abspage and put the real objects at the end
-% I use a counter to have a chance to get the correct number
-% if code is process twice.
-\newcounter  { g__uftag_parenttree_obj_int }
-\AtBeginDocument
- { \int_gset:Nn \c at g__uftag_parenttree_obj_int
-   { \zref at extractdefault{LastPage}{abspage}{100}  }
- }
 
-% we need to record the obj references:
+\tl_new:N \g__tag_parenttree_objr_tl
 
-\tl_new:N \g__uftag_parenttree_objr_tl
-
-\cs_new:Nn \__uftag_parenttree_add_objr:nn %#1 Structparent number, #2 obj number
-{
- \tl_gput_right:Nx \g__uftag_parenttree_objr_tl
+\cs_new_protected:Nn \__tag_parenttree_add_objr:nn %#1 Structparent number, #2 objref
   {
-   #1 \c_space_tl #2\c_space_tl 0 \c_space_tl R\c_space_tl ^^J
+    \tl_gput_right:Nx \g__tag_parenttree_objr_tl
+      {
+        #1 \c_space_tl #2 ^^J
+      }
   }
-}
 
-\tl_new:N \l__uftag_parenttree_content_tl
+\tl_new:N \l__tag_parenttree_content_tl
 
-\cs_new:Nn \__uftag_tree_fill_parenttree:
- {
-  \int_step_inline:nnnn{1}{1}{\zref at extractdefault{LastPage}{abspage}{-1}} %not quite clear if labels are needed. See lua code
-  { %page ##1\par
-   \prop_clear:N \l_tmpa_prop
-   \int_step_inline:nnnn{1}{1}{\zref at extractdefault{LastPage}{tagmcabs}{-1}}
-   {
-    %mcid####1
-    \int_compare:nT%F
-     {\zref at extractdefault{mcid-####1}{tagabspage}{-1}=##1} %mcid is on current page
-     {% yes\par
-      \prop_put:Nxx \l_tmpa_prop
-      {\zref at extractdefault{mcid-####1}{tagmcid}{-1}}
-      {\prop_item:Nn \g__uftag_mc_parenttree_prop {####1}}
-     }
-   }
-   %\prop_show:N \l_tmpa_prop
-   \tl_put_right:Nx\l__uftag_parenttree_content_tl
-      {\int_eval:n {##1-1}\c_space_tl[\c_space_tl} %%brackt
-   \int_step_inline:nnnn {0}{1}{ \prop_map_function:NN \l_tmpa_prop\__uftag_prop_count:nn -1 }
-    {
-     \prop_get:NnNTF \l_tmpa_prop {####1} \l_tmpb_tl
-     {% page#1:mcid##1:\l_tmpb_tl :content
-       \tl_put_right:Nx \l__uftag_parenttree_content_tl
-        {
-         \prop_item:cn { g__uftag_struct_\l_tmpb_tl _prop } {objnum}~0~R~
-        }
-     }
-     {\msg_warning:nn {uftag} {tree-mcid-index-wrong} }
-    }
-   \tl_put_right:Nn \l__uftag_parenttree_content_tl {]^^J} %
+\cs_new_protected:Nn \__tag_tree_fill_parenttree:
+  {
+    \int_step_inline:nnnn{1}{1}{\__tag_ref_value_lastpage:nn{abspage}{-1}} %not quite clear if labels are needed. See lua code
+      { %page ##1\par
+        \prop_clear:N \l_tmpa_prop
+        \int_step_inline:nnnn{1}{1}{\__tag_ref_value_lastpage:nn{tagmcabs}{-1}}
+          {
+            %mcid####1
+            \int_compare:nT%F
+              {\__tag_ref_value:enn{mcid-####1}{tagabspage}{-1}=##1} %mcid is on current page
+              {% yes\par
+                \prop_put:Nxx
+                  \l_tmpa_prop
+                  {\__tag_ref_value:enn{mcid-####1}{tagmcid}{-1}}
+                  {\prop_item:Nn \g__tag_mc_parenttree_prop {####1}}
+              }
+          }
+          %\prop_show:N \l_tmpa_prop
+        \tl_put_right:Nx\l__tag_parenttree_content_tl
+          {
+            \int_eval:n {##1-1}\c_space_tl
+            [\c_space_tl %]
+          }
+        \int_step_inline:nnnn
+          {0}
+          {1}
+          { \prop_map_function:NN \l_tmpa_prop\__tag_prop_count:nn -1 }
+          {
+            \prop_get:NnNTF \l_tmpa_prop {####1} \l_tmpb_tl
+              {% page#1:mcid##1:\l_tmpb_tl :content
+                \tl_put_right:Nx \l__tag_parenttree_content_tl
+                  {
+                    \prop_item:cn { g__tag_struct_\l_tmpb_tl _prop } {objref}
+                    \c_space_tl
+                  }
+                %\tl_show:N \l__tag_parenttree_content_tl
+              }
+              {
+                \msg_warning:nn { tag } {tree-mcid-index-wrong}
+              }
+          }
+        \tl_put_right:Nn
+          \l__tag_parenttree_content_tl
+          {%[
+            ]^^J
+          }
+      }
   }
- }
 
-%lua mode must/can do it differently
-\cs_new:Nn \__uftag_tree_lua_fill_parenttree:
- {
-  \tl_set:Nn \l__uftag_parenttree_content_tl
-   {
-    \directlua{uftag.func.output_parenttree(\int_use:N\g__uftag_abspage_int)}
-   }
- }
+\cs_new_protected:Nn \__tag_tree_lua_fill_parenttree:
+  {
+    \tl_set:Nn \l__tag_parenttree_content_tl
+      {
+        \directlua
+          {
+            ltx.__tag.func.output_parenttree
+              (
+                \int_use:N\g_shipout_readonly_int
+              )
+          }
+      }
+  }
 
+\cs_new_protected:Nn \__tag_tree_write_parenttree:
+  {
+    \bool_if:NTF \g__tag_mode_lua_bool
+      {
+        \__tag_tree_lua_fill_parenttree:
+      }
+      {
+        \__tag_tree_fill_parenttree:
+      }
+    \tl_put_right:NV \l__tag_parenttree_content_tl\g__tag_parenttree_objr_tl
+    \pdf_object_write:nx  { c__tag_tree_parenttree_obj }
+      {
+        /Nums\c_space_tl [\l__tag_parenttree_content_tl]
+      }
+  }
 
 
-\cs_new:Nn \__uftag_tree_write_parenttree:
- {
-  \bool_if:NTF \g__uftag_mode_lua_bool
-   {
-    \__uftag_tree_lua_fill_parenttree:
-   }
-   {
-    \__uftag_tree_fill_parenttree:
-   }
-  \tl_put_right:NV \l__uftag_parenttree_content_tl\g__uftag_parenttree_objr_tl
-  \__uftag_pdfuseobjnum:xx  { \c__uftag_tree_obj_parenttree_tl }
-   {
-    <<\c_space_tl/Nums\c_space_tl [\l__uftag_parenttree_content_tl] \c_space_tl >>
-   }
- }
+\pdf_object_new:nn { c__tag_tree_rolemap_obj }{ dict }
 
-%the Rolemap tree
-\__uftag_pdfreserveobjnum:N \l_tmpa_tl
-\tl_const:Nx \c__uftag_tree_obj_rolemap_tl { \l_tmpa_tl }
-\tl_new:N \l__uftag_rolemap_content_tl
+\tl_new:N \l__tag_rolemap_content_tl
 
-\cs_new:Nn \__uftag_tree_fill_rolemap:
- {
-  \prop_map_inline:Nn \g__uftag_role_rolemap_prop
-   {
-    \tl_put_right:Nx \l__uftag_rolemap_content_tl
-     {
-      /##1\c_space_tl/##2^^J
-     }
-   }
- }
+\cs_new_protected:Nn \__tag_tree_fill_rolemap:
+  {
+    \prop_map_inline:Nn \g__tag_role_rolemap_prop
+      {
+        \tl_put_right:Nx \l__tag_rolemap_content_tl
+          {
+            /##1\c_space_tl/##2^^J
+          }
+      }
+  }
 
-\cs_new:Nn \__uftag_tree_write_rolemap:
- {
-  \__uftag_tree_fill_rolemap:
-  \__uftag_pdfuseobjnum:xx  { \c__uftag_tree_obj_rolemap_tl }
-   {
-    <<\l__uftag_rolemap_content_tl >>
-   }
- }
+\cs_new_protected:Nn \__tag_tree_write_rolemap:
+  {
+    \__tag_tree_fill_rolemap:
+    \pdf_object_write:nx  { c__tag_tree_rolemap_obj }
+      {
+        \l__tag_rolemap_content_tl
+      }
+  }
 
-%classmap, should only be written, if values has been used
 
-\cs_new_protected:Nn \__uftag_tree_class_write_map:
- {
-  \tl_gclear:N \g__uftag_attr_class_content_tl
-  \seq_gremove_duplicates:N \g__uftag_attr_class_used_seq
-  \seq_set_map:NNn \l_tmpa_seq \g__uftag_attr_class_used_seq
-   {
-     /##1\c_space_tl
-     \prop_item:Nn \g__uftag_attr_entries_prop
-       {##1}
-   }
-  \tl_gset:Nx \g__uftag_attr_class_content_tl
-   {
-    \seq_use:Nn \l_tmpa_seq
-     { \iow_newline: }
-   }
-  \tl_if_empty:NF \g__uftag_attr_class_content_tl
+\cs_new_protected:Nn \__tag_tree_write_classmap:
   {
-   \__uftag_pdfreserveobjnum:N \l_tmpa_tl
-   \tl_const:Nx \c__uftag_tree_obj_classmap_tl { \l_tmpa_tl }
-   \__uftag_pdfuseobjnum:Nx \c__uftag_tree_obj_classmap_tl
-   { <<\g__uftag_attr_class_content_tl>> }
+    \tl_gclear:N \g__tag_attr_class_content_tl
+    \seq_gremove_duplicates:N \g__tag_attr_class_used_seq
+    \seq_set_map:NNn \l_tmpa_seq \g__tag_attr_class_used_seq
+      {
+        /##1\c_space_tl
+        <<
+          \prop_item:Nn
+            \g__tag_attr_entries_prop
+            {##1}
+        >>
+      }
+    \tl_gset:Nx \g__tag_attr_class_content_tl
+      {
+        \seq_use:Nn
+          \l_tmpa_seq
+          { \iow_newline: }
+      }
+    \tl_if_empty:NF
+      \g__tag_attr_class_content_tl
+      {
+        \pdf_object_new:nn { c__tag_tree_classmap_obj }{ dict }
+     %   \__tag_pdfreserveobjnum:N \l_tmpa_tl
+     %   \tl_const:Nx \c__tag_tree_obj_classmap_tl { \l_tmpa_tl }
+        \pdf_object_write:nx
+          { c__tag_tree_classmap_obj }
+          { \g__tag_attr_class_content_tl }
+        \__tag_prop_gput:cnx
+          { g__tag_struct_0_prop }
+          { ClassMap }
+          { \pdf_object_ref:n { c__tag_tree_classmap_obj }  }
+      }
+  }
 
-   \__uftag_prop_gput:cnx
-    { g__uftag_struct_0_prop }
-    { ClassMap }
-    { \c__uftag_tree_obj_classmap_tl\c_space_tl0\c_space_tl R  }
+\cs_new_protected:Nn \tag_finish_structure:
+  {
+    \__tag_tree_write_parenttree:
+    \__tag_tree_write_rolemap:
+    \__tag_tree_write_classmap:
+    \__tag_tree_write_structelements: %this is rather slow!!
+    \__tag_tree_write_structtreeroot:
   }
- }
 
+\cs_set_eq:NN \uftag_finish_structure: \tag_finish_structure:
 
-\cs_new:Nn \uftag_finish_structure:
- {
-  \__uftag_pdfcatalog:n {^^J/MarkInfo\c_space_tl<</Marked\c_space_tl true>> }
-  \__uftag_tree_write_parenttree:
-  \__uftag_tree_write_rolemap:
-  \__uftag_tree_class_write_map:
-  \__uftag_tree_write_structelements:
-  \__uftag_tree_write_structtreeroot:
- }
+\hook_gput_code:nnn{begindocument}{tagpdf}
+  {
+    \bool_if:NT\g__tag_active_tree_bool
+      {
+       \hook_gput_code:nnn{shipout/before} { tagpdf/structparents }
+         {
+             \pdfmanagement_add:nnx
+               { Page }
+               {StructParents}
+               {\int_eval:n { \g_shipout_readonly_int}}
+         }
+      }
+  }
 
-
-%StructParents + tabs order. Tabs order should be probably be changeable by page.
-
-\cs_new:Nn \__uftag_tree_write_pageattr:
- {
-  \__uftag_get_pdfpageattr:N \l_tmpa_tl
-  \regex_replace_once:nnN {/StructParents\s*\d+} {}\l_tmpa_tl
-  \regex_replace_once:nnN {/Tabs\s*/[SCR]} {}\l_tmpa_tl
-  \__uftag_gset_pdfpageattr:x
-   {
-    \l_tmpa_tl / StructParents \c_space_tl
-    \int_eval:n { \g__uftag_abspage_int }
-    \l__uftag_tree_tabs_order_tl
-   }
- }
-
-\endinput
+%% 
+%%
+%% End of file `tagpdf-tree-code.sty'.

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.sty	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.sty	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,102 +1,171 @@
-\ProvidesExplPackage {tagpdf-user} {2019/07/02} {0.61}
+%%
+%% This is file `tagpdf-user.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tagpdf.dtx  (with options: `user')
+%% 
+%% Copyright (C) 2019 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-user} {2021/02/23} {0.80}
   {tagpdf - user commands}
 
 \NewDocumentCommand \tagpdfsetup { m }
- {
-  \keys_set:nn { uftag / setup } { #1 }
- }
+  {
+    \keys_set:nn { __tag / setup } { #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
 
+%%% stop tagging
+\bool_new:N \l__tag_stop_bool
+
+\prg_new_conditional:Nnn \__tag_if_stop: {p,T,F,TF}
+  {
+    \bool_if:NTF \l__tag_stop_bool
+      { \prg_return_true:  }
+      { \prg_return_false: }
+  }
+
+\prg_new_eq_conditional:NNn \tag_if_stop: \__tag_if_stop: {p,T,F,TF}
+
+\cs_new_protected:Npn \__tag_stop:
+  {
+    \bool_set_true:N \l__tag_stop_bool
+    \cs_set_eq:NN \tag_mc_begin:n     \use_none:n
+    \cs_set_eq:NN \tag_mc_end:        \prg_do_nothing:
+    \cs_set_eq:NN \tag_mc_use:n       \use_none:n
+    \cs_set_eq:NN \tag_struct_begin:n \use_none:n
+    \cs_set_eq:NN \tag_struct_end:    \prg_do_nothing:
+    \cs_set_eq:NN \tag_struct_use:n   \use_none:n
+    %deprecated
+    \cs_set_eq:NN \uftag_mc_begin:n \tag_mc_begin:n
+    \cs_set_eq:NN \uftag_mc_end:    \tag_mc_end:
+    \cs_set_eq:NN \uftag_mc_use:n \tag_mc_use:n
+    \cs_set_eq:NN \uftag_struct_begin:n \tag_struct_begin:n
+    \cs_set_eq:NN \uftag_struct_end: \tag_struct_end:
+    \cs_set_eq:NN  \uftag_struct_use:n \tag_struct_use:n
+  }
+
+\cs_new_protected:Npn \tag_stop_group_begin:
+  {
+    \group_begin:
+    \__tag_stop:
+  }
+
+\cs_set_eq:NN \tag_stop_group_end: \group_end:
+
 %%% a generic command to retrieve data
 
-\cs_new:Npn \tagpdfget #1 { \uftag_get:n { #1} }
-\cs_new:Npn \uftag_get:n #1 { \use:c {__uftag_get_data_#1: } }
+\cs_new:Npn \tagpdfget #1   { \use:c {__tag_get_data_#1: } }
+\cs_new:Npn \tag_get:n #1   { \use:c {__tag_get_data_#1: } }
+\cs_new:Npn \uftag_get:n #1 { \use:c {__tag_get_data_#1: } }
 
-
 %%%% mc related user commands
 \NewDocumentCommand \tagmcifinTF { m m }
+  {
+    \__tag_mc_if_in:TF { #1 } { #2 }
+  }
+
+\NewDocumentEnvironment{tagmcartifact}{m}
  {
-  \__uftag_mc_if_in:TF { #1 } { #2 }
+  \tag_mc_artifact_group_begin:n { #1}\ignorespaces
  }
-
-\NewDocumentCommand \tagmcbegin { m }
  {
-  \uftag_mc_begin:n {#1}\ignorespaces
+  \tag_mc_artifact_group_end:
  }
 
+\NewDocumentCommand \tagmcbegin { m }
+  {
+    \tag_mc_begin:n {#1}\ignorespaces
+  }
 
 \NewDocumentCommand \tagmcend {  }
- {
-  \unskip % this unskip appears to mess up some spacing; can we do this in another way?
-  \uftag_mc_end:
- }
+  {
+    \unskip % this unskip appears to mess up some spacing; can we do this in another way?
+    \tag_mc_end:
+  }
 
 \NewDocumentCommand \tagmcuse { m }
- {
-  \uftag_mc_use:n {#1}
- }
+  {
+    \tag_mc_use:n {#1}
+  }
 
-
 %%%% structure related commands
 
 \NewDocumentCommand \tagstructbegin { m }
- {
-  \uftag_struct_begin:n {#1}
- }
+  {
+    \tag_struct_begin:n {#1}
+  }
 
 \NewDocumentCommand \tagstructend {  }
- {
-  \uftag_struct_end:
- }
+  {
+   \tag_struct_end:
+  }
 
 \NewDocumentCommand \tagstructuse { m }
- {
-  \uftag_struct_use:n {#1}
- }
+  {
+    \tag_struct_use:n {#1}
+  }
 
-
-
 %%%% debug/show commands
-\NewDocumentCommand\showtagpdfmcdata { O {\__uftag_get_mc_abs_cnt:} }
- {
-  \bool_if:NT \g__uftag_mode_lua_bool
-   {
-    \sys_if_engine_luatex:T
-     {
-      \directlua{uftag.trace.show_all_mc_data(#1)}
-     }
-   }
- }
+\NewDocumentCommand\showtagpdfmcdata { O {\__tag_tag_get_mc_abs_cnt:} }
+  {
+    \bool_if:NT \g__tag_mode_lua_bool
+      {
+        \sys_if_engine_luatex:T
+          {
+            \directlua{ltx.__tag.trace.show_all_mc_data(#1)}
+          }
+      }
+  }
 
 \NewDocumentCommand\showtagpdfattributes { }
- {
-  \bool_if:NT \g__uftag_mode_lua_bool
-   {
-    \sys_if_engine_luatex:T
-     {
-      \directlua
-       {
-        uftag.trace.log(
-        "showtagpdfattributes: MC=>abscnt=\__uftag_get_mc_abs_cnt:=>attr=\the\l__uftag_mc_cnt_attr=>tag=" ..
-        tostring(uftag.func.get_tag_from (\the\l__uftag_mc_type_attr)) ..
-        "=\the\l__uftag_mc_type_attr",0
-        )
-       }
-      \ignorespaces
-     }
+  {
+    \bool_if:NT \g__tag_mode_lua_bool
+      {
+        \sys_if_engine_luatex:T
+          {
+            \directlua
+              {
+                ltx.__tag.trace.log
+                 (
+                   "showtagpdfattributes:
+                    MC=>abscnt=\__tag_get_mc_abs_cnt:
+                    =>attr=\the\l__tag_mc_cnt_attr=>tag="
+                    ..
+                    tostring(ltx.__tag.func.get_tag_from (\the\l__tag_mc_type_attr))
+                    ..
+                    "=\the\l__tag_mc_type_attr",0
+                 )
+             }
+            \ignorespaces
+          }
+      }
    }
- }
 
 \sys_if_engine_luatex:T
-{
-  \NewDocumentCommand\pdffakespace { }
   {
-   \__uftag_fakespace:
+    \NewDocumentCommand\pdffakespace { }
+      {
+        \__tag_fakespace:
+      }
   }
-}
 
-
-\endinput
+%% 
+%%
+%% End of file `tagpdf-user.sty'.

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,10 +1,31 @@
+-- 
+--  This is file `tagpdf.lua',
+--  generated with the docstrip utility.
+-- 
+--  The original source files were:
+-- 
+--  tagpdf-backend.dtx  (with options: `lua')
+--  
+--  Copyright (C) 2019 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-backend.dtx
 -- tagpdf.lua
 -- Ulrike Fischer
 
-local ProvidesLuaModule = { 
+local ProvidesLuaModule = {
     name          = "tagpdf",
-    version       = "0.61",       --TAGVERSION
-    date          = "2019-07-02", --TAGDATE
+    version       = "0.80",       --TAGVERSION
+    date          = "2021-02-23", --TAGDATE
     description   = "tagpdf lua code",
     license       = "The LATEX Project Public License 1.3c"
 }
@@ -11,7 +32,7 @@
 
 if luatexbase and luatexbase.provides_module then
   luatexbase.provides_module (ProvidesLuaModule)
-end  
+end
 
 --[[
 The code has quite probably a number of problems
@@ -19,60 +40,58 @@
  - the naming is not always consistent due to the development of the code
  - the traversing of the shipout box must be tested with more complicated setups
  - it should probably handle more node types
- - 
+ -
 --]]
 
-
-
 --[[
-the main table is named uftag. It contains the functions and also the data
+the main table is named ltx.__tag. It contains the functions and also the data
 collected during the compilation.
 
-uftag.mc     will contain mc connected data.
-uftag.struct will contain structure related data.
-uftag.page   will contain page data
-uftag.tables contains also data from mc and struct (from older code). This needs cleaning up. 
+ltx.__tag.mc     will contain mc connected data.
+ltx.__tag.struct will contain structure related data.
+ltx.__tag.page   will contain page data
+ltx.__tag.tables contains also data from mc and struct (from older code). This needs cleaning up.
              There are certainly dublettes, but I don't dare yet ...
-uftag.func   will contain (public) functions. 
-uftag.trace  will contain tracing/loging functions.
+ltx.__tag.func   will contain (public) functions.
+ltx.__tag.trace  will contain tracing/loging functions.
 local funktions starts with __
+functions meant for users will be in ltx.tag
 
 functions
- uftag.func.get_num_from (tag):    takes a tag (string) and returns the id number
- uftag.func.output_num_from (tag): takes a tag (string) and prints (to tex) the id number
- uftag.func.get_tag_from (num):    takes a num and returns the tag
- uftag.func.output_tag_from (num): takes a num and prints (to tex) the tag
- uftag.func.store_mc_data (num,key,data): stores key=data in uftag.mc[num] 
- uftag.func.store_mc_label (label,num): stores label=num in uftag.mc.labels
- uftag.func.store_mc_kid (mcnum,kid,page): stores the mc-kids of mcnum on page page
- uftag.func.store_mc_in_page(mcnum,mcpagecnt,page): stores in the page table the number of mcnum on this page
- uftag.func.store_struct_mcabs (structnum,mcnum): stores relations structnum<->mcnum (abs)
- uftag.func.mc_insert_kids (mcnum): inserts the /K entries for mcnum by wandering throught the [kids] table
- uftag.func.mark_page_elements(box,mcpagecnt,mccntprev,mcopen,name,mctypeprev) : the main function 
- uftag.func.mark_shipout (): a wrapper around the core function which inserts the last EMC
- uftag.func.fill_parent_tree_line (page): outputs the entries of the parenttree for this page
- uftag.func.output_parenttree(): outputs the content of the parenttree
- uftag.func.markspaceon(), uftag.func.markspaceoff(): (de)activates the marking of positions for space chars
- uftag.trace.show_mc_data (num): shows uftag.mc[num] 
- uftag.trace.show_all_mc_data (max): shows a maximum about mc's
- uftag.trace.show_seq: shows a sequence (array)
- uftag.trace.show_struct_data (num): shows data of structure num
- uftag.trace.show_prop: shows a prop 
- uftag.trace.log
- uftag.trace.showspaces : boolean
+ ltx.__tag.func.get_num_from (tag):    takes a tag (string) and returns the id number
+ ltx.__tag.func.output_num_from (tag): takes a tag (string) and prints (to tex) the id number
+ ltx.__tag.func.get_tag_from (num):    takes a num and returns the tag
+ ltx.__tag.func.output_tag_from (num): takes a num and prints (to tex) the tag
+ ltx.__tag.func.store_mc_data (num,key,data): stores key=data in ltx.__tag.mc[num]
+ ltx.__tag.func.store_mc_label (label,num): stores label=num in ltx.__tag.mc.labels
+ ltx.__tag.func.store_mc_kid (mcnum,kid,page): stores the mc-kids of mcnum on page page
+ ltx.__tag.func.store_mc_in_page(mcnum,mcpagecnt,page): stores in the page table the number of mcnum on this page
+ ltx.__tag.func.store_struct_mcabs (structnum,mcnum): stores relations structnum<->mcnum (abs)
+ ltx.__tag.func.mc_insert_kids (mcnum): inserts the /K entries for mcnum by wandering throught the [kids] table
+ ltx.__tag.func.mark_page_elements(box,mcpagecnt,mccntprev,mcopen,name,mctypeprev) : the main function
+ ltx.__tag.func.mark_shipout (): a wrapper around the core function which inserts the last EMC
+ ltx.__tag.func.fill_parent_tree_line (page): outputs the entries of the parenttree for this page
+ ltx.__tag.func.output_parenttree(): outputs the content of the parenttree
+ ltx.__tag.func.markspaceon(), ltx.__tag.func.markspaceoff(): (de)activates the marking of positions for space chars
+ ltx.__tag.trace.show_mc_data (num): shows ltx.__tag.mc[num]
+ ltx.__tag.trace.show_all_mc_data (max): shows a maximum about mc's
+ ltx.__tag.trace.show_seq: shows a sequence (array)
+ ltx.__tag.trace.show_struct_data (num): shows data of structure num
+ ltx.__tag.trace.show_prop: shows a prop
+ ltx.__tag.trace.log
+ ltx.__tag.trace.showspaces : boolean
 --]]
 
-local mctypeattributeid       = luatexbase.registernumber ("l__uftag_mc_type_attr")
-local mccntattributeid        = luatexbase.registernumber ("l__uftag_mc_cnt_attr")
-local iwspaceattributeid = luatexbase.registernumber ("g__uftag_interwordspace_attr")
-local iwfontattributeid = luatexbase.registernumber ("g__uftag_interwordfont_attr")
+local mctypeattributeid       = luatexbase.registernumber ("l__tag_mc_type_attr")
+local mccntattributeid        = luatexbase.registernumber ("l__tag_mc_cnt_attr")
+local iwspaceattributeid = luatexbase.registernumber ("g__tag_interwordspace_attr")
+local iwfontattributeid = luatexbase.registernumber ("g__tag_interwordfont_attr")
 
-
 local catlatex       = luatexbase.registernumber("catcodetable at latex")
-local tagunmarkedbool= token.create("g__uftag_tagunmarked_bool")
-local truebool       = token.create("c_true_bool") 
+local tagunmarkedbool= token.create("g__tag_tagunmarked_bool")
+local truebool       = token.create("c_true_bool")
 
-local tableinsert    = table.insert 
+local tableinsert    = table.insert
 
 -- not all needed, copied from lua-visual-debug.
 local nodeid           = node.id
@@ -87,7 +106,7 @@
 local nodetraverse     = node.traverse
 local nodeinsertafter  = node.insert_after
 local nodeinsertbefore = node.insert_before
-local pdfpageref       = pdf.pageref 
+local pdfpageref       = pdf.pageref
 
 local HLIST          = node.id("hlist")
 local VLIST          = node.id("vlist")
@@ -100,46 +119,43 @@
 local LOCAL_PAR      = node.id("local_par")
 local MATH           = node.id("math")
 
-local function __uftag_get_mathsubtype  (mathnode)
+local function __tag_get_mathsubtype  (mathnode)
  if mathnode.subtype == 0 then
   subtype = "beginmath"
- else 
+ else
   subtype = "endmath"
- end  
+ end
  return subtype
-end 
+end
 
-
-
-uftag                = uftag        or { }
-uftag.mc             = uftag.mc     or  { } -- mc data
-uftag.struct         = uftag.struct or  { } -- struct data
-uftag.tables         = uftag.tables or  { } -- tables created with new prop and new seq. 
+ltx             = ltx        or { }
+ltx.__tag          = ltx.__tag        or { }
+ltx.__tag.mc             = ltx.__tag.mc     or  { } -- mc data
+ltx.__tag.struct         = ltx.__tag.struct or  { } -- struct data
+ltx.__tag.tables         = ltx.__tag.tables or  { } -- tables created with new prop and new seq.
                                             -- wasn't a so great idea ...
-uftag.page           = uftag.page   or  { } -- page data, currently only i->{0->mcnum,1->mcnum,...}  
-uftag.trace          = uftag.trace  or  { } -- show commands
-uftag.func           = uftag.func   or  { } -- functions 
-uftag.conf           = uftag.conf   or  { } -- configuration variables
+ltx.__tag.page           = ltx.__tag.page   or  { } -- page data, currently only i->{0->mcnum,1->mcnum,...}
+ltx.__tag.trace          = ltx.__tag.trace  or  { } -- show commands
+ltx.__tag.func           = ltx.__tag.func   or  { } -- functions
+ltx.__tag.conf           = ltx.__tag.conf   or  { } -- configuration variables
 
-local __uftag_log = 
+local __tag_log =
  function (message,loglevel)
-  if (loglevel or 3) <= tex.count["l__uftag_loglevel_int"] then
+  if (loglevel or 3) <= tex.count["l__tag_loglevel_int"] then
    texio.write_nl("tagpdf: ".. message)
   end
- end 
+ end
 
-uftag.trace.log = __uftag_log
+ltx.__tag.trace.log = __tag_log
 
-
-local __uftag_get_mc_cnt_type_tag = function (n)
+local __tag_get_mc_cnt_type_tag = function (n)
   local mccnt      =  nodegetattribute(n,mccntattributeid)  or -1
   local mctype     =  nodegetattribute(n,mctypeattributeid)  or -1
-  local tag        =  uftag.func.get_tag_from(mctype)
+  local tag        =  ltx.__tag.func.get_tag_from(mctype)
   return mccnt,mctype,tag
 end
 
-
-local function __uftag_insert_emc_node (head,current)
+local function __tag_insert_emc_node (head,current)
  local emcnode = nodenew("whatsit","pdf_literal")
        emcnode.data = "EMC"
        emcnode.mode=1
@@ -147,8 +163,7 @@
  return head
 end
 
-
-local function __uftag_insert_bmc_node (head,current,tag)
+local function __tag_insert_bmc_node (head,current,tag)
  local bmcnode = nodenew("whatsit","pdf_literal")
        bmcnode.data = "/"..tag.." BMC"
        bmcnode.mode=1
@@ -156,7 +171,7 @@
  return head
 end
 
-local function __uftag_insert_bdc_node (head,current,tag,dict)
+local function __tag_insert_bdc_node (head,current,tag,dict)
  local bdcnode = nodenew("whatsit","pdf_literal")
        bdcnode.data = "/"..tag.."<<"..dict..">> BDC"
        bdcnode.mode=1
@@ -165,9 +180,9 @@
 end
 
 -- this is for debugging the space chars
-local function __uftag_show_spacemark (head,current,color,height)
+local function __tag_show_spacemark (head,current,color,height)
  local markcolor = color or "1 0 0"
- local markheight = height or 10 
+ local markheight = height or 10
  local pdfstring = node.new("whatsit","pdf_literal")
        pdfstring.data =
        string.format("q "..markcolor.." RG "..markcolor.." rg 0.4 w 0 %g m 0 %g l S Q",-3,markheight)
@@ -177,9 +192,9 @@
 
 --[[ a function to mark up places where real space chars should be inserted
      it only sets an attribute.
---]]    
+--]]
 
-local function __uftag_mark_spaces (head)
+local function __tag_mark_spaces (head)
   local inside_math = false
   for n in nodetraverse(head) do
     local id = n.id
@@ -190,31 +205,31 @@
       then
         nodesetattribute(glyph.next,iwspaceattributeid,1)
         nodesetattribute(glyph.next,iwfontattributeid,glyph.font)
-      -- for debugging  
-       if uftag.trace.showspaces then 
-        __uftag_show_spacemark (head,glyph)
-       end 
+      -- for debugging
+       if ltx.__tag.trace.showspaces then
+        __tag_show_spacemark (head,glyph)
+       end
       elseif glyph.next and (glyph.next.id==KERN) and not inside_math then
        local kern = glyph.next
-       if kern.next and (kern.next.id== GLUE)  and (kern.next.width >0) 
+       if kern.next and (kern.next.id== GLUE)  and (kern.next.width >0)
        then
         nodesetattribute(kern.next,iwspaceattributeid,1)
         nodesetattribute(kern.next,iwfontattributeid,glyph.font)
-       end 
+       end
       end
     elseif id == PENALTY then
       local glyph = n
-      -- uftag.trace.log ("PENALTY ".. n.subtype.."VALUE"..n.penalty,3) 
+      -- ltx.__tag.trace.log ("PENALTY ".. n.subtype.."VALUE"..n.penalty,3)
       if glyph.next and (glyph.next.id == GLUE)
         and not inside_math  and (glyph.next.width >0) and n.subtype==0
       then
         nodesetattribute(glyph.next,iwspaceattributeid,1)
       --  nodesetattribute(glyph.next,iwfontattributeid,glyph.font)
-      -- for debugging  
-       if uftag.trace.showspaces then 
-        __uftag_show_spacemark (head,glyph)
-       end 
-      end 
+      -- for debugging
+       if ltx.__tag.trace.showspaces then
+        __tag_show_spacemark (head,glyph)
+       end
+      end
     elseif id == MATH then
       inside_math = (n.subtype == 0)
     end
@@ -222,16 +237,16 @@
   return head
 end
 
-local function __uftag_activate_mark_space ()
+local function __tag_activate_mark_space ()
  if not luatexbase.in_callback ("pre_linebreak_filter","markspaces") then
-  luatexbase.add_to_callback("pre_linebreak_filter",__uftag_mark_spaces,"markspaces")
-  luatexbase.add_to_callback("hpack_filter",__uftag_mark_spaces,"markspaces")
- end 
+  luatexbase.add_to_callback("pre_linebreak_filter",__tag_mark_spaces,"markspaces")
+  luatexbase.add_to_callback("hpack_filter",__tag_mark_spaces,"markspaces")
+ end
 end
 
-uftag.func.markspaceon=__uftag_activate_mark_space
+ltx.__tag.func.markspaceon=__tag_activate_mark_space
 
-local function __uftag_deactivate_mark_space ()
+local function __tag_deactivate_mark_space ()
  if luatexbase.in_callback ("pre_linebreak_filter","markspaces") then
  luatexbase.remove_from_callback("pre_linebreak_filter","markspaces")
  luatexbase.remove_from_callback("hpack_filter","markspaces")
@@ -238,7 +253,7 @@
  end
 end
 --
-uftag.func.markspaceoff=__uftag_deactivate_mark_space
+ltx.__tag.func.markspaceoff=__tag_deactivate_mark_space
 
 local default_space_char = node.new(GLYPH)
 local default_fontid     = font.id("TU/lmr/m/n/10")
@@ -245,7 +260,7 @@
 default_space_char.char  = 32
 default_space_char.font  = default_fontid
 
-local function __uftag_insert_space_char (head,n,fontid)
+local function __tag_insert_space_char (head,n,fontid)
  if luaotfload.aux.slot_of_name(fontid,"space") then
   local space
   -- head, space = node.insert_before(head, n, ) -- Set the right font
@@ -258,167 +273,168 @@
     Now follows the core function
     It wades through the shipout box and checks the attributes
     ARGUMENTS
-    box: is a box, 
+    box: is a box,
     mcpagecnt: num, the current page cnt of mc (should start at -1 in shipout box), needed for recursion
     mccntprev: num, the attribute cnt of the previous node/whatever - if different we have a chunk border
-    mcopen: num, records if some bdc/emc is open 
+    mcopen: num, records if some bdc/emc is open
     These arguments are only needed for log messages, if not present are replaces by fix strings:
     name: string to describe the box
     mctypeprev: num, the type attribute of the previous node/whatever
-    
+
     there are lots of logging messages currently. Should be cleaned up in due course.
     One should also find ways to make the function shorter.
 --]]
 
-function uftag.func.mark_page_elements (box,mcpagecnt,mccntprev,mcopen,name,mctypeprev)
+function ltx.__tag.func.mark_page_elements (box,mcpagecnt,mccntprev,mcopen,name,mctypeprev)
   local name = name or ("SOMEBOX")
   local mctypeprev = mctypeprev or -1
-  local abspage = tex.count["g__uftag_abspage_int"]  --["c at abspage"]
-  uftag.trace.log ("PAGE " .. abspage,3)
-  uftag.trace.log ("FUNC ARGS: pagecnt".. mcpagecnt.." prev "..mccntprev .. " type prev "..mctypeprev,4)
-  uftag.trace.log ("TRAVERSING BOX ".. tostring(name).." TYPE ".. node.type(node.getid(box)),3) 
-  local head = box.head -- AtBeginShipoutBox is a vlist?
+  local abspage = status.total_pages + 1  -- the real counter is increased inside the box so one off
+                                                                       -- if the callback is not used.
+  ltx.__tag.trace.log ("PAGE " .. abspage,3)
+  ltx.__tag.trace.log ("FUNC ARGS: pagecnt".. mcpagecnt.." prev "..mccntprev .. " type prev "..mctypeprev,4)
+  ltx.__tag.trace.log ("TRAVERSING BOX ".. tostring(name).." TYPE ".. node.type(node.getid(box)),3)
+  local head = box.head -- ShipoutBox is a vlist?
   if head then
-    mccnthead, mctypehead,taghead = __uftag_get_mc_cnt_type_tag (head)
-    uftag.trace.log ("HEAD " .. node.type(node.getid(head)).. " MC"..tostring(mccnthead).." => TAG "..tostring(mctypehead).." => "..tostring(taghead),3) 
+    mccnthead, mctypehead,taghead = __tag_get_mc_cnt_type_tag (head)
+    ltx.__tag.trace.log ("HEAD " .. node.type(node.getid(head)).. " MC"..tostring(mccnthead).." => TAG "..tostring(mctypehead).." => "..tostring(taghead),3)
   else
-    uftag.trace.log ("HEAD is ".. tostring(head),3)
-  end  
+    ltx.__tag.trace.log ("HEAD is ".. tostring(head),3)
+  end
   for n in node.traverse(head) do
-    local mccnt, mctype, tag = __uftag_get_mc_cnt_type_tag (n)
+    local mccnt, mctype, tag = __tag_get_mc_cnt_type_tag (n)
     local spaceattr = nodegetattribute(n,iwspaceattributeid)  or -1
-    uftag.trace.log ("NODE ".. node.type(node.getid(n)).." MC"..tostring(mccnt).." => TAG "..tostring(mctype).." => " .. tostring(tag),3)
+    ltx.__tag.trace.log ("NODE ".. node.type(node.getid(n)).." MC"..tostring(mccnt).." => TAG "..tostring(mctype).." => " .. tostring(tag),3)
     if n.id == HLIST
     then -- enter the hlist
-     mcopen,mcpagecnt,mccntprev,mctypeprev= 
-      uftag.func.mark_page_elements (n,mcpagecnt,mccntprev,mcopen,"INTERNAL HLIST",mctypeprev)
-    elseif n.id == VLIST then -- enter the vlist     
-     mcopen,mcpagecnt,mccntprev,mctypeprev= 
-      uftag.func.mark_page_elements (n,mcpagecnt,mccntprev,mcopen,"INTERNAL VLIST",mctypeprev)
-    elseif n.id == GLUE then       -- at glue real space chars are inserted, for the rest it is ignored 
-     -- for debugging       
-     if uftag.trace.showspaces and spaceattr==1  then 
-        __uftag_show_spacemark (head,n,"0 1 0")
+     mcopen,mcpagecnt,mccntprev,mctypeprev=
+      ltx.__tag.func.mark_page_elements (n,mcpagecnt,mccntprev,mcopen,"INTERNAL HLIST",mctypeprev)
+    elseif n.id == VLIST then -- enter the vlist
+     mcopen,mcpagecnt,mccntprev,mctypeprev=
+      ltx.__tag.func.mark_page_elements (n,mcpagecnt,mccntprev,mcopen,"INTERNAL VLIST",mctypeprev)
+    elseif n.id == GLUE then       -- at glue real space chars are inserted, for the rest it is ignored
+     -- for debugging
+     if ltx.__tag.trace.showspaces and spaceattr==1  then
+        __tag_show_spacemark (head,n,"0 1 0")
      end
-     if spaceattr==1  then 
+     if spaceattr==1  then
         local space
         local space_char = node.copy(default_space_char)
-        local curfont    = nodegetattribute(n,iwfontattributeid)  
-        uftag.trace.log ("FONT ".. tostring(curfont),3)
+        local curfont    = nodegetattribute(n,iwfontattributeid)
+        ltx.__tag.trace.log ("FONT ".. tostring(curfont),3)
         if curfont and luaotfload.aux.slot_of_name(curfont,"space") then
           space_char.font=curfont
         end
-        head, space = node.insert_before(head, n, space_char) -- 
+        head, space = node.insert_before(head, n, space_char) --
         n.width     = n.width - space.width
         space.attr  = n.attr
      end
-    elseif n.id == LOCAL_PAR then  -- local_par is ignored 
+    elseif n.id == LOCAL_PAR then  -- local_par is ignored
     elseif n.id == PENALTY then    -- penalty is ignored
-    elseif n.id == KERN then       -- kern is ignored   
-     uftag.trace.log ("SUBTYPE KERN ".. n.subtype,3)  
+    elseif n.id == KERN then       -- kern is ignored
+     ltx.__tag.trace.log ("SUBTYPE KERN ".. n.subtype,3)
     else
-     -- math is currently only logged. 
+     -- math is currently only logged.
      -- we could mark the whole as math
      -- for inner processing the mlist_to_hlist callback is probably needed.
-     if n.id == MATH then       
-      uftag.trace.log("NODE "..node.type(node.getid(n)).." "..__uftag_get_mathsubtype(n),3)
+     if n.id == MATH then
+      ltx.__tag.trace.log("NODE "..node.type(node.getid(n)).." "..__tag_get_mathsubtype(n),3)
      end
      -- endmath
-     uftag.trace.log("CURRENT "..mccnt.." PREV "..mccntprev,3)
+     ltx.__tag.trace.log("CURRENT "..mccnt.." PREV "..mccntprev,3)
      if mccnt~=mccntprev then -- a new mc chunk
-      uftag.trace.log ("NODE ".. node.type(node.getid(n)).." MC"..tostring(mccnt).." <=> PREVIOUS "..tostring(mccntprev),3)
+      ltx.__tag.trace.log ("NODE ".. node.type(node.getid(n)).." MC"..tostring(mccnt).." <=> PREVIOUS "..tostring(mccntprev),3)
       if mcopen~=0 then -- there is a chunk open, close it (hope there is only one ...
-       box.list=__uftag_insert_emc_node (box.list,n)
+       box.list=__tag_insert_emc_node (box.list,n)
        mcopen = mcopen - 1
-       uftag.trace.log ("INSERT EMC " .. mcpagecnt .. " MCOPEN = " .. mcopen,2)
+       ltx.__tag.trace.log ("INSERT EMC " .. mcpagecnt .. " MCOPEN = " .. mcopen,2)
        if mcopen ~=0 then
-        uftag.trace.log ("!WARNING! open mc" .. " MCOPEN = " .. mcopen,1)
-       end 
-      end 
-      if uftag.mc[mccnt] then
-       if uftag.mc[mccnt]["artifact"] then
-        uftag.trace.log("THIS IS AN ARTIFACT of type "..tostring(uftag.mc[mccnt]["artifact"]),3)
-        if uftag.mc[mccnt]["artifact"] == "" then
-         box.list = __uftag_insert_bmc_node (box.list,n,"Artifact")
+        ltx.__tag.trace.log ("!WARNING! open mc" .. " MCOPEN = " .. mcopen,1)
+       end
+      end
+      if ltx.__tag.mc[mccnt] then
+       if ltx.__tag.mc[mccnt]["artifact"] then
+        ltx.__tag.trace.log("THIS IS AN ARTIFACT of type "..tostring(ltx.__tag.mc[mccnt]["artifact"]),3)
+        if ltx.__tag.mc[mccnt]["artifact"] == "" then
+         box.list = __tag_insert_bmc_node (box.list,n,"Artifact")
         else
-         box.list = __uftag_insert_bdc_node (box.list,n,"Artifact", "/Type /"..uftag.mc[mccnt]["artifact"])
+         box.list = __tag_insert_bdc_node (box.list,n,"Artifact", "/Type /"..ltx.__tag.mc[mccnt]["artifact"])
         end
        else
-        uftag.trace.log("THIS IS A TAG "..tostring(tag),3)  
+        ltx.__tag.trace.log("THIS IS A TAG "..tostring(tag),3)
         mcpagecnt = mcpagecnt +1
-        uftag.trace.log ("INSERT BDC "..mcpagecnt,2)
+        ltx.__tag.trace.log ("INSERT BDC "..mcpagecnt,2)
         local dict= "/MCID "..mcpagecnt
-        if uftag.mc[mccnt]["raw"] then
-         uftag.trace.log("RAW CONTENT"..tostring(uftag.mc[mccnt]["raw"]),3)
-         dict= dict .. " " .. uftag.mc[mccnt]["raw"]
-        end 
-        if uftag.mc[mccnt]["alt"] then
-         uftag.trace.log("RAW CONTENT"..tostring(uftag.mc[mccnt]["alt"]),3)
-         dict= dict .. " " .. uftag.mc[mccnt]["alt"]
-        end 
-        if uftag.mc[mccnt]["actualtext"] then
-         uftag.trace.log("RAW CONTENT"..tostring(uftag.mc[mccnt]["actualtext"]),3)
-         dict= dict .. " " .. uftag.mc[mccnt]["actualtext"]
-        end    
-        box.list = __uftag_insert_bdc_node (box.list,n,tag, dict)
-        uftag.func.store_mc_kid (mccnt,mcpagecnt,abspage)
-        uftag.func.store_mc_in_page(mccnt,mcpagecnt,abspage)
-        uftag.trace.show_mc_data (mccnt)
-       end 
+        if ltx.__tag.mc[mccnt]["raw"] then
+         ltx.__tag.trace.log("RAW CONTENT"..tostring(ltx.__tag.mc[mccnt]["raw"]),3)
+         dict= dict .. " " .. ltx.__tag.mc[mccnt]["raw"]
+        end
+        if ltx.__tag.mc[mccnt]["alt"] then
+         ltx.__tag.trace.log("RAW CONTENT"..tostring(ltx.__tag.mc[mccnt]["alt"]),3)
+         dict= dict .. " " .. ltx.__tag.mc[mccnt]["alt"]
+        end
+        if ltx.__tag.mc[mccnt]["actualtext"] then
+         ltx.__tag.trace.log("RAW CONTENT"..tostring(ltx.__tag.mc[mccnt]["actualtext"]),3)
+         dict= dict .. " " .. ltx.__tag.mc[mccnt]["actualtext"]
+        end
+        box.list = __tag_insert_bdc_node (box.list,n,tag, dict)
+        ltx.__tag.func.store_mc_kid (mccnt,mcpagecnt,abspage)
+        ltx.__tag.func.store_mc_in_page(mccnt,mcpagecnt,abspage)
+        ltx.__tag.trace.show_mc_data (mccnt)
+       end
        mcopen = mcopen + 1
       else
-       uftag.trace.log("THIS HAS NOT BEEN TAGGED",1)
-     -- perhaps code that tag a artifact can be added ...  
+       ltx.__tag.trace.log("THIS HAS NOT BEEN TAGGED",1)
+     -- perhaps code that tag a artifact can be added ...
        if tagunmarkedbool.mode == truebool.mode then
-        box.list = __uftag_insert_bmc_node (box.list,n,"Artifact")
-       end 
-       mcopen = mcopen + 1
+        box.list = __tag_insert_bmc_node (box.list,n,"Artifact")
+        mcopen = mcopen + 1
+       end
       end
       mccntprev = mccnt
-     end  
+     end
     end -- end if
   end -- end for
   if head then
-    mccnthead, mctypehead,taghead = __uftag_get_mc_cnt_type_tag (head)
-    uftag.trace.log ("ENDHEAD " .. node.type(node.getid(head)).. " MC"..tostring(mccnthead).." => TAG "..tostring(mctypehead).." => "..tostring(taghead),3) 
+    mccnthead, mctypehead,taghead = __tag_get_mc_cnt_type_tag (head)
+    ltx.__tag.trace.log ("ENDHEAD " .. node.type(node.getid(head)).. " MC"..tostring(mccnthead).." => TAG "..tostring(mctypehead).." => "..tostring(taghead),3)
   else
-    uftag.trace.log ("ENDHEAD is ".. tostring(head),3)
-  end  
-  uftag.trace.log ("QUITTING TRAVERSING BOX ".. tostring(name).." TYPE ".. node.type(node.getid(box)),3)
+    ltx.__tag.trace.log ("ENDHEAD is ".. tostring(head),3)
+  end
+  ltx.__tag.trace.log ("QUITTING TRAVERSING BOX ".. tostring(name).." TYPE ".. node.type(node.getid(box)),3)
  return mcopen,mcpagecnt,mccntprev,mctypeprev
-end 
+end
 
-function uftag.func.mark_shipout ()
- mcopen = uftag.func.mark_page_elements (tex.box["AtBeginShipoutBox"],-1,-100,0,"Shipout",-1)
+function ltx.__tag.func.mark_shipout (box)
+ mcopen = ltx.__tag.func.mark_page_elements (box,-1,-100,0,"Shipout",-1)
  if mcopen~=0 then -- there is a chunk open, close it (hope there is only one ...
   local emcnode = nodenew("whatsit","pdf_literal")
-  local box = tex.box["AtBeginShipoutBox"].list 
+  local list = box.list
   emcnode.data = "EMC"
   emcnode.mode=1
-  if box then
-     box = node.insert_after (box,node.tail(box),emcnode)
+  if list then
+     list = node.insert_after (list,node.tail(list),emcnode)
      mcopen = mcopen - 1
-     uftag.trace.log ("INSERT LAST EMC, MCOPEN = " .. mcopen,2)
+     ltx.__tag.trace.log ("INSERT LAST EMC, MCOPEN = " .. mcopen,2)
   else
-     uftag.trace.log ("UPS ",1)
+     ltx.__tag.trace.log ("UPS ",1)
   end
   if mcopen ~=0 then
-     uftag.trace.log ("!WARNING! open mc" .. " MCOPEN = " .. mcopen,1)
-  end 
+     ltx.__tag.trace.log ("!WARNING! open mc" .. " MCOPEN = " .. mcopen,1)
+  end
  end
 end
 
-function uftag.trace.show_seq (seq)
+function ltx.__tag.trace.show_seq (seq)
  if (type(seq) == "table") then
-  for i,v in ipairs(seq) do 
-   __uftag_log ("[" .. i .. "] => " .. tostring(v),1)
-  end 
-  else 
-   __uftag_log ("sequence " .. tostring(seq) .. " not found",1)   
-  end  
-end 
+  for i,v in ipairs(seq) do
+   __tag_log ("[" .. i .. "] => " .. tostring(v),1)
+  end
+  else
+   __tag_log ("sequence " .. tostring(seq) .. " not found",1)
+  end
+end
 
-local __uftag_pairs_prop =
+local __tag_pairs_prop =
  function  (prop)
       local a = {}
       for n in pairs(prop) do tableinsert(a, n) end
@@ -433,42 +449,40 @@
       return iter
   end
 
-
-function uftag.trace.show_prop (prop)
+function ltx.__tag.trace.show_prop (prop)
  if (type(prop) == "table") then
-  for i,v in __uftag_pairs_prop (prop) do
-    __uftag_log ("[" .. i .. "] => " .. tostring(v),1)
-  end 
- else 
-   __uftag_log ("prop " .. tostring(prop) .. " not found or not a table",1)
- end 
- end 
+  for i,v in __tag_pairs_prop (prop) do
+    __tag_log ("[" .. i .. "] => " .. tostring(v),1)
+  end
+ else
+   __tag_log ("prop " .. tostring(prop) .. " not found or not a table",1)
+ end
+ end
 
-
-local __uftag_get_num_from =  
+local __tag_get_num_from =
  function (tag)
-  if uftag.tables["g__uftag_role_tags_prop"][tag] then
-    a= uftag.tables["g__uftag_role_tags_prop"][tag]
+  if ltx.__tag.tables["g__tag_role_tags_prop"][tag] then
+    a= ltx.__tag.tables["g__tag_role_tags_prop"][tag]
   else
-    a= -1 
+    a= -1
   end
-  return a 
- end     
- 
-uftag.func.get_num_from = __uftag_get_num_from
+  return a
+ end
 
-function uftag.func.output_num_from (tag)
-  local num = __uftag_get_num_from (tag)
+ltx.__tag.func.get_num_from = __tag_get_num_from
+
+function ltx.__tag.func.output_num_from (tag)
+  local num = __tag_get_num_from (tag)
   tex.sprint(catlatex,num)
   if num == -1 then
-   __uftag_log ("Unknown tag "..tag.." used")
+   __tag_log ("Unknown tag "..tag.." used")
   end
-end     
- 
-local __uftag_get_tag_from =
+end
+
+local __tag_get_tag_from =
  function  (num)
-  if uftag.tables["g__uftag_role_tags_seq"][num] then
-   a = uftag.tables["g__uftag_role_tags_seq"][num]
+  if ltx.__tag.tables["g__tag_role_tags_seq"][num] then
+   a = ltx.__tag.tables["g__tag_role_tags_seq"][num]
   else
    a= "UNKNOWN"
   end
@@ -475,159 +489,162 @@
  return a
 end
 
-uftag.func.get_tag_from = __uftag_get_tag_from
+ltx.__tag.func.get_tag_from = __tag_get_tag_from
 
-function uftag.func.output_tag_from (num)
-  tex.sprint(catlatex,__uftag_get_tag_from (num))
-end   
+function ltx.__tag.func.output_tag_from (num)
+  tex.sprint(catlatex,__tag_get_tag_from (num))
+end
 
-function uftag.func.store_mc_data (num,key,data)
- uftag.mc[num] = uftag.mc[num] or { }
- uftag.mc[num][key] = data
- __uftag_log  ("storing mc"..num..": "..tostring(key).."=>"..tostring(data))
+function ltx.__tag.func.store_mc_data (num,key,data)
+ ltx.__tag.mc[num] = ltx.__tag.mc[num] or { }
+ ltx.__tag.mc[num][key] = data
+ __tag_log  ("storing mc"..num..": "..tostring(key).."=>"..tostring(data))
 end
 
-function uftag.trace.show_mc_data (num)
- if uftag and uftag.mc and uftag.mc[num] then
-  for k,v in pairs(uftag.mc[num]) do
-   __uftag_log  ("mc"..num..": "..tostring(k).."=>"..tostring(v),3)
+function ltx.__tag.trace.show_mc_data (num)
+ if ltx.__tag and ltx.__tag.mc and ltx.__tag.mc[num] then
+  for k,v in pairs(ltx.__tag.mc[num]) do
+   __tag_log  ("mc"..num..": "..tostring(k).."=>"..tostring(v),3)
   end
-  if uftag.mc[num]["kids"] then
-  __uftag_log ("mc" .. num .. " has " .. #uftag.mc[num]["kids"] .. " kids",3)
-   for k,v in ipairs(uftag.mc[num]["kids"]) do
-    __uftag_log ("mc ".. num .. " kid "..k.." =>" .. v.kid.." on page " ..v.page,3)
+  if ltx.__tag.mc[num]["kids"] then
+  __tag_log ("mc" .. num .. " has " .. #ltx.__tag.mc[num]["kids"] .. " kids",3)
+   for k,v in ipairs(ltx.__tag.mc[num]["kids"]) do
+    __tag_log ("mc ".. num .. " kid "..k.." =>" .. v.kid.." on page " ..v.page,3)
    end
   end
  else
-  __uftag_log  ("mc"..num.." not found",3)   
+  __tag_log  ("mc"..num.." not found",3)
  end
 end
 
-function uftag.trace.show_all_mc_data (max)
- for i = 1, max do 
-  uftag.trace.show_mc_data (i)
+function ltx.__tag.trace.show_all_mc_data (max)
+ for i = 1, max do
+  ltx.__tag.trace.show_mc_data (i)
  end
-end 
+end
 
-
-function uftag.func.store_mc_label (label,num)
- uftag.mc["labels"] = uftag.mc["labels"] or { }
- uftag.mc.labels[label] = num
+function ltx.__tag.func.store_mc_label (label,num)
+ ltx.__tag.mc["labels"] = ltx.__tag.mc["labels"] or { }
+ ltx.__tag.mc.labels[label] = num
 end
 
-function uftag.func.store_mc_kid (mcnum,kid,page)
- uftag.trace.log("MC"..mcnum.." STORING KID" .. kid.." on page " .. page,3)
- uftag.mc[mcnum]["kids"] = uftag.mc[mcnum]["kids"] or { }
+function ltx.__tag.func.store_mc_kid (mcnum,kid,page)
+ ltx.__tag.trace.log("MC"..mcnum.." STORING KID" .. kid.." on page " .. page,3)
+ ltx.__tag.mc[mcnum]["kids"] = ltx.__tag.mc[mcnum]["kids"] or { }
  local kidtable = {kid=kid,page=page}
- tableinsert(uftag.mc[mcnum]["kids"], kidtable )
+ tableinsert(ltx.__tag.mc[mcnum]["kids"], kidtable )
 end
 
-
-function uftag.func.mc_num_of_kids (mcnum)
+function ltx.__tag.func.mc_num_of_kids (mcnum)
  local num = 0
- if uftag.mc[mcnum] and uftag.mc[mcnum]["kids"] then
-   num = #uftag.mc[mcnum]["kids"]
+ if ltx.__tag.mc[mcnum] and ltx.__tag.mc[mcnum]["kids"] then
+   num = #ltx.__tag.mc[mcnum]["kids"]
  end
- uftag.trace.log ("MC" .. mcnum .. "has " .. num .. "KIDS",4)
+ ltx.__tag.trace.log ("MC" .. mcnum .. "has " .. num .. "KIDS",4)
  return num
 end
-  
-function uftag.func.mc_insert_kids (mcnum,single)
-  if uftag.mc[mcnum] then
-  uftag.trace.log("MC-KIDS test " .. mcnum,4)
-   if uftag.mc[mcnum]["kids"] then
-    if #uftag.mc[mcnum]["kids"] > 1 and single==1 then
+
+function ltx.__tag.func.mc_insert_kids (mcnum,single)
+  if ltx.__tag.mc[mcnum] then
+  ltx.__tag.trace.log("MC-KIDS test " .. mcnum,4)
+   if ltx.__tag.mc[mcnum]["kids"] then
+    if #ltx.__tag.mc[mcnum]["kids"] > 1 and single==1 then
      tex.sprint("[")
-    end 
-    for i,kidstable in ipairs( uftag.mc[mcnum]["kids"] ) do
+    end
+    for i,kidstable in ipairs( ltx.__tag.mc[mcnum]["kids"] ) do
      local kidnum  = kidstable["kid"]
      local kidpage = kidstable["page"]
      local kidpageobjnum = pdfpageref(kidpage)
-     uftag.trace.log("MC" .. mcnum .. " insert KID " ..i.. " with num " .. kidnum .. " on page " .. kidpage.."/"..kidpageobjnum,3)
+     ltx.__tag.trace.log("MC" .. mcnum .. " insert KID " ..i.. " with num " .. kidnum .. " on page " .. kidpage.."/"..kidpageobjnum,3)
      tex.sprint(catlatex,"<</Type /MCR /Pg "..kidpageobjnum .. " 0 R /MCID "..kidnum.. ">> " )
-    end 
-    if #uftag.mc[mcnum]["kids"] > 1 and single==1 then
+    end
+    if #ltx.__tag.mc[mcnum]["kids"] > 1 and single==1 then
      tex.sprint("]")
-    end  
+    end
    else
-    uftag.trace.log("WARN! MC"..mcnum.." has no kids",0)
+    ltx.__tag.trace.log("WARN! MC"..mcnum.." has no kids",0)
+    if single==1 then
+      tex.sprint("null")
+    end
    end
   else
-   uftag.trace.log("WARN! MC"..mcnum.." doesn't exist",0)
+   ltx.__tag.trace.log("WARN! MC"..mcnum.." doesn't exist",0)
   end
 end
 
-
-function uftag.func.store_struct_mcabs (structnum,mcnum)
- uftag.struct[structnum]=uftag.struct[structnum] or { }
- uftag.struct[structnum]["mc"]=uftag.struct[structnum]["mc"] or { }
+function ltx.__tag.func.store_struct_mcabs (structnum,mcnum)
+ ltx.__tag.struct[structnum]=ltx.__tag.struct[structnum] or { }
+ ltx.__tag.struct[structnum]["mc"]=ltx.__tag.struct[structnum]["mc"] or { }
  -- a structure can contain more than on mc chunk, the content should be ordered
- tableinsert(uftag.struct[structnum]["mc"],mcnum)
- uftag.trace.log("MCNUM "..mcnum.." insert in struct "..structnum,3)
+ tableinsert(ltx.__tag.struct[structnum]["mc"],mcnum)
+ ltx.__tag.trace.log("MCNUM "..mcnum.." insert in struct "..structnum,3)
  -- but every mc can only be in one structure
- uftag.mc[mcnum]= uftag.mc[mcnum] or { }
- uftag.mc[mcnum]["parent"] = structnum 
-end  
+ ltx.__tag.mc[mcnum]= ltx.__tag.mc[mcnum] or { }
+ ltx.__tag.mc[mcnum]["parent"] = structnum
+end
 
-function uftag.trace.show_struct_data (num)
- if uftag and uftag.struct and uftag.struct[num] then
-  for k,v in ipairs(uftag.struct[num]) do
-   __uftag_log  ("struct "..num..": "..tostring(k).."=>"..tostring(v))
+function ltx.__tag.trace.show_struct_data (num)
+ if ltx.__tag and ltx.__tag.struct and ltx.__tag.struct[num] then
+  for k,v in ipairs(ltx.__tag.struct[num]) do
+   __tag_log  ("struct "..num..": "..tostring(k).."=>"..tostring(v))
   end
- else 
-  __uftag_log   ("struct "..num.." not found ") 
- end 
+ else
+  __tag_log   ("struct "..num.." not found ")
+ end
 end
 
 -- pay attention: lua counts arrays from 1, tex pages from one
--- mcid and arrays in pdf count from 0. 
-function uftag.func.store_mc_in_page (mcnum,mcpagecnt,page)
- uftag.page[page] = uftag.page[page] or {}
- uftag.page[page][mcpagecnt] = mcnum 
- uftag.trace.log("PAGE " .. page .. ": inserting MCID " .. mcpagecnt .. " => " .. mcnum,3)
+-- mcid and arrays in pdf count from 0.
+function ltx.__tag.func.store_mc_in_page (mcnum,mcpagecnt,page)
+ ltx.__tag.page[page] = ltx.__tag.page[page] or {}
+ ltx.__tag.page[page][mcpagecnt] = mcnum
+ ltx.__tag.trace.log("PAGE " .. page .. ": inserting MCID " .. mcpagecnt .. " => " .. mcnum,3)
 end
 
-function uftag.func.fill_parent_tree_line (page)
-     -- we need to get page-> i=kid -> mcnum -> structnum 
+function ltx.__tag.func.fill_parent_tree_line (page)
+     -- we need to get page-> i=kid -> mcnum -> structnum
      -- pay attention: the kid numbers and the page number in the parent tree start with 0!
     local numsentry =""
     local pdfpage = page-1
-    if uftag.page[page] and uftag.page[page][0] then
-     mcchunks=#uftag.page[page] 
-     uftag.trace.log("PAGETREE PAGE "..page.." has "..mcchunks.."+1 Elements ",3)  
+    if ltx.__tag.page[page] and ltx.__tag.page[page][0] then
+     mcchunks=#ltx.__tag.page[page]
+     ltx.__tag.trace.log("PAGETREE PAGE "..page.." has "..mcchunks.."+1 Elements ",3)
      for i=0,mcchunks do
-      uftag.trace.log("PAGETREE CHUNKS "..uftag.page[page][i],3)        
+      ltx.__tag.trace.log("PAGETREE CHUNKS "..ltx.__tag.page[page][i],3)
      end
-     if mcchunks == 0 then 
+     if mcchunks == 0 then
       -- only one chunk so no need for an array
-      local mcnum  = uftag.page[page][0] 
-      local structnum = uftag.mc[mcnum]["parent"]
-      local propname  = "g__uftag_struct_"..structnum.."_prop"
-      local objnum   =  uftag.tables[propname]["objnum"] or "XXXX"
-       texio.write_nl("=====>"..tostring(objnum))
-      numsentry = pdfpage .. " ".. objnum .. " 0 R"
-      uftag.trace.log("PAGETREE PAGE" .. page.. " NUM ENTRY = ".. numsentry,3)
+      local mcnum  = ltx.__tag.page[page][0]
+      local structnum = ltx.__tag.mc[mcnum]["parent"]
+      local propname  = "g__tag_struct_"..structnum.."_prop"
+      local objref   =  ltx.__tag.tables[propname]["objref"] or "XXXX"
+       texio.write_nl("=====>"..tostring(objref))
+      numsentry = pdfpage .. " [".. objref .. "]"
+      ltx.__tag.trace.log("PAGETREE PAGE" .. page.. " NUM ENTRY = ".. numsentry,3)
      else
       numsentry = pdfpage .. " ["
        for i=0,mcchunks do
-        local mcnum  = uftag.page[page][i]
-        local structnum = uftag.mc[mcnum]["parent"] or 0
-        local propname  = "g__uftag_struct_"..structnum.."_prop"
-        local objnum   =  uftag.tables[propname]["objnum"] or "XXXX"
-        numsentry = numsentry .. " ".. objnum .. " 0 R"
+        local mcnum  = ltx.__tag.page[page][i]
+        local structnum = ltx.__tag.mc[mcnum]["parent"] or 0
+        local propname  = "g__tag_struct_"..structnum.."_prop"
+        local objref   =  ltx.__tag.tables[propname]["objref"] or "XXXX"
+        numsentry = numsentry .. " ".. objref
        end
       numsentry = numsentry .. "] "
-      uftag.trace.log("PAGETREE PAGE" .. page.. " NUM ENTRY = ".. numsentry,3)
-     end  
+      ltx.__tag.trace.log("PAGETREE PAGE" .. page.. " NUM ENTRY = ".. numsentry,3)
+     end
     else
-      uftag.trace.log ("PAGETREE: NO DATA FOR PAGE "..page,3)
+      ltx.__tag.trace.log ("PAGETREE: NO DATA FOR PAGE "..page,3)
     end
-    return numsentry 
+    return numsentry
 end
 
-function uftag.func.output_parenttree (abspage)
+function ltx.__tag.func.output_parenttree (abspage)
  for i=1,abspage do
-  line = uftag.func.fill_parent_tree_line (i) .. "^^J"
+  line = ltx.__tag.func.fill_parent_tree_line (i) .. "^^J"
   tex.sprint(catlatex,line)
  end
 end
+
+-- 
+--  End of File `tagpdf.lua'.

Modified: trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,180 +1,248 @@
-\RequirePackage{expl3}[2019/07/01]
-%\RequirePackage[enable-debug]{expl3}[2018/06/14]
+%%
+%% This is file `tagpdf.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% tagpdf.dtx  (with options: `package')
+%% 
+%% Copyright (C) 2019 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} {2021/02/23} {0.80}
+  { A package to experiment with pdf tagging }
 
-\ProvidesExplPackage {tagpdf} {2019/07/02} {0.61}
- {A package to experiment with pdf tagging}
-%\debug_on:n{check-declarations,check-expressions,deprecation}
+\bool_if:nF
+  {
+    \bool_lazy_and_p:nn
+      {\cs_if_exist_p:N \pdfmanagement_if_active_p:}
+      { \pdfmanagement_if_active_p: }
+  }
+  {  %error for now, perhaps warning later.
+    \PackageError{tagpdf}
+     {
+       PDF~resource~management~is~no~active!\MessageBreak
+       tagpdf~will~no~work.
+     }
+     {
+       Activate~it~with \MessageBreak
+       \string\RequirePackage{pdfmanagement-testphase}\MessageBreak
+       \string\DeclareDocumentMetadata{<options>}\MessageBreak
+       before~\string\documentclass
+     }
+  }
 
-%map internal tag to package name
+
 \prop_if_exist:NT \g_msg_module_name_prop
- {
-  \prop_gput:Nnn \g_msg_module_name_prop { uftag }{ tagpdf }
- }
+  {
+    \prop_gput:Nnn \g_msg_module_name_prop { tag }{ tagpdf }
+  }
 
-% storing internal names to my name space:
-\cs_set_eq:NN \__uftag_tex_pdffeedback:D         \tex_pdffeedback:D
-\cs_set_eq:NN \__uftag_tex_pdfextension:D        \tex_pdfextension:D
-\cs_set_eq:NN \__uftag_tex_immediate:D           \tex_immediate:D
-\cs_set_eq:NN \__uftag_tex_pdfvariable:D         \tex_pdfvariable:D
-\cs_set_eq:NN \__uftag_tex_global:D              \tex_global:D
-\cs_set_eq:NN \__uftag_tex_the:D                 \tex_the:D
-\cs_set_eq:NN \__uftag_tex_pdfliteral:D          \tex_pdfliteral:D
-\cs_set_eq:NN \__uftag_tex_pdfcatalog:D          \tex_pdfcatalog:D
-\cs_set_eq:NN \__uftag_tex_pdflastobj:D          \tex_pdflastobj:D
-\cs_set_eq:NN \__uftag_tex_pdfobj:D              \tex_pdfobj:D
-\cs_set_eq:NN \__uftag_tex_pdfpageattr:D         \tex_pdfpageattr:D
-\cs_set_eq:NN \__uftag_tex_pdfpagesattr:D        \tex_pdfpagesattr:D
-\cs_set_eq:NN \__uftag_tex_pdfpageref:D          \tex_pdfpageref:D
-\cs_set_eq:NN \__uftag_tex_pdfcompresslevel:D    \tex_pdfcompresslevel:D
-\cs_set_eq:NN \__uftag_tex_pdfobjcompresslevel:D \tex_pdfobjcompresslevel:D
+\cs_set_eq:NN \__tag_tex_global:D              \tex_global:D
 
 %%% package options
-\bool_new:N\g__uftag_mode_lua_bool
+\bool_new:N\g__tag_mode_lua_bool
 
-\DeclareOption{luamode}    { \sys_if_engine_luatex:T { \bool_gset_true:N \g__uftag_mode_lua_bool } }
-\DeclareOption{genericmode}{ \bool_gset_false:N\g__uftag_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 }
 \ExecuteOptions{luamode}
 \ProcessOptions
 
 %%% some packages
-\RequirePackage{xparse}
-\RequirePackage{atbegshi}
-\RequirePackage{zref-base,zref-lastpage}
-\RequirePackage{etoolbox}
-\RequirePackage{l3pdf}
-%\RequirePackage{pdfescape} %check if needed
-%\RequirePackage{pdftexcmds}%check if needed (expandable commands!)
+\RequirePackage{l3ref-tmp}
+ %================
+ % temporary code
+ % ===============
+ % faking the LastPage label:
+ \cs_new_protected:Npn \__tag_lastpagelabel:
+   {
+     \legacy_if:nT { @filesw }
+       {
+         \exp_args:NNnx \exp_args:NNx\iow_now:Nn \@auxout
+            {
+              \token_to_str:N \newlabeldata
+                {__tag_LastPage}
+                {
+                  {abspage} { \int_use:N \g_shipout_readonly_int}
+                  {tagmcabs}{ \int_use:N \c at g__tag_MCID_abs_int }
+                }
+            }
+       }
+   }
 
-%\RequirePackage{l3str-convert}
-\cs_generate_variant:Nn \str_set_convert:Nnnn {Nonn, Noon, Nnon }
+ \AddToHook{enddocument/afterlastpage}
+  {\__tag_lastpagelabel:}
 
+ % a command to override the general default. See issue in ref
+ \cs_if_exist:NF \ref_value:nnn
+   {
+     \cs_new:Npn \ref_value:nnn #1#2#3
+       {
+         \exp_args:Nee
+           \__ref_value:nnn
+            { \tl_to_str:n {#1} } { \tl_to_str:n {#2} } {#3}
+       }
+     \cs_new:Npn \__ref_value:nnn #1#2#3
+       {
+         \tl_if_exist:cTF { g__ref_label_ #1 _ #2 _tl }
+           { \tl_use:c { g__ref_label_ #1 _ #2 _tl } }
+           {
+             % test if attribute exist at all?
+             #3
+           }
+       }
+   }
 
-%%% absolute page numbers
-\int_new:N   \g__uftag_abspage_int
-\int_gset:Nn \g__uftag_abspage_int { 0 }
-\zref at newlist {uftagzrl} %zrl=zreflist
-\zref at newprop*{tagabspage}     [0] { \int_use:N \g__uftag_abspage_int }
-\zref at addprop {uftagzrl} {tagabspage}
+ %=============
+ % attributes
+ %=============
+\ref_attribute_gset:nnnn {tagstruct}    {0}{now}    { \int_use:N \c at g__tag_struct_abs_int }
+\ref_attribute_gset:nnnn {tagstructobj} {}{now}
+ {
+  \exp_args:Ne
+   \pdf_object_if_exist:nT {c__tag_struct_ \int_use:N \c at g__tag_struct_abs_int _obj}
+    {
+      \pdf_object_ref:e{c__tag_struct_ \int_use:N \c at g__tag_struct_abs_int _obj}
+    }
+ }
+ % replace by abspage??
+\ref_attribute_gset:nnnn {tagabspage}{0}{shipout}{ \int_use:N \g_shipout_readonly_int }
+\ref_attribute_gset:nnnn {tagmcabs } {0}{now}    { \int_use:N \c at g__tag_MCID_abs_int }
+\ref_attribute_gset:nnnn {tagmcid }  {0}{now}    { \int_use:N \g__tag_MCID_tmp_bypage_int }
+\clist_const:Nn \c__tag_refmc_clist     {tagabspage,tagmcabs,tagmcid} %mc is new!!
+\clist_const:Nn \c__tag_refstruct_clist {tagstruct,tagstructobj}
+\cs_generate_variant:Nn \ref_label:nn { nv }
+\cs_new_protected:Npn \__tag_ref_label:nn #1 #2 %#1 label, #2 name of list mc or struct
+  {
+    \@bsphack
+    \ref_label:nv {#1}{c__tag_ref#2_clist}
+    \@esphack
+  }
+\cs_new:Npn \__tag_ref_value:nnn #1 #2 #3 %#1 label, #2 attribute, #3 default
+  {
+    \ref_value:nnn {#1}{#2}{#3}
+  }
+\cs_new:Npn \__tag_ref_value_lastpage:nn #1 #2
+  {
+    \ref_value:nnn {__tag_LastPage}{#1}{#2}
+  }
 
+\cs_generate_variant:Nn \__tag_ref_label:nn {en}
+\cs_generate_variant:Nn \__tag_ref_value:nnn {enn}
 
+\RequirePackage{etoolbox}
+
+\cs_generate_variant:Nn \str_set_convert:Nnnn {Nonn, Noon, Nnon }
+
 %%% tagpdfsetup,
 %%% TODO: checks need to be improved
-\int_new:N  \l__uftag_loglevel_int
-\tl_new:N   \l__uftag_tree_tabs_order_tl
+\int_new:N  \l__tag_loglevel_int
+\tl_new:N   \l__tag_tree_tabs_order_tl
 
-\keys_define:nn { uftag / setup }
-{
- activate-mc     .bool_gset:N = \g_uftag_active_mc_bool,
- activate-tree   .bool_gset:N = \g_uftag_active_tree_bool,
- activate-struct .bool_gset:N = \g_uftag_active_struct_bool,
- activate-all    .meta:n ={activate-mc,activate-tree,activate-struct},
- check-tags      .bool_gset:N = \g__uftag_check_tags_bool,
- check-tags      .initial:n  = true,
- log             .choice:,
- log / none      .code:n = {\int_set:Nn \l__uftag_loglevel_int { 0 }},
- log / v         .code:n = {\int_set:Nn \l__uftag_loglevel_int { 1 }},
- log / vv        .code:n = {\int_set:Nn \l__uftag_loglevel_int { 2 }},
- log / vvv       .code:n = {\int_set:Nn \l__uftag_loglevel_int { 3 }},
- log / all       .code:n = {\int_set:Nn \l__uftag_loglevel_int { 10 }},
- tagunmarked     .bool_gset:N = \g__uftag_tagunmarked_bool,
- tagunmarked     .initial:n  = true,
- tabsorder       .choice:,
- tabsorder / row       .code:n = {\tl_set:Nn \l__uftag_tree_tabs_order_tl {/Tabs/R}},
- tabsorder / column    .code:n = {\tl_set:Nn \l__uftag_tree_tabs_order_tl {/Tabs/C}},
- tabsorder / structure .code:n = {\tl_set:Nn \l__uftag_tree_tabs_order_tl {/Tabs/S}},
- tabsorder / none      .code:n = {\tl_set:Nn \l__uftag_tree_tabs_order_tl {}},
- tabsorder       .initial:n = structure,
- uncompress     .code:n = {\pdf_uncompress:  },
- inputencoding  .code:n =
+\keys_define:nn { __tag / setup }
   {
-   \sys_if_engine_pdftex:T
-    { \tl_gset:Nn \g__uftag_inputencoding_tl { #1 } }
-  },
-}
+    activate-mc     .bool_gset:N = \g__tag_active_mc_bool,
+    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},
+    check-tags      .bool_gset:N = \g__tag_check_tags_bool,
+    check-tags      .initial:n  = true,
+    log             .choice:,
+    log / none      .code:n = {\int_set:Nn \l__tag_loglevel_int { 0 }},
+    log / v         .code:n = {\int_set:Nn \l__tag_loglevel_int { 1 }},
+    log / vv        .code:n = {\int_set:Nn \l__tag_loglevel_int { 2 }},
+    log / vvv       .code:n = {\int_set:Nn \l__tag_loglevel_int { 3 }},
+    log / all       .code:n = {\int_set:Nn \l__tag_loglevel_int { 10 }},
+    tagunmarked     .bool_gset:N = \g__tag_tagunmarked_bool,
+    tagunmarked     .initial:n  = true,
+    tabsorder       .choice:,
+    tabsorder / row       .code:n = %{\tl_set:Nn \l__tag_tree_tabs_order_tl {/Tabs/R}},
+      \pdfmanagement_add:nnn { Page } {Tabs}{/R},
+    tabsorder / column    .code:n = %{\tl_set:Nn \l__tag_tree_tabs_order_tl {/Tabs/C}},
+      \pdfmanagement_add:nnn { Page } {Tabs}{/C},
+    tabsorder / structure .code:n = %{\tl_set:Nn \l__tag_tree_tabs_order_tl {/Tabs/S}},
+      \pdfmanagement_add:nnn { Page } {Tabs}{/S},
+    tabsorder / none      .code:n = %{\tl_set:Nn \l__tag_tree_tabs_order_tl {}},
+      \pdfmanagement_remove:nn {Page} {Tabs},
+    tabsorder       .initial:n = structure,
+    uncompress      .code:n = {\pdf_uncompress:  },
+  }
+\hook_gput_code:nnn{begindocument}{tagpdf}
+  {
+    \bool_if:NT \g__tag_active_struct_bool
+      {
+         \pdfmanagement_add:nnn { Catalog / MarkInfo } { Marked } { true }
+      }
+  }
 
-% escape commands are a bit engine specific so have been moved to the backend files.
-% commands to escape strings so that they can be safely used in pdf
-% currently not much used. But will be needed later, when alt and actualtext are added.
-% we probably need the equivalent \pdfescapestring, \pdfescapename \pdfescapehex
-% the commands of pdfescape adds an additional layout to allow for babel shorthands
-%\cs_set_eq:NN \__uftag_pdf_escape_string:Nn \EdefEscapeString
-%\cs_set_eq:NN \__uftag_pdf_escape_name:Nn   \EdefEscapeName
-%\cs_set_eq:NN \__uftag_pdf_escape_hex:Nn    \EdefEscapeHex
 
-%\cs_set_eq:NN \__uftag_pdf_escape_string:n \EdefEscapeString
-%\cs_set_eq:NN \__uftag_pdf_escape_name:Nn   \EdefEscapeName
 
-%escape command. They are backend specific as \pdf at escapehex would ignore most chars
-%outside the "pdflatex" range
+\cs_new:Nn   \__tag_finish_page_hook: { }
 
 
+\hook_gput_code:nnn
+  { shipout/before }
+  { tagpdf/cnt }
+  {
+    \__tag_finish_page_hook:
+    %\int_gincr:N \g__tag_abspage_int
+  }
 
-
-
-% a hook for later code and an absolute page counter
-% should be executed before counters are resetted.
-% is it used?
-\cs_new:Nn   \__uftag_finish_page_hook: { }
-
-\AtBeginShipout
- {
-  \__uftag_finish_page_hook:
-  \bool_if:NT\g_uftag_active_tree_bool
-   {
-     \__uftag_tree_write_pageattr:
-   }
-  \int_gincr:N \g__uftag_abspage_int
- }
-
-
-%testing the engines and loading the backend files
 \sys_if_engine_xetex:T
- {
-  \PackageError { tagpdf } { xelatex~is~not~supported~-~aborting } {}
-  \tex_endinput:D
- }
+  { %lets try with xelatex ...
+    %\PackageError { tagpdf } { xelatex~is~not~supported~-~aborting } {}
+    %\tex_endinput:D
+    \file_input:n {tagpdf-pdftex.def}
+  }
 
 \sys_if_engine_luatex:T
- {
-  \file_input:n {tagpdf-luatex.def}
- }
+  {
+    \file_input:n {tagpdf-luatex.def}
+  }
 
 \sys_if_engine_pdftex:T
- {
-  \file_input:n {tagpdf-pdftex.def}
- }
+  {
+    \file_input:n {tagpdf-pdftex.def}
+  }
 
 \sys_if_output_dvi:T
- {
-  \PackageError { tagpdf } { dvi~output~is~not~supported~-~aborting }{}
-  \tex_endinput:D
- }
+  {
+    %\PackageError { tagpdf } { dvi~output~is~not~supported~-~aborting }{}
+    %\tex_endinput:D
+  }
 
-\cs_generate_variant:Nn \__uftag_prop_gput:Nnn      { Nxn , Nxx, Nnx , cnn, cxn, cnx, cno}
-\cs_generate_variant:Nn \__uftag_seq_gput_right:Nn  { Nx  , No, cn, cx }
-\cs_generate_variant:Nn \__uftag_prop_new:N   { c }
-\cs_generate_variant:Nn \__uftag_seq_new:N    { c }
-\cs_generate_variant:Nn \__uftag_seq_show:N   { c }
-\cs_generate_variant:Nn \__uftag_prop_show:N  { c }
+\cs_generate_variant:Nn \__tag_prop_gput:Nnn      { Nxn , Nxx, Nnx , cnn, cxn, cnx, cno}
+\cs_generate_variant:Nn \__tag_seq_gput_right:Nn  { Nx  , No, cn, cx }
+\cs_generate_variant:Nn \__tag_prop_new:N   { c }
+\cs_generate_variant:Nn \__tag_seq_new:N    { c }
+\cs_generate_variant:Nn \__tag_seq_show:N   { c }
+\cs_generate_variant:Nn \__tag_prop_show:N  { c }
 \cs_generate_variant:Nn \prop_gput:Nnn {Nxx}
 \cs_generate_variant:Nn \prop_put:Nnn  {Nxx}
-\cs_generate_variant:Nn \__uftag_pdfuseobjnum:Nn {Nx,No}
-\cs_generate_variant:Nn \__uftag_pdfuseobjnum:nn {nx,xx}
-\cs_generate_variant:Nn \__uftag_gset_pdfpageattr:n {x}
 
-% few temp tl
-\tl_new:N \g__uftag_tmpa_tl
-\tl_new:N \l__uftag_tmpa_tl
-\tl_new:N \l__uftag_tmpb_tl
-\tl_new:N \l__uftag_tmpc_tl
-\tl_new:N \l__uftag_tmpd_tl
-\tl_new:N \l__uftag_tmpe_tl
-\str_new:N \l__uftag_tmpa_str
+\cs_generate_variant:Nn \pdffile_embed_stream:nnn {nxx,oxx}
+\cs_generate_variant:Nn \pdf_object_ref:n {e}
 
-% helper function to get the propcount.
-% use as \prop_map_function:NN PROP { \__uftag_prop_count:nn -1 }
-\cs_new:Nn\__uftag_prop_count:nn { + 1 }
+\tl_new:N \g__tag_tmpa_tl
+\tl_new:N \l__tag_tmpa_tl
+\tl_new:N \l__tag_tmpb_tl
+\tl_new:N \l__tag_tmpc_tl
+\tl_new:N \l__tag_tmpd_tl
+\tl_new:N \l__tag_tmpe_tl
+\str_new:N \l__tag_tmpa_str
 
+\cs_new:Nn\__tag_prop_count:nn { + 1 }
+
 %% Loading the tagpdf sub packages
 \RequirePackage { tagpdf-checks-code }
 \RequirePackage { tagpdf-user }
@@ -181,16 +249,17 @@
 \RequirePackage { tagpdf-tree-code }
 \RequirePackage { tagpdf-roles-code }
 \RequirePackage { tagpdf-attr-code }
-% mc-code is split:
 \RequirePackage { tagpdf-mc-code-shared }
-\bool_if:NTF \g__uftag_mode_lua_bool
- {
-  \RequirePackage {tagpdf-mc-code-lua}
- }
- {
-  \RequirePackage { tagpdf-mc-code-generic } %
- }
+\bool_if:NTF \g__tag_mode_lua_bool
+  {
+   \RequirePackage {tagpdf-mc-code-lua}
+  }
+  {
+   \RequirePackage { tagpdf-mc-code-generic } %
+  }
 
 \RequirePackage { tagpdf-struct-code }
 \RequirePackage { tagpdf-space-code }
-\endinput
+%% 
+%%
+%% 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	2021-02-23 15:38:50 UTC (rev 57856)
+++ trunk/Master/texmf-dist/tex/latex/tagpdf/tagpdfdocu-patches.sty	2021-02-23 22:24:07 UTC (rev 57857)
@@ -1,7 +1,7 @@
 \RequirePackage{expl3}[2018/06/14]
 %\RequirePackage[enable-debug]{expl3}[2018/06/14]
 \RequirePackage{xpatch}
-\ProvidesExplPackage {tagpdfdocu-patches} {2019/07/02} {0.61}
+\ProvidesExplPackage {tagpdfdocu-patches} {2019/10/15} {0.70}
  {patches/commands for the tagpdf documentation}
 
 % to do : marginnote, perhaps the description macros ...
@@ -30,20 +30,20 @@
 
 \NewDocumentCommand\TagP{t{^}}
  {
-  \uftag_mc_if_in:T { \uftag_mc_end: }
+  \tag_mc_if_in:T { \tag_mc_end: }
   \IfBooleanF{#1}
   {
-    \uftag_struct_end:
+    \tag_struct_end:
   }
-  \uftag_struct_begin:n{tag=P}
-  \uftag_mc_begin:n{tag=P}
+  \tag_struct_begin:n{tag=P}
+  \tag_mc_begin:n{tag=P}
  }
 % close a mc and one structure
 
 \NewDocumentCommand\TagPend{}
  {
-  \uftag_mc_if_in:T { \uftag_mc_end: }
-  \uftag_struct_end:
+  \tag_mc_if_in:T { \tag_mc_end: }
+  \tag_struct_end:
  }
 
 
@@ -58,15 +58,15 @@
 
 %Marking the toc entries
 %around the whole entry so only structure:
-\newcommand\tagscrtocentry[1]{\uftag_struct_begin:n{tag=TOCI}#1\uftag_struct_end:}
+\newcommand\tagscrtocentry[1]{\tag_struct_begin:n{tag=TOCI}#1\tag_struct_end:}
 
 %leaf so structure and mc:
 \newcommand\tagscrtocpagenumber[1]{%
- \uftag_struct_begin:n{tag=Reference}%
- \uftag_mc_begin:n{tag=Reference}%
+ \tag_struct_begin:n{tag=Reference}%
+ \tag_mc_begin:n{tag=Reference}%
  #1%
- \uftag_mc_end:
- \uftag_struct_end:}
+ \tag_mc_end:
+ \tag_struct_end:}
 
 
 \DeclareTOCStyleEntry[
@@ -85,9 +85,9 @@
 
 
 \renewcommand{\addtocentrydefault}[3]{%
- \ifstr{#3}{}{}
+ \Ifstr{#3}{}{}
    {%\
-   \ifstr{#2}{}
+   \Ifstr{#2}{}
     {%
      \addcontentsline{toc}{#1}
       {%
@@ -118,7 +118,7 @@
 
 \renewcommand*{\TOCLineLeaderFill}[1][.]{
   \leaders\hbox{$\m at th
-    \mkern \@dotsep mu\hbox{\uftag_mc_begin:n{artifact}#1\uftag_mc_end:}\mkern \@dotsep
+    \mkern \@dotsep mu\hbox{\tag_mc_begin:n{artifact}#1\tag_mc_end:}\mkern \@dotsep
     mu$}\hfill
 }
 
@@ -142,34 +142,34 @@
     \tagstructbegin{tag=\prop_item:Nn\g_tag_section_level_prop{#1}}
     \tl_if_empty:nF{#3}
     {
-     \uftag_mc_begin:n    {tag=\prop_item:Nn\g_tag_section_level_prop{#1}}
+     \tag_mc_begin:n    {tag=\prop_item:Nn\g_tag_section_level_prop{#1}}
      #3
-     \uftag_mc_end:
+     \tag_mc_end:
     }
    }
-   {\uftag_mc_begin:n    {tag=\prop_item:Nn\g_tag_section_level_prop{#1}}
+   {\tag_mc_begin:n    {tag=\prop_item:Nn\g_tag_section_level_prop{#1}}
     #4
-    \uftag_mc_end:\tagstructend}%
+    \tag_mc_end:\tagstructend}%
  }
 
 %minisec is simply P, H6 doesn't work ....
-\cs_new:Nn \__uftag_docu_tag_minisec:n
+\cs_new:Nn \__tag_docu_tag_minisec:n
 {
-  \uftag_struct_begin:n {tag=P}
-  \uftag_mc_begin:n{tag=P}
+  \tag_struct_begin:n {tag=P}
+  \tag_mc_begin:n{tag=P}
   #1
-  \uftag_mc_end:
-  \uftag_struct_end:
+  \tag_mc_end:
+  \tag_struct_end:
 }
 
-\addtokomafont{minisec}{\__uftag_docu_tag_minisec:n}
+\addtokomafont{minisec}{\__tag_docu_tag_minisec:n}
 
-\AfterTOCHead{\uftag_struct_begin:n{tag=TOC}}
-\AfterStartingTOC{\uftag_struct_end:} %end TOC
+\AfterTOCHead{\tag_struct_begin:n{tag=TOC}}
+\AfterStartingTOC{\tag_struct_end:} %end TOC
 
 %% list
 
-\newcommand\uftag at enit@format at preset[1]{%
+\newcommand\tag at enit@format at preset[1]{%
   \tagstructbegin{tag=LI}%
   \tagstructbegin{tag=Lbl}%
   \tagmcbegin{tag=Lbl}%
@@ -190,7 +190,7 @@
 }
 
 \ExplSyntaxOff
-\xpatchcmd\enit at preset{\@firstofone}{\uftag at enit@format at preset}{}{\fail}
+\xpatchcmd\enit at preset{\@firstofone}{\tag at enit@format at preset}{}{\fail}
 \ExplSyntaxOn
 \setlist{
     before*=\tagstructbegin{tag=L},
@@ -209,62 +209,95 @@
  %%% attention, to get the order right, it is necessary currently to start a new
  %%% mc after a link! I'm not sure if this can/group be included in the hooks
  %%% grouping is a bit tricky ...
-\cs_if_exist:NT\hook_put_left:nnn
-{
- \hook_put_left:nnn
- { pdf }
- { link_begin_url }
- {
-   \uftag_struct_begin:n{tag=Link}
-   \uftag_mc_begin:n{tag=Link}
- }
-\hook_put:nnnn
- { pdf }
- { link_begin_url_attr }
- { /StructParent }
- { \int_use:N\c at g__uftag_parenttree_obj_int }
+%\cs_if_exist:NT\hook_put_left:nnn
+%{
+% \hook_put_left:nnn
+% { pdf }
+% { annot/Link/URI_begin }
+% {
+%   \tag_struct_begin:n{tag=Link}
+%   \tag_mc_begin:n{tag=Link}
+% }
 
-\hook_put_right:nnn
- { pdf }
- { link_end_url }
- {
-  \__uftag_struct_finish_link:
-   \uftag_mc_end:
-   \uftag_struct_end:
- }
+\cs_generate_variant:Nn \pdfannot_dict_put:nnn {nnx}
+\hook_gput_code:nnn
+  {pdfannot/link/URI/before}
+  {tagpdf}
+  {
+    \tag_struct_begin:n{tag=Link}
+    \tag_mc_begin:n{tag=Link}
+    \pdfannot_dict_put:nnx
+    {link/URI}
+    { StructParent }
+    { \int_use:N\c at g__tag_parenttree_obj_int }
+  }
 
-\hook_put_left:nnn
- { pdf }
- { link_begin_link }
- {
-   \uftag_struct_begin:n{tag=Link}
-   \uftag_mc_begin:n{tag=Link}
- }
-\hook_put:nnnn
- { pdf }
- { link_begin_link_attr }
- { /StructParent }
- { \int_use:N\c at g__uftag_parenttree_obj_int }
-\hook_put_right:nnn
- { pdf }
- { link_end_link }
- {
-  \__uftag_struct_finish_link:
-  \uftag_mc_end:
-  \uftag_struct_end:
- }
+%\hook_put_right:nnn
+% { pdf }
+% { annot/Link/URI_end }
+% {
+%  \__tag_struct_finish_link:
+%   \tag_mc_end:
+%   \tag_struct_end:
+% }
+\hook_gput_code:nnn
+  {pdfannot/link/URI/after}
+  {tagpdf}
+  {
+    \__tag_struct_finish_link:
+    \tag_mc_end:
+    \tag_struct_end:
+  }
 
+%\hook_put_left:nnn
+% { pdf }
+% { annot/Link/GoTo_begin }
+% {
+%   \tag_struct_begin:n{tag=Link}
+%   \tag_mc_begin:n{tag=Link}
+% }
+
+\hook_gput_code:nnn
+  {pdfannot/link/GoTo/before}
+  {tagpdf}
+  {
+    \tag_struct_begin:n{tag=Link}
+    \tag_mc_begin:n{tag=Link}
+    \pdfannot_dict_put:nnx
+    {link/GoTo}
+    { StructParent }
+    { \int_use:N\c at g__tag_parenttree_obj_int }
+  }
+
+
+
+
+%\hook_put_right:nnn
+% { pdf }
+% { annot/link/GoTo_end }
+% {
+%  \__tag_struct_finish_link:
+%  \tag_mc_end:
+%  \tag_struct_end:
+% }
+
+\hook_gput_code:nnn
+  {pdfannot/link/GoTo/after}
+  {tagpdf}
+  {
+    \__tag_struct_finish_link:
+    \tag_mc_end:
+    \tag_struct_end:
+  }
 % "alternative descriptions " for PAX3. How to get better text here??
-\hook_put:nnnn
- { pdf }
- { link_begin_url_attr }
- { /Contents }
+\pdfannot_dict_put:nnx
+ {link/URI}
+ { Contents }
  { (url) }
 
-\hook_put:nnnn
- { pdf }
- { link_begin_link_attr }
- { /Contents }
+\pdfannot_dict_put:nnx
+ {link/GoTo}
+ { Contents }
  { (ref) }
- }
+
 \endinput



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