From 369c9c8d7d512734c965753092593de0eec12d5c Mon Sep 17 00:00:00 2001 From: Henri Menke Date: Mon, 4 Nov 2019 11:00:48 +1300 Subject: [PATCH] Fix pgfkeys pretty printer for single key-value pair #762 --- .../pgf/doc/pgfmanual.prettyprinter.code.tex | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tex/latex/pgf/doc/pgfmanual.prettyprinter.code.tex b/tex/latex/pgf/doc/pgfmanual.prettyprinter.code.tex index e8aa33422..95cc98fd0 100644 --- a/tex/latex/pgf/doc/pgfmanual.prettyprinter.code.tex +++ b/tex/latex/pgf/doc/pgfmanual.prettyprinter.code.tex @@ -720,7 +720,7 @@ % Collects tokens inside of a token list up to a single delimiting token, dealing with nested % catcode-12-braces. % -% #1: is the end token, the delimiter. It won't be collected. +% #1: list of tokens, each of which is marking the end. It won't be collected. % #2: is code to invoke after % \pgfmanualprettyprinterhandlecollectedargsVtwo has been invoked. % @@ -743,7 +743,7 @@ \def\pgfmanualprettyprintercollectupto#1#2{% \pgfmanualprettyprinterarghasunmatchedbracesfalse \begingroup - \def\pgfmanual@loc@delimittoken{#1}% + \def\pgfmanual@loc@delimittokens{#1}% \toksdef\t@afterpgfmanualprettyprinterhandlecollected=10 \t@afterpgfmanualprettyprinterhandlecollected={#2}% % @@ -758,6 +758,12 @@ \pgfmanual@pretty@collectupto@loop }% +% Stores the token that marks the end in the first argument of +% \pgfmanualprettyprintercollectupto. For example if the token list was {,]} +% and ] was encountered first, then \pgfmanualprettyprinterterminator will +% be ]. +\def\pgfmanualprettyprinterterminator{} + % loops through all tokens, collecting the required number of % arguments. This involves to track nested braces manually. % #1 is a single token. @@ -794,11 +800,13 @@ \advance\c@pgfmanual@pretty@openbracecount by-1 \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% \else - \ifx\pgfmanual@loc@TMPc\pgfmanual@loc@delimittoken + \expandafter\expandafter\expandafter\pgfutil@in@\expandafter\pgfmanual@loc@TMPc\expandafter{\pgfmanual@loc@delimittokens}% + \ifpgfutil@in@ \ifnum\c@pgfmanual@pretty@openbracecount=0 % do NOT include the delimit token. \edef\pgfmanual@pretty@collectupto@loop@NEXT{% \noexpand\endgroup + \noexpand\def\noexpand\pgfmanualprettyprinterterminator{\pgfmanual@loc@TMPc}% \noexpand\pgfmanualprettyprinterhandlecollectedargsVtwo{\the\t@pgfmanual@currentarg}{1}% \noexpand\pgfmanualprettyprintercollectupto@restore@callback \the\t@afterpgfmanualprettyprinterhandlecollected @@ -1053,7 +1061,7 @@ \if\pgfmanual@pretty@isconsumed0% \def\pgfmanualprettyprinterhandlecollectedargsVtwo##1##2{\pgfmanual@pretty@pgfkeys@processvalue{##1}}% the braces will be handled separately. \def\pgfmanual@pretty@pgfkeys@collectvalue@next{% - \pgfmanualprettyprintercollectupto,{\afterpgfmanual@pretty@collectargs@finish@value}#1% + \pgfmanualprettyprintercollectupto{,]}{\afterpgfmanual@pretty@collectargs@finish@value}#1% }% \fi \fi @@ -1063,7 +1071,7 @@ \pgfutil@ifnextchar\pgfmanual@EOI{% \pgfmanual@pretty@pgfkeys@loop }{% - \pgfmanual@pretty@pgfkeys@loop,% re-insert the gobbled comma here! + \expandafter\pgfmanual@pretty@pgfkeys@loop\pgfmanualprettyprinterterminator% re-insert the gobbled comma here! }% }%