Skip to content

fix: isolate lexer defaults per instance#2

Open
codefix-patchflow[bot] wants to merge 1 commit into
masterfrom
codefix/6625d35e-import-marked-from-marked-const-lexer-new-marked
Open

fix: isolate lexer defaults per instance#2
codefix-patchflow[bot] wants to merge 1 commit into
masterfrom
codefix/6625d35e-import-marked-from-marked-const-lexer-new-marked

Conversation

@codefix-patchflow

Copy link
Copy Markdown

What failed

Creating a new marked.Lexer() and then calling the static marked.Lexer.lex() could make the original lexer instance return paragraph tokens with empty inline tokens.

The default lexer constructor was writing a newly-created tokenizer back onto the shared _defaults options object. Later lexer construction reused and repointed that tokenizer's lexer reference, so an older lexer instance could enqueue inline tokens on the wrong lexer.

What changed

The lexer constructor now creates a shallow per-instance options object from defaults plus the provided options before assigning a fallback tokenizer

  • src/Lexer.ts around line 24 (modified, +1/-1)

Why this works

When no explicit tokenizer is supplied, each lexer instance receives its own tokenizer through its own options object instead of mutating defaults.tokenizer. Static and instance lexing no longer share a tokenizer whose lexer pointer can be overwritten by later construction

Expected result

marked.Lexer.lex("Test") and new marked.Lexer().lex("Test") should produce identical token arrays, including populated inline paragraph tokens

Patchflow did not run repository-local commands; the automated review gate checks the patch without assuming the project full runtime environment is available.

🔧 Fixed automatically by Patchflow — $1/fix · no fix, no fee

Automation details
  • Job ID: 6625d35e-2c66-451b-a81e-d87e697d9b9f
  • Repository: CDEN190/marked
  • Branch: codefix/6625d35e-import-marked-from-marked-const-lexer-new-marked
  • Base branch: master
  • Reference command: None
  • Review gate: automated static review; repository-local commands were not executed.

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.

0 participants