fix(#652): remove usage of lookbehind regex with wildcard lengths #47
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.
Overview
Resolves: a-h/templ#652.
This PR removes the usage of wildcards in all of the lookbehind expressions mentioned in a-h/templ#652.
For
(?<=\s*})
lookbehind expressions, most were able to just remove the wildcard\s
and work the same. Theelse
expression did need some adjustments however to properly address the syntax highlighting of the match it's covering.For the script/style elements, these were previously added and later updated to fix inline tags. The way the lookbehind expression was previously used was allowing the
#element
match to find it first and lookbehind for script/style to start the new match. Instead, I moved#script-element
and#style-element
above#element
in the top-level patterns so they will be matched first and made them more exact matching with proper closing brackets (>
). I also copied down the HTML tokens into these captures.Through testing a few different scenarios of each area I saw no regression, but would be worth a double check from different eyes.