[latex3-commits] [latex3/tagpdf] luatex-softhyphen: remove biblatex fix, add first draft for tikz tagging (c3265bda)

github at latex-project.org github at latex-project.org
Sat Jul 27 00:55:43 CEST 2024


Repository : https://github.com/latex3/tagpdf
On branch  : luatex-softhyphen
Link       : https://github.com/latex3/tagpdf/commit/c3265bdaada39bc5e4166409f992c94ab22e6c15

>---------------------------------------------------------------

commit c3265bdaada39bc5e4166409f992c94ab22e6c15
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Sat Jul 27 00:55:43 2024 +0200

    remove biblatex fix, add first draft for tikz tagging


>---------------------------------------------------------------

c3265bdaada39bc5e4166409f992c94ab22e6c15
 doc/tagpdfdocu-patches.sty | 165 +++++++++++++++++++++++++++++++++++++--------
 1 file changed, 138 insertions(+), 27 deletions(-)

diff --git a/doc/tagpdfdocu-patches.sty b/doc/tagpdfdocu-patches.sty
index 936f8ada..14e14a73 100644
--- a/doc/tagpdfdocu-patches.sty
+++ b/doc/tagpdfdocu-patches.sty
@@ -82,10 +82,6 @@
 % }
 
 \ExplSyntaxOff
-% ======== 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.
@@ -138,22 +134,6 @@
 % ======= footnote ========
 % 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.
-
-
-\def\blx at endbibliography{%
-  \csuse{blx at endenv@\blx at theenv}%
-  \blx at noitem
-  \blx at locallabelwidth@finish
-  \endgroup
-  \blx at bibnote\blx at thepostnote
-%  \endgroup
-   \expandafter\endgroup\if at endpe\@doendpe\fi
-}
-
 % ====== hyperref ========
 % this should probably go into tagpdf, but it is related to
 % problem of pdf strings and context ....
@@ -167,16 +147,147 @@
    \let\tagstructend\relax
  }}{}
 
