fix: handle single-line comments in template code blocks#369
Open
harunosakura030303-maker wants to merge 1 commit intobgub:mainfrom
Open
fix: handle single-line comments in template code blocks#369harunosakura030303-maker wants to merge 1 commit intobgub:mainfrom
harunosakura030303-maker wants to merge 1 commit intobgub:mainfrom
Conversation
Previously, the parser only handled block comments (/* */), causing unpaired apostrophes in single-line comments (// it's, don't) to be incorrectly treated as string delimiters, resulting in 'unclosed string' parse errors. This adds // detection to parseCloseReg and skips to end of line when a single-line comment is encountered, matching the existing block comment handling behavior. Fixes bgub#337
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.
Summary
Fixes #337 — unpaired apostrophes in single-line comments (
// it's,// don't) no longer cause parse errors.Problem
The parser's
parseCloseRegregex matches',",`,/*, and closing tags. When it encounters a'inside a//comment, it tries to match a complete string literal and fails with "unclosed string" since the apostrophe is unpaired.Fix
Added
//toparseCloseRegand a handler that skips to end of line when a single-line comment is encountered, matching the existing/* */block comment behavior.Test Case