[latex3-commits] [latex3/tagpdf] faster-ref: more corrections to Ref code (2e2f930)

github at latex-project.org github at latex-project.org
Mon Sep 9 21:26:40 CEST 2024


Repository : https://github.com/latex3/tagpdf
On branch  : faster-ref
Link       : https://github.com/latex3/tagpdf/commit/2e2f9302d706df98adb09de3040bc02288d1e517

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

commit 2e2f9302d706df98adb09de3040bc02288d1e517
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Mon Sep 9 21:26:40 2024 +0200

    more corrections to Ref code


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

2e2f9302d706df98adb09de3040bc02288d1e517
 tagpdf-backend.dtx |  2 +-
 tagpdf-checks.dtx  |  6 +++---
 tagpdf-struct.dtx  | 27 +++++++++++++++++++++------
 tagpdf.dtx         | 17 +++++++++++++++++
 4 files changed, 42 insertions(+), 10 deletions(-)

diff --git a/tagpdf-backend.dtx b/tagpdf-backend.dtx
index 0ed233e..f19fea6 100644
--- a/tagpdf-backend.dtx
+++ b/tagpdf-backend.dtx
@@ -114,7 +114,7 @@
 \cs_set_protected:Npn \@@_prop_gput:Nnn #1 #2 #3
   {
     \prop_gput:Nnn #1 { #2 } { #3 }
-    \lua_now:e { ltx.@@.tables.\cs_to_str:N#1 ["#2"] = "#3" }
+    \lua_now:e { ltx.@@.tables.\cs_to_str:N#1 ["#2"] = "\lua_escape:n{#3}" }
   }
 
 
diff --git a/tagpdf-checks.dtx b/tagpdf-checks.dtx
index 9ca418e..f838836 100644
--- a/tagpdf-checks.dtx
+++ b/tagpdf-checks.dtx
@@ -456,13 +456,13 @@
 %    \end{macrocode}
 % \end{macro}
 % 
-% \begin{macro}{struct-Ref-dest-unknown}
+% \begin{macro}{struct-Ref-unknown}
 % This message is issued at the end, when the Ref keys are updated.
 % TODO: in debug mode it should report more info about the structure.
 %    \begin{macrocode}
-\msg_new:nnn { tag } {struct-Ref-dest-unknown}
+\msg_new:nnn { tag } {struct-Ref-unknown}
  {
-    Destination~#1~has~no~related~structure.\\
+     #1~has~no~related~structure.\\
     /Ref~not~updated.
  }
 %    \end{macrocode}
diff --git a/tagpdf-struct.dtx b/tagpdf-struct.dtx
index d4c083b..c6704fe 100644
--- a/tagpdf-struct.dtx
+++ b/tagpdf-struct.dtx
@@ -1264,17 +1264,24 @@
 % It therefore stores it values as
 % clist of commands which are executed at the end of the document,
 % when the structure elements are written.
-% \begin{macro}{\@@_struct_Ref_label:nN,\@@_struct_Ref_dest:nN}
-% this two commands are helper commands that are stored as clist
+% \begin{macro}{\@@_struct_Ref_label:nN,\@@_struct_Ref_dest:nN,\@@_struct_Ref_num:nN,}
+% this commands are helper commands that are stored as clist
 % in the Ref key of a structure. They are executed when the structure
 % elements are written in  \cs{@@_struct_write_obj}. They are used
-% in \cs{@@_struct_format_Ref}.
+% in \cs{@@_struct_format_Ref}. They allow to add a Ref by label, destname
+% and structure number
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_struct_Ref_label:nN #1 #2 %#1 a label
   {
-    \tl_put_right:Ne#2
+    \prop_get:NnNTF \g_@@_struct_label_num_prop {#1} \l_@@_tmpb_tl
+      {
+        \tl_put_right:Ne#2
+          {
+            \c_space_tl\tag_struct_object_ref:e{ \l_@@_tmpb_tl }
+          }
+      }    
       {
-        \c_space_tl\@@_property_ref:en{tagpdfstruct-#1}{tagstructobj}
+        \msg_warning:nnn {tag}{struct-Ref-unknown}{Label~#1}
       }    
   }
 \cs_new_protected:Npn \@@_struct_Ref_dest:nN #1 #2 %#1 a dest name
@@ -1287,9 +1294,17 @@
           }
       }    
       {
-        \msg_warning:nnn {tag}{struct-Ref-dest-unknown}{#1}
+        \msg_warning:nnn {tag}{struct-Ref-unknown}{Destination~#1}
       }
   }
+\cs_new_protected:Npn \@@_struct_Ref_num:nN #1 #2 %#1 a structure number
+  {
+    \tl_put_right:Ne#2
+      {
+        \c_space_tl\tag_struct_object_ref:e{ #1 }
+      }  
+  }
+   
 %    \end{macrocode}
 % \end{macro}
 %
diff --git a/tagpdf.dtx b/tagpdf.dtx
index ab6fc94..398c155 100644
--- a/tagpdf.dtx
+++ b/tagpdf.dtx
@@ -191,6 +191,23 @@
  }
 %</base>
 %    \end{macrocode}
+% \subsection{Patches related to Ref improvement}
+% 2024-09-09: Temporary code. Can be removed when the latex-lab-footnote
+% and latex-lab-toc code have been adapted to the better Ref handling.
+%    \begin{macrocode}
+%<*package>
+\AddToHook{package/latex-lab-testphase-new-or-2/after}
+  {
+    \cs_set_protected:Npn \__fnote_gput_ref:nn #1 #2 %#1 the structure number receiving the ref #2
+      {
+        \tag_if_active:T
+          {
+            \tag_struct_gput:nnn {#1}{ref}{\__tag_struct_Ref_num:nN { #2 }}
+          }
+      }
+  }
+%</package>
+%    \end{macrocode}
 % \subsection{Indexed objects}
 % 2024-04-11: Temporary code! Can be removed after the next expl3 release!
 %    \begin{macrocode}





More information about the latex3-commits mailing list.