Skip to content

Keep an explicit quote marker from rewriting the shared default. - #145

Merged
jgm merged 1 commit into
jgm:mainfrom
karlb:fix-quote-defaultmatch-leak
Aug 2, 2026
Merged

jgm merged 1 commit into
jgm:mainfrom
karlb:fix-quote-defaultmatch-leak

Conversation

@karlb

@karlb karlb commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

defaultmatch is a parameter of the outer betweenMatched factory, captured by the matcher it returns. The matcher assigned to it when adjusting for an explicit { or } marker, but the matchers table is built once at module load, so that binding lives for the lifetime of the module and the rewrite stuck.

One "} therefore flipped left_double_quote to right_double_quote for every later unmatched " -- in the rest of that document, and in every document parsed afterwards in the same process:

He said "hello"}

Later an unmatched "quote here.

rendered the second paragraph's quote as ”, though it is unmatched and renders as “ when that paragraph is parsed on its own. {' does the same in the other direction, turning later unmatched ' into ‘.

Only the quote matchers were affected; every other betweenMatched caller passes "str", which matches neither /^right/ nor /^left/.

Hoist the adjustment into a local so it applies only to the delimiter being handled.

`defaultmatch` is a parameter of the outer betweenMatched factory,
captured by the matcher it returns. The matcher assigned to it when
adjusting for an explicit `{` or `}` marker, but the matchers table is
built once at module load, so that binding lives for the lifetime of
the module and the rewrite stuck.

One `"}` therefore flipped left_double_quote to right_double_quote for
every later unmatched `"` -- in the rest of that document, and in every
document parsed afterwards in the same process:

    He said "hello"}

    Later an unmatched "quote here.

rendered the second paragraph's quote as `”`, though it is unmatched
and renders as `“` when that paragraph is parsed on its own. `{'` does
the same in the other direction, turning later unmatched `'` into `‘`.

Only the quote matchers were affected; every other betweenMatched
caller passes "str", which matches neither /^right/ nor /^left/.

Hoist the adjustment into a local so it applies only to the delimiter
being handled.
@jgm
jgm merged commit 6208947 into jgm:main Aug 2, 2026
1 check passed
@jgm

jgm commented Aug 2, 2026

Copy link
Copy Markdown
Owner

good, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants