Skip to content

Commit

Permalink
Fixes #473 by reducing the backtracking to handle the long strings of…
Browse files Browse the repository at this point in the history
… spaces
  • Loading branch information
caliskanmehmet committed Nov 25, 2024
1 parent 7be50e9 commit 4a30b6a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions index.compiler.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4824,3 +4824,25 @@ it('#597 handles script tag with empty content', () => {
</script>
`)
})

it('#473 handles content with multiple empty spaces without crashing', () => {
render(
compiler(
'##Long \r\n \r\n ###input \ntest'
)
)

expect(root.innerHTML).toMatchInlineSnapshot(`
<div>
<h2 id="long">
Long
</h2>
<h3 id="input">
input
</h3>
<p>
test
</p>
</div>
`)
})
2 changes: 1 addition & 1 deletion index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ const BREAK_LINE_R = /^ {2,}\n/
const BREAK_THEMATIC_R = /^(?:( *[-*_])){3,} *(?:\n *)+\n/
const CODE_BLOCK_FENCED_R =
/^(?: {1,3})?(`{3,}|~{3,}) *(\S+)? *([^\n]*?)?\n([\s\S]*?)(?:\1\n?|$)/
const CODE_BLOCK_R = /^(?: {4}[^\n]+\n*)+(?:\n *)+\n?/
const CODE_BLOCK_R = /^(?: {4}[^\n]+\n*)+(?:\n *)*\n?/
const CODE_INLINE_R = /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/
const CONSECUTIVE_NEWLINE_R = /^(?:\n *)*\n/
const CR_NEWLINE_R = /\r\n?/g
Expand Down

0 comments on commit 4a30b6a

Please sign in to comment.