Skip to content

Commit fdc8bf9

Browse files
dginevclaude
andauthored
Fix pstricks raw TeX interpretation for --includestyles mode (#2777)
* fix pstricks raw TeX interpretation for --includestyles mode Enable raw pstricks loading alongside the ltxml binding so that internal registers, utility macros, conditionals, and key-value handlers from pstricks.tex/sty are available for downstream raw packages (pst-3d.tex, pst-plot.tex, pstricks-add.tex, etc.). Four fixes work together: 1. pstricks.tex.ltxml: load raw pstricks.tex via noltxml => 1 instead of redirecting to the sty binding, so TeX-level internals (\pst@dima, \pstheader, \pst@number, etc.) are defined. 2. pstricks.sty.ltxml: load raw pstricks.sty before the ltxml overrides; add optional [] family argument to \psset (matching xkeyval's \setkeys+ interface); fix color key regex to avoid treating boolean values as colors and guard against undefined color lookups. 3. KeyVals.pm: filter empty strings from keyset lists produced by split(',', ...). The pstricks family list \pst@famlist accumulates as ",pstricks" (leading comma), so splitting produces ["", "pstricks"]. The empty keyset caused keyval_qname("psset","","ArrowInside") = "psset@@arrowinside", which collided with the raw \def\psset@@arrowinside (a delimited- argument helper), triggering "Missing argument" errors for delimiters -, \@empty, \@nil. 4. KeyVal.pm: fix empty macroprefix handling for boolean and command keys — use defined() checks so that an explicitly empty macroprefix="" is respected rather than falling through to the default qname-based macro name. Resolves all 101 pstricks-related errors for arXiv paper 2405.20126v1. Minimal reproduction: min-pstricks.tex (not committed). Test suite: all 468 tests pass with no regressions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * create pstricks_support layer and address feedback (thanks @brucemiller) * only documented color keys with hex values use lowercase c * add pstricks_support.sty.ltxml to MANIFEST --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 48ad18d commit fdc8bf9

File tree

6 files changed

+1081
-1042
lines changed

6 files changed

+1081
-1042
lines changed

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ lib/LaTeXML/Package/pst-grad.sty.ltxml
697697
lib/LaTeXML/Package/pst-node.sty.ltxml
698698
lib/LaTeXML/Package/pstricks.sty.ltxml
699699
lib/LaTeXML/Package/pstricks.tex.ltxml
700+
lib/LaTeXML/Package/pstricks_support.sty.ltxml
700701
lib/LaTeXML/Package/pxfonts.sty.ltxml
701702
lib/LaTeXML/Package/pzd.fontmap.ltxml
702703
lib/LaTeXML/Package/quantumarticle.cls.ltxml

lib/LaTeXML/Core/KeyVal.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,14 @@ sub define {
102102
if ($kind eq 'ordinary') {
103103
defineOrdinary($qname, $options{code}); }
104104
elsif ($kind eq 'command') {
105-
my $macroname = ($options{macroprefix} ? $options{macroprefix} . $key : "cmd" . $qname);
105+
my $macroname = (defined($options{macroprefix}) && $options{macroprefix} ne ''
106+
? $options{macroprefix} . $key : "cmd" . $qname);
106107
defineCommand($qname, $options{code}, $macroname); }
107108
elsif ($kind eq 'choice') {
108109
defineChoice($qname, $options{code}, $options{mismatch},
109110
$options{choices}, ($options{normalize} || 0), $options{bin}); }
110111
elsif ($kind eq 'boolean') {
111-
my $macroname = ($options{macroprefix} ? $options{macroprefix} . $key : $qname);
112+
my $macroname = (defined($options{macroprefix}) ? $options{macroprefix} . $key : $qname);
112113
defineBoolean($qname, $options{code}, $options{mismatch}, $macroname); }
113114
else {
114115
Warn('unknown', undef, "Unknown KeyVals kind $kind",

lib/LaTeXML/Core/KeyVals.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ sub new {
4949
my ($class, $prefix, $keysets, %options) = @_;
5050
# parse all the arguments
5151
$prefix = defined($prefix) ? ToString($prefix) : 'KV';
52-
$keysets = [split(',', ToString(defined($keysets) ? $keysets : '_anonymous_'))] unless (ref($keysets) eq 'ARRAY');
52+
$keysets = [grep { $_ ne '' } split(',', ToString(defined($keysets) ? $keysets : '_anonymous_'))] unless (ref($keysets) eq 'ARRAY');
5353
my $skip = $options{skip};
5454
$skip = [split(',', ToString(defined($options{skip}) ? $options{skip} : ''))] unless (ref($options{skip}) eq 'ARRAY');
5555
my $setAll = $options{setAll} ? 1 : 0;
@@ -390,7 +390,7 @@ sub setKeysExpansion {
390390
T_CS('\def'), T_CS('\XKV@tfam'), T_BEGIN, T_END,
391391
T_CS('\def'), T_CS('\XKV@header'), T_BEGIN, T_END,
392392
T_CS('\def'), T_CS('\XKV@tkey'), T_BEGIN, T_END) if $setInternals;
393-
} } }
393+
} } }
394394

395395
# and assign the skipmissing macro with the other keys
396396
push(@tokens, T_CS('\def'), $rmmacro, T_BEGIN, @rmtokens, T_END) if $rmmacro;

0 commit comments

Comments
 (0)