From 292b0e0b0716716b5505e43a3de75487794f887d Mon Sep 17 00:00:00 2001 From: ache Date: Fri, 7 Feb 2020 18:57:12 +0100 Subject: Support for linkReferences and footnotes --- __tests__/index.js | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to '__tests__') diff --git a/__tests__/index.js b/__tests__/index.js index 7ac7b0c..6cfa471 100644 --- a/__tests__/index.js +++ b/__tests__/index.js @@ -25,6 +25,13 @@ const render = text => unified() .use(stringify) .processSync(text); +const renderFootnotes = text => unified() + .use(reParse, {footnotes: true}) + .use(plugin, {allowDangerousDOMEventHandlers: false, scope: 'permissive'}) + .use(remark2rehype) + .use(stringify) + .processSync(text); + const renderRaw = text => unified() .use(reParse) .use(plugin, {allowDangerousDOMEventHandlers: false, scope: 'permissive'}) @@ -128,16 +135,40 @@ Title of the article {data-id="title"} `; - const {contents} = render(imageMd); + const {contents} = renderDefault(imageMd); t.deepEqual(parse(contents), parse('

Title of the article

')); }); test('emphasis and strong', t => { const emphasis = 'Hey ! *That looks cool*{style="color: blue;"} ! No, that\'s **not**{.not} !'; - const {contents} = render(emphasis); + const {contents} = renderDefault(emphasis); t.deepEqual(parse(contents), parse('

Hey ! That looks cool ! No, that\'s not !')); }); +test('linkReference', t => { + const linkRef = `[Google][google]{hreflang="en"} + +[google]: https://google.com +`; + const {contents} = renderDefault(linkRef); + t.deepEqual(parse(contents), parse('

Google

')); +}); + +test('footnote', t => { + const footnotes = `Since XP is good we should always use XP[^xp]{ data-id=xp } + +[^xp]: Apply XP principe to XP. +`; + const {contents} = renderFootnotes(footnotes); + t.deepEqual(parse(contents), parse(`

Since XP is good we should always use XPxp

+
+
+
    +
  1. Apply XP principe to XP.
  2. +
+
`)); +}); + /* Readme tests * * Should be act acording to the README.md -- cgit v1.2.3