mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
fix: array access error when token.map is null, fix #3123
This commit is contained in:
@@ -289,7 +289,9 @@ class Markdown {
|
|||||||
case 'list_item_open':
|
case 'list_item_open':
|
||||||
case 'paragraph_open':
|
case 'paragraph_open':
|
||||||
case 'table_open':
|
case 'table_open':
|
||||||
token.attrPush(['data-line', token.map[0]])
|
if (token.map) {
|
||||||
|
token.attrPush(['data-line', token.map[0]])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const result = originalRender.call(this.md.renderer, tokens, options, env)
|
const result = originalRender.call(this.md.renderer, tokens, options, env)
|
||||||
|
|||||||
8
tests/fixtures/markdowns.js
vendored
8
tests/fixtures/markdowns.js
vendored
@@ -104,6 +104,11 @@ Term 2 with *inline markup*
|
|||||||
`
|
`
|
||||||
const shortcuts = '<kbd>Ctrl</kbd>\n\n[[Ctrl]]'
|
const shortcuts = '<kbd>Ctrl</kbd>\n\n[[Ctrl]]'
|
||||||
|
|
||||||
|
const footnote = `
|
||||||
|
^[hello-world]
|
||||||
|
hello-world: https://github.com/BoostIO/Boostnote/
|
||||||
|
`
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
basic,
|
basic,
|
||||||
codeblock,
|
codeblock,
|
||||||
@@ -115,5 +120,6 @@ export default {
|
|||||||
subTexts,
|
subTexts,
|
||||||
supTexts,
|
supTexts,
|
||||||
deflists,
|
deflists,
|
||||||
shortcuts
|
shortcuts,
|
||||||
|
footnote
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,3 +68,8 @@ test('Markdown.render() should render shortcuts correctly', t => {
|
|||||||
const rendered = md.render(markdownFixtures.shortcuts)
|
const rendered = md.render(markdownFixtures.shortcuts)
|
||||||
t.snapshot(rendered)
|
t.snapshot(rendered)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('Markdown.render() should render footnote correctly', t => {
|
||||||
|
const rendered = md.render(markdownFixtures.footnote)
|
||||||
|
t.snapshot(rendered)
|
||||||
|
})
|
||||||
|
|||||||
@@ -4,6 +4,21 @@ The actual snapshot is saved in `markdown-test.js.snap`.
|
|||||||
|
|
||||||
Generated by [AVA](https://ava.li).
|
Generated by [AVA](https://ava.li).
|
||||||
|
|
||||||
|
## Markdown.render() should render footnote correctly
|
||||||
|
|
||||||
|
> Snapshot 1
|
||||||
|
|
||||||
|
`<p data-line="1"><sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup><br />␊
|
||||||
|
hello-world: <a href="https://github.com/BoostIO/Boostnote/">https://github.com/BoostIO/Boostnote/</a></p>␊
|
||||||
|
<hr class="footnotes-sep" />␊
|
||||||
|
<section class="footnotes">␊
|
||||||
|
<ol class="footnotes-list">␊
|
||||||
|
<li id="fn1" class="footnote-item"><p>hello-world <a href="#fnref1" class="footnote-backref">↩︎</a></p>␊
|
||||||
|
</li>␊
|
||||||
|
</ol>␊
|
||||||
|
</section>␊
|
||||||
|
`
|
||||||
|
|
||||||
## Markdown.render() should render line breaks correctly
|
## Markdown.render() should render line breaks correctly
|
||||||
|
|
||||||
> Snapshot 1
|
> Snapshot 1
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user