diff --git a/browser/lib/markdown-it-deflist.js b/browser/lib/markdown-it-deflist.js index f3c58009..db14c636 100644 --- a/browser/lib/markdown-it-deflist.js +++ b/browser/lib/markdown-it-deflist.js @@ -116,7 +116,7 @@ module.exports = function definitionListPlugin (md) { for (;;) { token = state.push('dd_open', 'dd', 1) - token.map = itemLines = [ nextLine, 0 ] + token.map = itemLines = [ ddLine, 0 ] pos = contentStart max = state.eMarks[ddLine] diff --git a/browser/lib/markdown.js b/browser/lib/markdown.js index 6420f215..81a1ed67 100644 --- a/browser/lib/markdown.js +++ b/browser/lib/markdown.js @@ -251,9 +251,12 @@ class Markdown { this.md.renderer.render = (tokens, options, env) => { tokens.forEach((token) => { switch (token.type) { - case 'heading_open': - case 'paragraph_open': case 'blockquote_open': + case 'dd_open': + case 'dt_open': + case 'heading_open': + case 'list_item_open': + case 'paragraph_open': case 'table_open': token.attrPush(['data-line', token.map[0]]) } diff --git a/tests/fixtures/markdowns.js b/tests/fixtures/markdowns.js index 69e335e0..e261f231 100644 --- a/tests/fixtures/markdowns.js +++ b/tests/fixtures/markdowns.js @@ -50,11 +50,68 @@ const smartQuotes = 'This is a "QUOTE".' const breaks = 'This is the first line.\nThis is the second line.' +const abbrevations = ` +## abbr + +The HTML specification +is maintained by the W3C. + +*[HTML]: Hyper Text Markup Language +*[W3C]: World Wide Web Consortium +` + +const subTexts = ` +## sub + +H~2~0 +` + +const supTexts = ` +## sup + +29^th^ +` + +const deflists = ` +## definition list + +### list 1 + +Term 1 + ~ Definition 1 + +Term 2 + ~ Definition 2a + ~ Definition 2b + +Term 3 +~ + + +### list 2 + +Term 1 + +: Definition 1 + +Term 2 with *inline markup* + +: Definition 2 + + { some code, part of Definition 2 } + + Third paragraph of definition 2. +` + export default { basic, codeblock, katex, checkboxes, smartQuotes, - breaks + breaks, + abbrevations, + subTexts, + supTexts, + deflists } diff --git a/tests/lib/markdown-test.js b/tests/lib/markdown-test.js index 73b68799..e9fb8fc2 100644 --- a/tests/lib/markdown-test.js +++ b/tests/lib/markdown-test.js @@ -43,3 +43,23 @@ test('Markdown.render() should render line breaks correctly', t => { const renderedNonBreaks = newmd.render(markdownFixtures.breaks) t.snapshot(renderedNonBreaks) }) + +test('Markdown.render() should renders abbrevations correctly', t => { + const rendered = md.render(markdownFixtures.abbrevations) + t.snapshot(rendered) +}) + +test('Markdown.render() should renders sub correctly', t => { + const rendered = md.render(markdownFixtures.subTexts) + t.snapshot(rendered) +}) + +test('Markdown.render() should renders sup correctly', t => { + const rendered = md.render(markdownFixtures.supTexts) + t.snapshot(rendered) +}) + +test('Markdown.render() should renders definition lists correctly', t => { + const rendered = md.render(markdownFixtures.deflists) + t.snapshot(rendered) +}) diff --git a/tests/lib/snapshots/markdown-test.js.md b/tests/lib/snapshots/markdown-test.js.md index ffc3d699..b020b098 100644 --- a/tests/lib/snapshots/markdown-test.js.md +++ b/tests/lib/snapshots/markdown-test.js.md @@ -25,13 +25,22 @@ Generated by [AVA](https://ava.li). `␊ ` +## Markdown.render() should renders abbrevations correctly + +> Snapshot 1 + + `
The HTML specification
␊
+ is maintained by the W3C.
Term 3
␊
+ ~
Definition 1
␊ +Definition 2
␊ + { some code, part of Definition 2 }␊
+ ␊
+ Third paragraph of definition 2.
␊ +H20
␊ + ` + +## Markdown.render() should renders sup correctly + +> Snapshot 1 + + `29th
␊ + ` + ## Markdown.render() should text with quotes correctly > Snapshot 1 diff --git a/tests/lib/snapshots/markdown-test.js.snap b/tests/lib/snapshots/markdown-test.js.snap index fc310cfd..c70ca57b 100644 Binary files a/tests/lib/snapshots/markdown-test.js.snap and b/tests/lib/snapshots/markdown-test.js.snap differ