From da0bd16b0ba9d42d044af47137003788f0b7f773 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sat, 24 Dec 2022 03:01:20 +0000 Subject: CTAN sync 202212240301 --- macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty | 285 +++++++-------------- 1 file changed, 94 insertions(+), 191 deletions(-) (limited to 'macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty') diff --git a/macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty b/macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty index e01f9fa594..9e39ec1547 100644 --- a/macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty +++ b/macros/latex/contrib/tagpdf/tagpdfdocu-patches.sty @@ -1,145 +1,86 @@ %\RequirePackage[enable-debug]{expl3}[2018/06/14] -\ProvidesExplPackage {tagpdfdocu-patches} {2022-08-24} {0.97} +\ProvidesExplPackage {tagpdfdocu-patches} {2022-12-22} {0.98} {patches/commands for the tagpdf documentation} -\RequirePackage{etoolbox} +\RequirePackage{etoolbox,xpatch} -%%%%% -% tableofcontents -% no internal patches, but KOMA-only solution -% TODO it must be checked how best practice is now for the table of contents. -%%%%% +%vLogos - -\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: - } - - -\DeclareTOCStyleEntry[ - entryformat=\tagscrtocentry, - pagenumberformat=\tagscrtocpagenumber]{tocline}{section} -\DeclareTOCStyleEntry[ - entryformat=\tagscrtocentry, - pagenumberformat=\tagscrtocpagenumber]{tocline}{subsection} -\DeclareTOCStyleEntry[ - entryformat=\tagscrtocentry, - pagenumberformat=\tagscrtocpagenumber]{tocline}{subsubsection} -\DeclareTOCStyleEntry[ - entryformat=\tagscrtocentry, - pagenumberformat=\tagscrtocpagenumber]{tocline}{paragraph} - - -% \IfStr{#3} doesnt like a \label ... -\renewcommand{\addtocentrydefault}[3]{% -% \Ifstr{#3}{}{} -% {% - \Ifstr{#2}{} - {% - \addcontentsline{toc}{#1} - {% - \protect\nonumberline - \tagstructbegin{tag=P}% - \tagmcbegin{tag=P}% - #3% +\ExplSyntaxOn +\DeclareRobustCommand\TeX{ + \tag_mc_end_push: + \tag_struct_begin:n{tag=Span,alt=TeX,actualtext=TeX} + \tagmcbegin{} + \kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@ + \tagmcend + \tag_struct_end: + \tag_mc_begin_pop:n{}} +\DeclareRobustCommand{\LaTeX}{ + { + \tag_mc_end_push: + \tag_struct_begin:n{tag=Span,alt=LaTeX,actualtext=LaTeX} + \tagmcbegin{} + L\kern-.36em% + \sbox\z@ T% + \vbox to\ht\z@{\hbox{\check@mathfonts + \fontsize\sf@size\z@ + \math@fontsfalse\selectfont + A}% + \vss}% + }% + \kern-.15em% + \TeX \tagmcend - \tagstructend - }% - }% - {% - \addcontentsline{toc}{#1}{% - \tagstructbegin{tag=Lbl}% - \tagmcbegin{tag=Lbl}% - \protect\numberline{#2}% - \tagmcend\tagstructend - \tagstructbegin{tag=P}% - \tagmcbegin{tag=P}% - #3% - \tagmcend - \tagstructend - }% - }% - %} -}% - -% the dots must be marked too - -\renewcommand*{\TOCLineLeaderFill}[1][.]{ - \leaders\hbox{$\m@th - \mkern \@dotsep mu\hbox{\tag_mc_begin:n{artifact}#1\tag_mc_end:}\mkern \@dotsep - mu$}\hfill -} - -%%%%%%%%% -% Sectioning commands -% no internal patches, but KOMA-only solution -%%%%%%%% - -% the structure should be opened rather early to catch the refstepcounter! -\AddtoDoHook{heading/begingroup}{\tagpdfparaOff\use_none:n} -\cs_new_protected:Npn \__tag_struct_section_begin:n #1 {\tagstructbegin{tag=\prop_item:Nn\g_tag_section_level_prop{#1}}} -\AddtoDoHook{heading/postinit}{\__tag_struct_section_begin:n} -\AddtoDoHook{heading/endgroup}{\tagstructend\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} - -\renewcommand{\sectionlinesformat}[4] - { - \@hangfrom - {\hskip #2 - %\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 - \tag_mc_end: - } - } - {\tag_mc_begin:n {tag=\prop_item:Nn\g_tag_section_level_prop{#1}} - #4 - \tag_mc_end:}% - } - -% minisec is simply P, so we let paratagging handle this. -% But we add a strong structure -% TODO: 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=Strong} - \tag_mc_begin:n{tag=Strong} - #1 - \tag_mc_end: - \tag_struct_end: -} -% -\addtokomafont{minisec}{\__tag_docu_tag_minisec:n} - - + \tag_struct_end: + \tag_mc_begin_pop:n{} + } + + +% textbf + +\AddToHook{cmd/textbf/before} + {\leavevmode\tag_mc_end_push:\tag_struct_begin:n{tag=Strong}\tagmcbegin{}} + +\AddToHook{cmd/textbf/after} + {\tag_mc_end:\tag_struct_end:\tag_mc_begin_pop:n{}} + + +\newcommand\minisec[1]{% + \if@noskipsec \leavevmode \fi + \par + \@afterindentfalse + \if@nobreak + \everypar{}% + \else + \addpenalty\@secpenalty\addvspace{1.5ex}% + \fi + {\tagpdfsetup{paratag=H10}\parindent \z@ + \setlength{\parfillskip}{\z@ plus 1fil}% + \raggedright\normalfont\bfseries\nobreak + \nobreak\interlinepenalty \@M #1\par\nobreak% + }\nobreak + \@afterheading +} + + + %%%% %% Lists %% patches enumitem internals! %%%% -\AddToHook{env/itemize/begin}{\par\tagstructbegin{tag=L}}%\par is needed to close the paragraph before. +\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}} +\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}} +\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]{% @@ -151,7 +92,7 @@ \tagstructend\tagstructend} % for the LBody/LI \tagstructbegin{tag=LI} \tagstructbegin{tag=Lbl} - \tagmcbegin{tag=Lbl} + \tagmcbegin{} #1 \tagmcend \tagstructend @@ -161,6 +102,7 @@ \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 @@ -170,20 +112,22 @@ \def\enit@format{% \tagstructbegin{tag=LI}% \tagstructbegin{tag=Lbl}% - \tagmcbegin{tag=Lbl}% + \tagmcbegin{}% #1\tagmcend}} % 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 +% we use Code for every line. -\AddToHook{env/lstlisting/begin}{\tagpdfparaOff\tagstructbegin{tag=Code}\tagmcbegin{tag=Code}} -\AddToHook{env/lstlisting/end}{\tagmcend\tagstructend} +\AddToHook{env/lstlisting/begin}{\tagpdfsetup{paratag=Code}} +\AddToHook{env/lstlisting/end}{} -\AddToHook{env/verbatim/begin}{\tagpdfparaOff\tagstructbegin{tag=Code}\tagmcbegin{tag=Code}} -\AddToHook{env/verbatim/end}{\tagmcend\tagstructend} +\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 ========== % TODO marginnote has a bug (a \par is missing) so it messes up tagging. @@ -209,32 +153,30 @@ %\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 - - +\ExplSyntaxOff % ======= footnote ======== -% TODO +% done in testphase code % ======= bibliography ======== % biblatex. Creates some empty mc-chunks. % no internal patches, but redefining begentry/finentry is not safe. % better hook is needed. -\newbibmacro*{begentry}{\tagstructbegin{tag=BibEntry}\tagmcbegin{tag=BibEntry}} +\newbibmacro*{begentry}{\tagstructbegin{tag=BibEntry}\tagmcbegin{}} \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 -}}{} +\AddToHook{package/hyperref/after} + {% + \pdfstringdefDisableCommands{% + \let\tagstructbegin\@gobble + \let\tagmcbegin\@gobble + \let\tagmcend\relax + \let\tagstructend\relax + }}{} %====== pictures ======== @@ -243,46 +185,7 @@ \tagpdfsetup { newattribute = - {bbox}{/O /Layout /BBox [0~0~100~100]} + {bbox}{/O /Layout /BBox [0 0 100 100]} } -%%%%% -%======== Role maps ========= -%%%%% -\tagpdfsetup{ add-new-tag=Title/H1,add-new-tag=Strong/Span } - - - \endinput - -% ========================== -% now unneeded commands - -% 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: - } - - - \ExplSyntaxOn -\newcommand\showcurrentstruct{\prop_show:c { g__tag_struct_\g__tag_struct_stack_current_tl _prop }} - - -\ExplSyntaxOff -- cgit v1.2.3