[latex3-commits] [latex3/tagpdf] addrolemap: add RoleMap also with pdf 2.0 (073da2b)

github at latex-project.org github at latex-project.org
Thu Jan 25 19:53:02 CET 2024


Repository : https://github.com/latex3/tagpdf
On branch  : addrolemap
Link       : https://github.com/latex3/tagpdf/commit/073da2b4a1691b7329f289dd873be8307bd9a78d

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

commit 073da2b4a1691b7329f289dd873be8307bd9a78d
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Thu Jan 25 19:53:02 2024 +0100

    add RoleMap also with pdf 2.0


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

073da2b4a1691b7329f289dd873be8307bd9a78d
 CHANGELOG.md     |   5 +++
 tagpdf-roles.dtx |  18 ++++++++++
 tagpdf-tree.dtx  | 100 +++++++++++++++++++------------------------------------
 3 files changed, 57 insertions(+), 66 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index e98c9c5..a642798 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,11 @@ All notable changes to the `tagpdf` package since the
 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 this project uses date-based 'snapshot' version identifiers.
 
+## [Unreleased]
+### Changed 
+ - add RoleMap (currently without mathml tag) 
+   also with pdf 2.0 (see pdf-UA-meeting)
+
 ## [2024-01-19]
 Version 0.98s
 
diff --git a/tagpdf-roles.dtx b/tagpdf-roles.dtx
index c700553..699ae23 100644
--- a/tagpdf-roles.dtx
+++ b/tagpdf-roles.dtx
@@ -543,6 +543,24 @@
             \prop_gput:cno { g_@@_role_NS_#2_prop } {#1}{\l_@@_tmpa_tl}
           }          
       }
+%    \end{macrocode}
+% We also store into the pdf 1.7 rolemapping so that we can
+% add that as fallback for pdf 1.7 processor
+%    \begin{macrocode}
+     \tl_if_empty:nF { #3 }
+      {
+        \tl_if_eq:nnF{#1}{#3}
+         {
+          \prop_get:NnN \g_@@_role_rolemap_prop {#3}\l_@@_tmpa_tl
+           \quark_if_no_value:NTF \l_@@_tmpa_tl
+            {          
+              \prop_gput:Nne \g_@@_role_rolemap_prop {#1}{\tl_to_str:n{#3}}
+            }
+            {
+              \prop_gput:NnV \g_@@_role_rolemap_prop {#1}\l_@@_tmpa_tl
+            } 
+          }         
+       }
    }
 \cs_generate_variant:Nn \@@_role_add_tag:nnnn {VVVV}
 %    \end{macrocode}
diff --git a/tagpdf-tree.dtx b/tagpdf-tree.dtx
index fd0a8bf..6271885 100644
--- a/tagpdf-tree.dtx
+++ b/tagpdf-tree.dtx
@@ -191,48 +191,25 @@
 % \begin{macro}{\@@_tree_write_structtreeroot:}
 % This writes out the root object.
 %    \begin{macrocode}
-\pdf_version_compare:NnTF < {2.0}   
- { 
-   \cs_new_protected:Npn \@@_tree_write_structtreeroot:
-     {
-        \@@_prop_gput:cne
-          { g_@@_struct_0_prop }
-          { ParentTree }
-          { \pdf_object_ref:n { @@/tree/parenttree } }
-        \@@_prop_gput:cne
-          { g_@@_struct_0_prop }
-          { RoleMap }
-          { \pdf_object_ref:n { @@/tree/rolemap } } 
-        \@@_struct_fill_kid_key:n { 0 }   
-        \@@_struct_get_dict_content:nN { 0 } \l_@@_tmpa_tl        
-        \pdf_object_write:nne
-            { @@/struct/0 }
-            {dict}
-            {
-             \l_@@_tmpa_tl            
-            }
-     }
- } 
-%    \end{macrocode}
-% no RoleMap in pdf 2.0
-%    \begin{macrocode}
- {
-   \cs_new_protected:Npn \@@_tree_write_structtreeroot:
-     {
-        \@@_prop_gput:cne
-          { g_@@_struct_0_prop }
-          { ParentTree }
-          { \pdf_object_ref:n { @@/tree/parenttree } }
-        \@@_struct_fill_kid_key:n { 0 }  
-        \@@_struct_get_dict_content:nN { 0 } \l_@@_tmpa_tl        
-        \pdf_object_write:nne
-            { @@/struct/0 }
-            {dict}
-            {
-             \l_@@_tmpa_tl            
-            }
-     }  
- } 
+\cs_new_protected:Npn \@@_tree_write_structtreeroot:
+  {
+     \@@_prop_gput:cne
+       { g_@@_struct_0_prop }
+       { ParentTree }
+       { \pdf_object_ref:n { @@/tree/parenttree } }
+     \@@_prop_gput:cne
+       { g_@@_struct_0_prop }
+       { RoleMap }
+       { \pdf_object_ref:n { @@/tree/rolemap } } 
+     \@@_struct_fill_kid_key:n { 0 }   
+     \@@_struct_get_dict_content:nN { 0 } \l_@@_tmpa_tl        
+     \pdf_object_write:nne
+         { @@/struct/0 }
+         {dict}
+         {
+          \l_@@_tmpa_tl            
+         }
+  } 
 %    \end{macrocode}
 % \end{macro}
 %
@@ -418,11 +395,9 @@
 % command which writes it to the PDF.
 % \begin{variable}{@@/tree/rolemap}
 % At first we reserve again an object. 
+% Rolemap is also used in PDF 2.0 as a fallback.
 %    \begin{macrocode}
-\pdf_version_compare:NnT < {2.0}
-  {
-    \pdf_object_new:n { @@/tree/rolemap }
-  }  
+\pdf_object_new:n { @@/tree/rolemap }
 %    \end{macrocode}
 % \end{variable}
 %
@@ -430,29 +405,22 @@
 % This writes out the rolemap, basically it simply pushes out
 % the dictionary which has been filled in the role module.
 %    \begin{macrocode}
-\pdf_version_compare:NnTF < {2.0}
-  {
-   \cs_new_protected:Npn \@@_tree_write_rolemap:
-    {     
-      \prop_map_inline:Nn\g_@@_role_rolemap_prop
+\cs_new_protected:Npn \@@_tree_write_rolemap:
+ {     
+   \prop_map_inline:Nn\g_@@_role_rolemap_prop
+     {
+       \tl_if_eq:nnF {##1}{##2}
         {
-          \tl_if_eq:nnF {##1}{##2}
-           {
-             \pdfdict_gput:nne {g_@@_role/RoleMap_dict}
-              {##1}
-              {\pdf_name_from_unicode_e:n{##2}}
-           }   
+          \pdfdict_gput:nne {g_@@_role/RoleMap_dict}
+           {##1}
+           {\pdf_name_from_unicode_e:n{##2}}
         }   
-      \pdf_object_write:nne  { @@/tree/rolemap }{dict}
-       {
-        \pdfdict_use:n{g_@@_role/RoleMap_dict}
-       }
+     }
+   \pdf_object_write:nne  { @@/tree/rolemap }{dict}
+    {
+     \pdfdict_use:n{g_@@_role/RoleMap_dict}
     }
-  }
-  {
-    \cs_new_protected:Npn \@@_tree_write_rolemap:{}
-  }
-    
+ }
 %    \end{macrocode}
 % \end{macro}
 %





More information about the latex3-commits mailing list.