Skip to content

Commit

Permalink
Improved tag matching for JSX
Browse files Browse the repository at this point in the history
  • Loading branch information
FIameCaster committed Aug 20, 2023
1 parent 2c8a786 commit 38fa98b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prism-code-editor",
"version": "0.1.0",
"version": "0.1.1",
"type": "module",
"description": "Lightweight, extensible code editor for the web using Prism",
"main": "./dist/index.js",
Expand Down
10 changes: 5 additions & 5 deletions package/src/extensions/matchTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ export const createTagMatcher = (editor: PrismEditor): TagMatcher => {

if (Array.isArray(content)) {
if (type == "tag") {
const [{ length: openingLength }, tagName] = <[Prism.Token, string?]>(
let [{ length: openingLength }, tagName] = <[Prism.Token, (string | Prism.Token)?]>(
(<Prism.Token>content[0]).content
)
let closingLength = (<Prism.Token>content[content.length - 1]).length

const closingLength = (<Prism.Token>content[content.length - 1]).length

// Skip self-closing tags or JSX fragments
if (closingLength == 1 && tagName && (noVoidTags || !voidTags.has(tagName))) {
// Skip self-closing tags
if (closingLength == 1 && (noVoidTags || !voidTags.has(<string>tagName))) {
tagName = <string>((<Prism.Token>tagName)?.content || tagName)
if (openingLength == 1) {
stack.push([tagIndex, tagName])
} else {
Expand Down

0 comments on commit 38fa98b

Please sign in to comment.