diff options
Diffstat (limited to 'macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty')
-rw-r--r-- | macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty | 308 |
1 files changed, 139 insertions, 169 deletions
diff --git a/macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty b/macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty index 2032895ec2..40dc38289f 100644 --- a/macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty +++ b/macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty @@ -1,72 +1,26 @@ -\RequirePackage{expl3}[2018/06/14] %\RequirePackage[enable-debug]{expl3}[2018/06/14] -\RequirePackage{xpatch} -\ProvidesExplPackage {tagpdfdocu-patches} {2019/10/15} {0.70} +\ProvidesExplPackage {tagpdfdocu-patches} {2021/03/22} {0.80} {patches/commands for the tagpdf documentation} -% to do : marginnote, perhaps the description macros ... -% to do: footnotes! -% printbibliography? - -\newbibmacro*{begentry}{\tagstructbegin{tag=BibEntry}\tagmcbegin{tag=BibEntry}} -\newbibmacro*{finentry}{\finentry\tagmcend\tagstructend} - -% hyperref -\@ifpackageloaded{hyperref}{% -\pdfstringdefDisableCommands{ - \let\tagstructbegin\@gobble - \let\tagmcbegin\@gobble - \let\tagmcend\relax - \let\tagstructend\relax -}}{} - -%%%%% -% Paragraphs -%%%%% - -% we need a command which simply starts a paragraph \TagP^, -% a "continuation" variant which closes the previous paragraph (\TagP), -% and a final end. - -\NewDocumentCommand\TagP{t{^}} - { - \tag_mc_if_in:T { \tag_mc_end: } - \IfBooleanF{#1} - { - \tag_struct_end: - } - \tag_struct_begin:n{tag=P} - \tag_mc_begin:n{tag=P} - } -% close a mc and one structure - -\NewDocumentCommand\TagPend{} - { - \tag_mc_if_in:T { \tag_mc_end: } - \tag_struct_end: - } - - -%%%%% -% maketitle -%%%%% -\tagpdfsetup{ add-new-tag=Title/H1 } - %%%%% % tableofcontents %%%%% +\AfterTOCHead{\tag_struct_begin:n{tag=TOC}} +\AfterStartingTOC{\tag_struct_end:} %end TOC %Marking the toc entries %around the whole entry so only structure: \newcommand\tagscrtocentry[1]{\tag_struct_begin:n{tag=TOCI}#1\tag_struct_end:} %leaf so structure and mc: -\newcommand\tagscrtocpagenumber[1]{% - \tag_struct_begin:n{tag=Reference}% - \tag_mc_begin:n{tag=Reference}% - #1% - \tag_mc_end: - \tag_struct_end:} +\newcommand\tagscrtocpagenumber[1] + { + \tag_struct_begin:n{tag=Reference} + \tag_mc_begin:n{tag=Reference} + #1 + \tag_mc_end: + \tag_struct_end: + } \DeclareTOCStyleEntry[ @@ -126,21 +80,21 @@ % Sectioning commands %%%%%%%% +\AddtoDoHook{heading/begingroup}{\tagpdfparaOff\use_none:n} + \prop_new:N \g_tag_section_level_prop \prop_gput:Nnn \g_tag_section_level_prop {section}{H1} \prop_gput:Nnn \g_tag_section_level_prop {subsection}{H2} \prop_gput:Nnn \g_tag_section_level_prop {subsubsection}{H3} \prop_gput:Nnn \g_tag_section_level_prop {paragraph}{H4} - - -%unnumbered sections level give an empty mc, need to think about it. \renewcommand{\sectionlinesformat}[4] { \@hangfrom {\hskip #2 \tagstructbegin{tag=\prop_item:Nn\g_tag_section_level_prop{#1}} - \tl_if_empty:nF{#3} + %\tl_if_empty:nF{#3} + \tl_if_in:nnF{\@empty}{#3} { \tag_mc_begin:n {tag=\prop_item:Nn\g_tag_section_level_prop{#1}} #3 @@ -153,48 +107,52 @@ } %minisec is simply P, H6 doesn't work .... +% so we let paratagging handle this. But we add a strong structure +% should changed to H6 as it is no longer required to have H6 only after H5 +%but need to check how to disable paratagging ... \cs_new:Nn \__tag_docu_tag_minisec:n { - \tag_struct_begin:n {tag=P} - \tag_mc_begin:n{tag=P} + \tag_struct_begin:n {tag=Strong} + \tag_mc_begin:n{tag=Strong} #1 \tag_mc_end: \tag_struct_end: } - +% \addtokomafont{minisec}{\__tag_docu_tag_minisec:n} -\AfterTOCHead{\tag_struct_begin:n{tag=TOC}} -\AfterStartingTOC{\tag_struct_end:} %end TOC -%% list +%%%% +%% Lists + +\AddToHook{env/itemize/begin}{\par\tagstructbegin{tag=L}}%\par is needed to close the paragraph before. +\AddToHook{env/itemize/end}{\par\tagstructend\tagstructend\tagstructend}%LBody,LI,L +\AddToHook{env/enumerate/begin}{\par\tagstructbegin{tag=L}} +\AddToHook{env/enumerate/end}{\par\tagstructend\tagstructend\tagstructend}%LBody,LI,L +\AddToHook{env/description/begin}{\par\tagstructbegin{tag=L}} +\AddToHook{env/description/end}{\par\tagstructend\tagstructend\tagstructend}%LBody,LI,L \newcommand\tag@enit@format@preset[1]{% - \tagstructbegin{tag=LI}% - \tagstructbegin{tag=Lbl}% - \tagmcbegin{tag=Lbl}% - #1% + \str_if_eq:eeTF { \prop_item:cn { g__tag_struct_\g__tag_struct_stack_current_tl _prop }{S} }{/L} + { + %\typeout{BEGIN~OF~LIST} + } + {%\typeout{NEXT ITEM} + \tagstructend\tagstructend} % for the LBody/LI + \tagstructbegin{tag=LI} + \tagstructbegin{tag=Lbl} + \tagmcbegin{tag=Lbl} + #1 \tagmcend - \tagstructend %end Lbl - \tagstructbegin{tag=LBody}} - -\newcommand\meti{% end of \item - \tagstructend %end of LBody - \tagstructend %end of LI -} - -\newcommand\Pmeti{% end of \item - \TagPend %end of P - \tagstructend %end of LBody - \tagstructend %end of LI -} + \tagstructend + \tagstructbegin{tag=LBody} + } \ExplSyntaxOff \xpatchcmd\enit@preset{\@firstofone}{\tag@enit@format@preset}{}{\fail} +%close mc from paratagging and reopen ... +\xpatchcmd\@item{\box\@labels}{\tagmcend \box\@labels \tagmcbegin{tag=P}}{}{\fail} \ExplSyntaxOn -\setlist{ - before*=\tagstructbegin{tag=L}, - after*={\tagstructend}} % keys that overwrite \enit@format must be patched, eg like the follow % the font key should be patched in a similar way @@ -205,99 +163,111 @@ \tagmcbegin{tag=Lbl}% #1\tagmcend}} - %%% hooks for links - %%% 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 } -% { annot/Link/URI_begin } -% { -% \tag_struct_begin:n{tag=Link} -% \tag_mc_begin:n{tag=Link} -% } - -\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@g__tag_parenttree_obj_int } - } -%\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: - } +% listings + verbatim +% the paragraph code could create span around the lines ... +% it is quite unclear if Code is a sensible structure as it no longer exists in pdf 2.0 + +\AddToHook{env/lstlisting/begin}{\tagpdfparaOff\tagstructbegin{tag=Code}\tagmcbegin{tag=Code}} +\AddToHook{env/lstlisting/end}{\tagmcend\tagstructend} + +\AddToHook{env/verbatim/begin}{\tagpdfparaOff\tagstructbegin{tag=Code}\tagmcbegin{tag=Code}} +\AddToHook{env/verbatim/end}{\tagmcend\tagstructend} + + +% ======== 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 + +\NewDocumentCommand\sidenote{m}{\begin{tagmcartifact}{notype}\tagpdfparaOff\marginnote{#1}\end{tagmcartifact}} + +% ======== tikzpicture ========== +% TODO this needs some investigation: it messes up the stack if one add paraOff + +\AddToHook{env/tikzpicture/begin}{} + +%======== tcolorbox ======== +% 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}} + + %locally for now + + +% ======= footnote ======== +% TODO + +% ======= bibliography ======== +% biblatex. There are some entry mc-chunks somewhere. + +\newbibmacro*{begentry}{\tagstructbegin{tag=BibEntry}\tagmcbegin{tag=BibEntry}} +\newbibmacro*{finentry}{\finentry\tagmcend\tagstructend} + +% ====== hyperref ======== +% this should probably go into tagpdf, but it is related to +% problem of pdf strings and context .... + +\@ifpackageloaded{hyperref}{% +\pdfstringdefDisableCommands{ + \let\tagstructbegin\@gobble + \let\tagmcbegin\@gobble + \let\tagmcend\relax + \let\tagstructend\relax +}}{} -%\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} + +%====== pictures ======== +% PAC3 complained that the BBox is missing, so we are cheating for now +% and add a fix size. +\tagpdfsetup { - \tag_struct_begin:n{tag=Link} - \tag_mc_begin:n{tag=Link} - \pdfannot_dict_put:nnx - {link/GoTo} - { StructParent } - { \int_use:N\c@g__tag_parenttree_obj_int } + newattribute = + {bbox}{/O /Layout /BBox [0~0~100~100]} } +%%%%% +%======== Role maps ========= +%%%%% +\tagpdfsetup{ add-new-tag=Title/H1,add-new-tag=Strong/Span } + +\endinput -%\hook_put_right:nnn -% { pdf } -% { annot/link/GoTo_end } -% { -% \__tag_struct_finish_link: -% \tag_mc_end: -% \tag_struct_end: -% } +% ========================== +% now unneeded commands -\hook_gput_code:nnn - {pdfannot/link/GoTo/after} - {tagpdf} +% we need a command which simply starts a paragraph \TagP^, +% a "continuation" variant which closes the previous paragraph (\TagP), +% and a final end. + +\NewDocumentCommand\TagP{t{^}} + { + \tag_mc_if_in:T { \tag_mc_end: } + \IfBooleanF{#1} { - \__tag_struct_finish_link: - \tag_mc_end: \tag_struct_end: } -% "alternative descriptions " for PAX3. How to get better text here?? -\pdfannot_dict_put:nnx - {link/URI} - { Contents } - { (url) } + \tag_struct_begin:n{tag=P} + \tag_mc_begin:n{tag=P} + } +% close a mc and one structure + +\NewDocumentCommand\TagPend{} + { + \tag_mc_if_in:T { \tag_mc_end: } + \tag_struct_end: + } -\pdfannot_dict_put:nnx - {link/GoTo} - { Contents } - { (ref) } -\endinput + \ExplSyntaxOn +\newcommand\showcurrentstruct{\prop_show:c { g__tag_struct_\g__tag_struct_stack_current_tl _prop }} + + +\ExplSyntaxOff |