-%====== picture =======
+%====== tikz picture =======
+% first draft to tag. The main problem is to handle paragraphs. One 
+\ExplSyntaxOn
+\cs_new_protected:Npn\__tag_tikz_savepos:n #1
+ {
+  \tex_savepos:D 
+  \tikz at resetexpandcount%
+  \tikz at scan@one at point\pgfutil at firstofone(current~bounding~box.north~east)\relax
+  \pgf at pos@transform{\pgf at x}{\pgf at y}%
+  \property_record:nn{#1}{xpos,ypos,abspage}
+  \property_record:nn{#1-tr}{pgfx,pgfy}
+  \tikz at scan@one at point\pgfutil at firstofone(current~bounding~box.south~west)\relax
+  \pgf at pos@transform{\pgf at x}{\pgf at y}%
+  \property_record:nn{#1-bl}{pgfx,pgfy}
+  \tex_savepos:D 
+ }
+\cs_generate_variant:Nn \__tag_tikz_savepos:n {e}
  
-% PAC3 complained that the BBox is missing, so we are cheating for now
-% and add a fix size.
-\tagpdfsetup
-  {
-     newattribute =
-        {bbox}{/O /Layout /BBox [0 0 100 100]}
+\NewProperty{pgfx}{now}{0}
+ {
+   \dim_compare:nNnTF {\dim_abs:n {\pgf at x}} > {15999pt} 
+    { 0 }
+    { \dim_to_decimal_in_sp:n{\pgf at x} } 
+ }  
+\NewProperty{pgfy}{now}{0}
+ {
+   \dim_compare:nNnTF {\dim_abs:n {\pgf at y}} > {15999pt} 
+    { 0 }
+    { \dim_to_decimal_in_sp:n{\pgf at y} } 
+ }  
+
+\cs_new_protected:Npn \__tag_tikz_getbbox:
+ {
+   \int_gincr:N\g__tag_graphic_int
+   \tl_set:Ne\l__tag_graphic_currentlabel_tl {__tag_graphic_\int_use:N \g__tag_graphic_int}
+   \tl_gset:Ne\g__tag_graphic_lx_tl
+     {
+       \dim_to_decimal_in_bp:n 
+         {   \property_ref:een {\l__tag_graphic_currentlabel_tl}{xpos}{0}sp 
+           + \property_ref:een {\l__tag_graphic_currentlabel_tl-bl}{pgfx}{0}sp  
+         }
+     }  
+   \tl_gset:Ne\g__tag_graphic_ly_tl
+        {
+          \dim_to_decimal_in_bp:n 
+            { \property_ref:een {\l__tag_graphic_currentlabel_tl}{ypos}{0}sp 
+              + \property_ref:een {\l__tag_graphic_currentlabel_tl-bl}{pgfy}{0}sp
+            }
+        } 
+   \tl_gset:Ne\g__tag_graphic_ux_tl
+     {
+       \dim_to_decimal_in_bp:n 
+         {   \property_ref:een {\l__tag_graphic_currentlabel_tl}{xpos}{0}sp 
+           + \property_ref:een {\l__tag_graphic_currentlabel_tl-tr}{pgfx}{0}sp  
+         }
+     }
+   \tl_gset:Ne\g__tag_graphic_uy_tl
+     {
+       \dim_to_decimal_in_bp:n 
+         {   \property_ref:een {\l__tag_graphic_currentlabel_tl}{ypos}{0}sp 
+           + \property_ref:een {\l__tag_graphic_currentlabel_tl-tr}{pgfy}{0}sp  
+         }
+     }  
+  }
+
+\cs_new_protected:Npn \__tag_graphic_tikz_begin_picture:
+ {
+  \tag_mc_end_push:
+  \bool_if:NTF \l__tag_graphic_artifact_bool
+   { \tagmcbegin{artifact} }
+   {   
+     \__tag_tikz_getbbox:
+     \tagstructbegin{tag=Figure,alt=\l__tag_graphic_alt_tl}\tagmcbegin{}
+     \__tag_prop_gput:cne
+         { g__tag_struct_\int_eval:n {\c at g__tag_struct_abs_int}_prop }
+         { A } 
+         {
+           << 
+             /O /Layout /BBox~
+             [
+              \g__tag_graphic_lx_tl\c_space_tl
+              \g__tag_graphic_ly_tl\c_space_tl
+              \g__tag_graphic_ux_tl\c_space_tl
+              \g__tag_graphic_uy_tl
+             ]
+           >>   
+         }
+    \bool_if:NT\l__tag_graphic_debug_bool
+     {
+       \__tag_graphic_show_bbox:VVVVne
+        \g__tag_graphic_lx_tl
+        \g__tag_graphic_ly_tl
+        \g__tag_graphic_ux_tl
+        \g__tag_graphic_uy_tl
+        {red}
+        {\int_use:N\g__tag_graphic_int}
+      }
+    }      
+    \SuspendTagging{tikz}      
   }
 
+\cs_new_protected:Npn \__tag_graphic_tikz_end_picture:
+ {
+   \ResumeTagging{tikz}\tagmcend
+   \bool_if:NF \l__tag_graphic_artifact_bool
+     {
+       \tagstructend
+       \__tag_tikz_savepos:e {__tag_graphic_\int_use:N \g__tag_graphic_int}
+     }
+   \tag_mc_begin_pop:n{}
+ }
+ 
+\tikzset
+ {
+   every~picture/.style=
+    {
+     artifact,
+     execute~at~begin~picture=\__tag_graphic_tikz_begin_picture:, 
+     execute~at~end~picture=\__tag_graphic_tikz_end_picture:
+    }
+ }
+\AddToHook{env/tikzpicture/before}{\leavevmode} 
+ 
+\tikzset
+ {
+   alt/.code= 
+     {
+       \bool_set_false:N \l__tag_graphic_artifact_bool
+       \tl_set:Nn \l__tag_graphic_alt_tl{#1}
+     } 
+ } 
+\tikzset
+ {
+   artifact/.code= 
+    \bool_set_true:N \l__tag_graphic_artifact_bool
+ } 
+
+\ExplSyntaxOff
+
+
+
 
 
 \endinput





More information about the latex3-commits mailing list.