pgf icon indicating copy to clipboard operation
pgf copied to clipboard

Profiler documented code broken rendering

Open Atcold opened this issue 3 years ago • 2 comments

Version

3.1.9a

Details

In the Profiler Library, we can see:

image

There's a missing { before the 1, at the end of the line. I checked the source code, and the { is actually there.

https://github.com/pgf-tikz/pgf/blob/89a9ef189a7420e0510fe97907285804bee4f670/doc/generic/pgf/pgfmanual-en-library-profiler.tex#L34-L36

So, I don't know how to fix this bug.

Atcold avatar Sep 23 '22 18:09 Atcold

Note to myself: \pgfkeys is parsed specially, but for some reason that special parser jumps over the } and swallows the { after that.

hmenke avatar Sep 23 '22 19:09 hmenke

Currently the code does not handle the case where a closing brace is encountered before the first opening brace, so it just keeps on scanning. This might fix it.

diff --git a/tex/latex/pgf/doc/pgfmanual.prettyprinter.code.tex b/tex/latex/pgf/doc/pgfmanual.prettyprinter.code.tex
index d01b375a..c6c370ab 100644
--- a/tex/latex/pgf/doc/pgfmanual.prettyprinter.code.tex
+++ b/tex/latex/pgf/doc/pgfmanual.prettyprinter.code.tex
@@ -662,9 +662,22 @@
                                     \the\t@afterpgfmanualprettyprinterhandlecollected
                                 }%
                             \fi
+                        \else\ifnum\c@pgfmanual@pretty@openbracecount<0
+                            % we have somehow collected a closing brace too many
+                            % reinsert it an back out
+                            \edef\pgfmanual@loc@TMPc{\the\t@pgfmanual@allargs\the\t@pgfmanual@currentarg#1}%
+                            \t@pgfmanual@allargs=\expandafter{\pgfmanual@loc@TMPc}%
+                            \t@pgfmanual@currentarg={}%
+                            % finish the loop
+                            \edef\pgfmanual@pretty@collectargs@loop@NEXT{%
+                                \noexpand\endgroup
+                                \noexpand\def\noexpand\pgfmanualprettyprinternumcollectedargs{\the\c@pgfmanual@pretty@curargcount}%
+                                \noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@allargs}%
+                                \the\t@afterpgfmanualprettyprinterhandlecollected
+                            }%
                         \else
                             \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}%
-                        \fi
+                        \fi\fi
                     \else
                         \ifnum13=\catcode`#1
                             % we found a white space (space, TAB or NL) or comment

hmenke avatar Sep 23 '22 20:09 hmenke