fix: shared default lexer state by cloning effective options during lexer construction#1
Open
codefix-patchflow[bot] wants to merge 1 commit into
Open
Conversation
…exer construction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What failed
Describe the bug import { marked } from "marked"; const lexer = new marked.Lexer(); const tokensA = marked.Lexer.lex("Test"); const tokensB = lexer.lex("Test"); The values of tokensA and tokensB should be the same instead tokensA is [ { "type": "paragraph", "raw": "Test", "text": "Test", "tokens": [ { "type": "text", "raw": "Test", "text": "Test", "escaped": false } ] } ] as expected but tokensB is [ { "type": "paragraph", "raw": "Test", "text": "Test", "tokens": [] } ] The problem is probably related to the shared defaults option object To Reproduce Steps to reproduce the behavior: Run the code above Expected behavior I would expect both options to give the same result
What changed
Fixed shared default lexer state by cloning effective options during lexer construction
Why this works
The patch is scoped to the failing path and preserves existing behavior outside the touched code.
Expected result
A concise pull request is created with a clear review note
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