Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into split-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
quantizor committed Apr 19, 2024
2 parents 5d8e4d5 + acd970d commit d45f28d
Show file tree
Hide file tree
Showing 9 changed files with 364 additions and 51 deletions.
Binary file not shown.
Binary file not shown.
58 changes: 58 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,63 @@
# markdown-to-jsx

## 7.4.7

### Patch Changes

- 7603248: Fix parsing isolation of individual table cells.
- f9328cc: Improved block html detection regex to handle certain edge cases that cause extreme slowness. Thank you @devbrains-com for the basis for this fix 🤝

## 7.4.6

### Patch Changes

- a9e5276: Browsers assign element with `id` to the global scope using the value as the variable name. E.g.: `<h1 id="analytics">` can be referenced via `window.analytics`.
This can be a problem when a name conflict happens. For instance, pages that expect `analytics.push()` to be a function will stop working if the an element with an `id` of `analytics` exists in the page.

In this change, we export the `slugify` function so that users can easily augment it.
This can be used to avoid variable name conflicts by giving the element a different `id`.

```js
import { slugify } from 'markdown-to-jsx';

options={{
slugify: str => {
let result = slugify(str)

return result ? '-' + str : result;
}
}}
```

## 7.4.5

### Patch Changes

- f5a0079: fix: double newline between consecutive blockquote syntax creates separate blockquotes

Previously, for consecutive blockquotes they were rendered as one:

**Input**

```md
> Block A.1
> Block A.2

> Block B.1
```

**Output**

```html
<blockquote>
<p>Block A.1</p>
<p>Block A.2</p>
<p>Block.B.1</p>
</blockquote>
```

This is not compliant with the [GFM spec](https://github.github.com/gfm/#block-quotes) which states that consecutive blocks should be created if there is a blank line between them.

## 7.4.4

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion docs/markdown-to-jsx.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/markdown-to-jsx.js.map

Large diffs are not rendered by default.

241 changes: 241 additions & 0 deletions index.compiler.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,39 @@ describe('misc block level elements', () => {
</blockquote>
`)
})

it('should handle lazy continuation lines of blockquotes', () => {
render(compiler('> Line 1\nLine 2\n>Line 3'))

expect(root.innerHTML).toMatchInlineSnapshot(`
<blockquote>
<p>
Line 1
Line 2
Line 3
</p>
</blockquote>
`)
})

it('should handle consecutive blockquotes', () => {
render(compiler('> Something important, perhaps?\n\n> Something else'))

expect(root.innerHTML).toMatchInlineSnapshot(`
<div>
<blockquote>
<p>
Something important, perhaps?
</p>
</blockquote>
<blockquote>
<p>
Something else
</p>
</blockquote>
</div>
`)
})
})

describe('headings', () => {
Expand Down Expand Up @@ -2274,6 +2307,66 @@ describe('GFM tables', () => {
</table>
`)
})

it('#568 handle inline syntax around table separators', () => {
render(compiler(`|_foo|bar_|\n|-|-|\n|1|2|`))

expect(root.innerHTML).toMatchInlineSnapshot(`
<table>
<thead>
<tr>
<th>
_foo
</th>
<th>
bar_
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
1
</td>
<td>
2
</td>
</tr>
</tbody>
</table>
`)
})

it('#568 handle inline code syntax around table separators', () => {
render(compiler(`|\`foo|bar\`|baz|\n|-|-|\n|1|2|`))

expect(root.innerHTML).toMatchInlineSnapshot(`
<table>
<thead>
<tr>
<th>
<code>
foo|bar
</code>
</th>
<th>
baz
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
1
</td>
<td>
2
</td>
</tr>
</tbody>
</table>
`)
})
})

describe('arbitrary HTML', () => {
Expand Down Expand Up @@ -3397,6 +3490,154 @@ Item detail
</p>
`)
})

it('#546 perf regression test, self-closing block + block HTML causes exponential degradation', () => {
render(
compiler(
`<span class="oh" data-self-closing="yes" />
You can have anything here. But it's best if the self-closing tag also appears in the document as a pair tag multiple times. We have found it when compiling a table with spans that had a self-closing span at the top.
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
<span class="oh">no</span>
Each span you copy above increases the time it takes by 2. Also, writing text here increases the time.`.trim()
)
)

expect(root.innerHTML).toMatchInlineSnapshot(`
<div>
<span class="oh"
data-self-closing="yes"
>
</span>
<p>
You can have anything here. But it's best if the self-closing tag also appears in the document as a pair tag multiple times. We have found it when compiling a table with spans that had a self-closing span at the top.
</p>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<span class="oh">
no
</span>
<p>
Each span you copy above increases the time it takes by 2. Also, writing text here increases the time.
</p>
</div>
`)
})
})

describe('horizontal rules', () => {
Expand Down

0 comments on commit d45f28d

Please sign in to comment.