diff options
Diffstat (limited to 'macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty')
-rw-r--r-- | macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty | 131 |
1 files changed, 55 insertions, 76 deletions
diff --git a/macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty b/macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty index df9d084a39..2501381ded 100644 --- a/macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty +++ b/macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty @@ -1,9 +1,9 @@ %\RequirePackage[enable-debug]{expl3}[2018/06/14] -\ProvidesExplPackage {tagpdfdocu-patches} {2023-02-15} {0.98d} +\ProvidesExplPackage {tagpdfdocu-patches} {2023-03-07} {0.98e} {patches/commands for the tagpdf documentation} \RequirePackage{etoolbox,xpatch} -%vLogos +%Logos \ExplSyntaxOn \DeclareRobustCommand\TeX{ @@ -48,7 +48,7 @@ \AddToHook{cmd/emph/after} {\tag_mc_end:\tag_struct_end:\tag_mc_begin_pop:n{}} - +% minisec, correct tagging is still unclear. \newcommand\minisec[1]{% \if@noskipsec \leavevmode \fi \par @@ -66,75 +66,34 @@ \@afterheading } - +% listings. Unclear how to make it work for the original lstlisting, so we make a +% copy taglstlisting for now +\DeclareInstance{blockenv}{lstlisting}{display} +{ + env-name = lstlisting, + tag-name = verbatim, + tag-class = , + tagging-recipe = standard, + inner-level-counter = , + level-increase = false, + setup-code = , + block-instance = displayblock , + inner-instance = , + final-code = \tl_set:Nn \l__tag_para_main_tag_tl {codeline}\tagtool{paratag=Code}, +} + +\lstnewenvironment{taglstlisting}[2][]{% + \UseInstance{blockenv}{lstlisting} {} + \lst@TestEOLChar{#2}% + \lstset{#1}% + \csname\@lst @SetFirstNumber\endcsname% + }{% + \@nobreakfalse + \csname\@lst @SaveFirstNumber\endcsname% + \endblockenv + } -%%%% -%% Lists -%% patches enumitem internals! -%%%% -\tagpdfsetup - { - newattribute = - {itemize}{/O /List /ListNumbering/Unordered}, - newattribute = - {enumerate}{/O /List /ListNumbering/Ordered}, - newattribute = - {description}{/O /List /ListNumbering/Description}, - } -\AddToHook{env/itemize/begin}{\par\tagstructbegin{tag=L,attribute-class=itemize}}%\par is needed to close the paragraph before. -\AddToHook{env/itemize/end}{\par\tagstructend\tagstructend\tagstructend}%LBody,LI,L -\AddToHook{env/enumerate/begin}{\par\tagstructbegin{tag=L,attribute-class=enumerate}} -\AddToHook{env/enumerate/end}{\par\tagstructend\tagstructend\tagstructend}%LBody,LI,L -\AddToHook{env/description/begin}{\par\tagstructbegin{tag=L,attribute-class=description}} -\AddToHook{env/description/end}{\par\tagstructend\tagstructend\tagstructend}%LBody,LI,L - -\newcommand\tag@enit@format@preset[1]{% - \str_if_eq:eeTF { \prop_item:cn { g__tag_struct_\g__tag_struct_stack_current_tl _prop }{S} }{/L} - { - %\typeout{BEGIN~OF~LIST} - } - {%\typeout{NEXT ITEM} - \tagstructend\tagstructend} % for the LBody/LI - \tagstructbegin{tag=LI} - \tagstructbegin{tag=Lbl} - \tagmcbegin{} - #1 - \tagmcend - \tagstructend - \tagstructbegin{tag=LBody} - } - -\ExplSyntaxOff -\xpatchcmd\enit@preset{\@firstofone}{\tag@enit@format@preset}{}{\fail} -%close mc from paratagging and reopen ... -% this disturbs someone docCommand which has then a MC outside a P. -\xpatchcmd\@item{\box\@labels}{\tagmcend \box\@labels \tagmcbegin{tag=P}}{}{\fail} -\ExplSyntaxOn - -% keys that overwrite \enit@format must be patched, eg like the follow -% the font key should be patched in a similar way -\enitkv@key{}{format}{% new enumitem don't use first argument - \def\enit@format{% - \tagstructbegin{tag=LI}% - \tagstructbegin{tag=Lbl}% - \tagmcbegin{}% - #1\tagmcend}} - - -% listings + verbatim -% the paragraph code could create span around the lines ... -% we use Code for every line. - -\AddToHook{env/lstlisting/begin}{\tagpdfsetup{paratag=Code}} -\AddToHook{env/lstlisting/end}{} - -\AddToHook{env/verbatim/begin}{\tagpdfsetup{paratag=Code}} -\AddToHook{env/verbatim/end}{} - -\AddToHook{env/docCommand/begin}{\tagstructbegin{tag=P}\tagpdfsetup{paratag=Code}} -\AddToHook{env/docCommand/end} {\tagstructend} - -% ======== marginnote ========== + % ======== marginnote ========== % TODO marginnote has a bug (a \par is missing) so it messes up tagging. % but currently unneeded as we marked them up as artifacts anyway as they don't contain % meaningful contents @@ -144,6 +103,7 @@ \tag_mc_artifact_group_begin:n{notype}\tagpdfparaOff\marginnote{#1}\tag_mc_artifact_group_end: } +\ExplSyntaxOff % ======== tikzpicture ========== % TODO this needs some investigation: it messes up the stack if one add paraOff @@ -153,12 +113,21 @@ % We switch of paratagging at the begin and reenable it locally in before upper. % the before upper setting is dangerous as it can be overwritten by % users. So a more stable hook is needed. -%\AddToHook{env/tcolorbox/begin}{\tagpdfparaOff} -%\AddToHook{env/docCommand/begin}{\tagpdfparaOff} -%\tcbset{before~upper=\tagpdfparaOn} -\AddToHook{env/tcolorbox/begin}{\tagpdfparaOff \tcbset{before~upper=\tagpdfparaOn}} -\AddToHook{env/docCommand/begin}{\tagpdfparaOff \tcbset{before~upper=\tagpdfparaOn}} +% we force also a \par and add a div structure, to avoid clashes with the block +% tagging code. This needs revisting! + +\AddToHook{env/tcolorbox/before}{\par\tagstructbegin{tag=Div}} +\AddToHook{env/tcolorbox/begin}{\tagpdfparaOff \tcbset{before upper=\tagpdfparaOn}} +\AddToHook{env/tcolorbox/after}{\par\tagstructend} + +% this is not good and only temporary, but it is still unclear how to handle internal lists. +\ExplSyntaxOn +\AddToHook{env/docCommand/before}{\par\tagtool{para=false}\tagstructbegin{tag=Code}\tagmcbegin{}\tag_stop:} +\AddToHook{env/docCommand/after}{\par\tag_start:\tagmcend\tagstructend\tagtool{para=true}} \ExplSyntaxOff + +%\AddToHook{env/docCommand/begin}{\tagpdfparaOff \tcbset{before upper=\tagpdfparaOn}\tagtool{paratag=Code}\tagtool{para-flattened=true}} + % ======= footnote ======== % done in testphase code @@ -170,6 +139,16 @@ \newbibmacro*{begentry}{\tagstructbegin{tag=BibEntry}\tagmcbegin{}} \newbibmacro*{finentry}{\finentry\tagmcend\tagstructend} +\def\blx@endbibliography{% + \csuse{blx@endenv@\blx@theenv}% + \blx@noitem + \blx@locallabelwidth@finish + \endgroup + \blx@bibnote\blx@thepostnote +% \endgroup + \expandafter\endgroup\if@endpe\@doendpe\fi +} + % ====== hyperref ======== % this should probably go into tagpdf, but it is related to % problem of pdf strings and context .... |