zauguin / luapstricks

8 stars 0 forks source link

Print the warning for pdfmanagement-testphase only once #86

Closed hvoss49 closed 11 months ago

hvoss49 commented 12 months ago

It is. bit annoying to get for every PSTricks command the warning. With the below modification it is printed only once.

voss>~:$ diff -u `kpsewhich luapstricks.lua` Documents/luapstricks.lua 
--- /usr/local/texlive/2023/texmf-dist/tex/lualatex/luapstricks/luapstricks.lua 2023-05-25 00:24:40
+++ Documents/luapstricks.lua   2023-10-05 17:04:19
@@ -539,6 +539,8 @@
   flatness = 1,
   miterlimit = nil,
 }}
+
+DocumentMetadata = false

 local lua_node_lookup = setmetatable({}, {__mode = 'k'})
 local char_width_storage -- Non nil only at the beginning of a Type 3 glyph. Used to export the width.
@@ -561,10 +563,15 @@
   t[k] = name
   return name
 end or function()
-  texio.write_nl"Extended graphic state modifications dropped since `pdfmanagement-testphase' is not loaded."
+   if not DocumentMetadata then
+      texio.write_nl"Extended graphic state modifications dropped since `pdfmanagement-testphase' is not loaded."
+      texio.write_nl"Insert \\DocumentMetadata{} as first line"
+      DocumentMetadata = true
+    end
   return ''
 end})

+
 local write_shading do
   local ShadingCount = 0
   if pdfdict_gput then
@@ -589,7 +596,11 @@
     end
   else
     function write_shading()
-      texio.write_nl"Extended graphic state modifications dropped since `pdfmanagement-testphase' is not loaded."
+      if not DocumentMetadata then
+        texio.write_nl"Extended graphic state modifications dropped since `pdfmanagement-testphase' is not loaded."
+        texio.write_nl"Insert \\DocumentMetadata{} as first line"
+        DocumentMetadata = true
+      end
       return ''
     end
   end
hvoss49 commented 11 months ago

ping!

zauguin commented 11 months ago

Thanks for the ping, I had forgotten about this. There is already an implementation of this in the repository, does that look good or do you still want other changes. Otherwise I would prepare a release with this.

hvoss49 commented 11 months ago

Looks good! I also will use this in pstricks.sty:

\ifpst@metadata
  \ifluatex
    \@ifclassloaded{beamer}{}{%   do not execute \DocumentMetadata
%     \RequirePackage{pdfmanagement-testphase}
      \typeout{>>>Setting Metadata ... }%
      \DocumentMetadata{}%
      \makeatletter
    }
  \fi
\fi

Then the \DocumentMetadata. will be used by default. However I need some more testing, but luapstricks.lua can be updated anyway.

hvoss49 commented 11 months ago

I'll close this use and you can upload the new version of pstricks-lua.lua. For pstricks I already did it.