diff --git a/browser/lib/markdown.js b/browser/lib/markdown.js index 2dc98121..49183442 100644 --- a/browser/lib/markdown.js +++ b/browser/lib/markdown.js @@ -289,7 +289,9 @@ class Markdown { case 'list_item_open': case 'paragraph_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) diff --git a/tests/fixtures/markdowns.js b/tests/fixtures/markdowns.js index 0ee80909..340f2ddd 100644 --- a/tests/fixtures/markdowns.js +++ b/tests/fixtures/markdowns.js @@ -104,6 +104,11 @@ Term 2 with *inline markup* ` const shortcuts = 'Ctrl\n\n[[Ctrl]]' +const footnote = ` +^[hello-world] +hello-world: https://github.com/BoostIO/Boostnote/ +` + export default { basic, codeblock, @@ -115,5 +120,6 @@ export default { subTexts, supTexts, deflists, - shortcuts + shortcuts, + footnote } diff --git a/tests/lib/markdown-test.js b/tests/lib/markdown-test.js index 46ae5941..31ffc518 100644 --- a/tests/lib/markdown-test.js +++ b/tests/lib/markdown-test.js @@ -68,3 +68,8 @@ test('Markdown.render() should render shortcuts correctly', t => { const rendered = md.render(markdownFixtures.shortcuts) t.snapshot(rendered) }) + +test('Markdown.render() should render footnote correctly', t => { + const rendered = md.render(markdownFixtures.footnote) + t.snapshot(rendered) +}) diff --git a/tests/lib/snapshots/markdown-test.js.md b/tests/lib/snapshots/markdown-test.js.md index 56c4466f..4111c2f2 100644 --- a/tests/lib/snapshots/markdown-test.js.md +++ b/tests/lib/snapshots/markdown-test.js.md @@ -4,6 +4,21 @@ The actual snapshot is saved in `markdown-test.js.snap`. Generated by [AVA](https://ava.li). +## Markdown.render() should render footnote correctly + +> Snapshot 1 + + `

[1]
␊ + hello-world: https://github.com/BoostIO/Boostnote/

␊ +
␊ +
␊ +
    ␊ +
  1. hello-world ↩︎

    ␊ +
  2. ␊ +
␊ +
␊ + ` + ## Markdown.render() should render line breaks correctly > Snapshot 1 diff --git a/tests/lib/snapshots/markdown-test.js.snap b/tests/lib/snapshots/markdown-test.js.snap index 67d43616..3f5ec41c 100644 Binary files a/tests/lib/snapshots/markdown-test.js.snap and b/tests/lib/snapshots/markdown-test.js.snap differ