From 6e63fc8cc013ab1925790ec6ce99cb1490375b7f Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Wed, 4 Oct 2023 21:10:25 -0600 Subject: [PATCH] update specs --- test/specs/gfm/gfm.0.29.json | 55 +++++++++++++++++++++++++++--------- test/unit/Lexer.test.js | 1 - test/update-specs.js | 15 +++++++--- 3 files changed, 52 insertions(+), 19 deletions(-) diff --git a/test/specs/gfm/gfm.0.29.json b/test/specs/gfm/gfm.0.29.json index 50c4ac8d095..9d403a9a8bd 100644 --- a/test/specs/gfm/gfm.0.29.json +++ b/test/specs/gfm/gfm.0.29.json @@ -61,8 +61,8 @@ }, { "section": "[extension] Strikethrough", - "html": "

Hi Hello, world!

", - "markdown": "~~Hi~~ Hello, world!", + "html": "

Hi Hello, there world!

", + "markdown": "~~Hi~~ Hello, ~there~ world!", "example": 491 }, { @@ -71,77 +71,104 @@ "markdown": "This ~~has a\n\nnew paragraph~~.", "example": 492 }, + { + "section": "[extension] Strikethrough", + "html": "

This will ~~~not~~~ strike.

", + "markdown": "This will ~~~not~~~ strike.", + "example": 493 + }, { "section": "[extension] Autolinks", "html": "

www.commonmark.org

", "markdown": "www.commonmark.org", - "example": 621 + "example": 622 }, { "section": "[extension] Autolinks", "html": "

Visit www.commonmark.org/help for more information.

", "markdown": "Visit www.commonmark.org/help for more information.", - "example": 622 + "example": 623 }, { "section": "[extension] Autolinks", "html": "

Visit www.commonmark.org.

\n

Visit www.commonmark.org/a.b.

", "markdown": "Visit www.commonmark.org.\n\nVisit www.commonmark.org/a.b.", - "example": 623 + "example": 624 }, { "section": "[extension] Autolinks", "html": "

www.google.com/search?q=Markup+(business)

\n

www.google.com/search?q=Markup+(business)))

\n

(www.google.com/search?q=Markup+(business))

\n

(www.google.com/search?q=Markup+(business)

", "markdown": "www.google.com/search?q=Markup+(business)\n\nwww.google.com/search?q=Markup+(business)))\n\n(www.google.com/search?q=Markup+(business))\n\n(www.google.com/search?q=Markup+(business)", - "example": 624 + "example": 625 }, { "section": "[extension] Autolinks", "html": "

www.google.com/search?q=(business))+ok

", "markdown": "www.google.com/search?q=(business))+ok", - "example": 625 + "example": 626 }, { "section": "[extension] Autolinks", "html": "

www.google.com/search?q=commonmark&hl=en

\n

www.google.com/search?q=commonmark&hl;

", "markdown": "www.google.com/search?q=commonmark&hl=en\n\nwww.google.com/search?q=commonmark&hl;", - "example": 626 + "example": 627 }, { "section": "[extension] Autolinks", "html": "

www.commonmark.org/he<lp

", "markdown": "www.commonmark.org/hehttp://commonmark.org

\n

(Visit https://encrypted.google.com/search?q=Markup+(business))

", "markdown": "http://commonmark.org\n\n(Visit https://encrypted.google.com/search?q=Markup+(business))", - "example": 628 + "example": 629 }, { "section": "[extension] Autolinks", "html": "

foo@bar.baz

", "markdown": "foo@bar.baz", - "example": 629 + "example": 630 }, { "section": "[extension] Autolinks", "html": "

hello@mail+xyz.example isn't valid, but hello+xyz@mail.example is.

", "markdown": "hello@mail+xyz.example isn't valid, but hello+xyz@mail.example is.", - "example": 630 + "example": 631 }, { "section": "[extension] Autolinks", "html": "

a.b-c_d@a.b

\n

a.b-c_d@a.b.

\n

a.b-c_d@a.b-

\n

a.b-c_d@a.b_

", "markdown": "a.b-c_d@a.b\n\na.b-c_d@a.b.\n\na.b-c_d@a.b-\n\na.b-c_d@a.b_", - "example": 631 + "example": 632 + }, + { + "section": "[extension] Autolinks", + "html": "

mailto:foo@bar.baz

\n

mailto:a.b-c_d@a.b

\n

mailto:a.b-c_d@a.b.

\n

mailto:a.b-c_d@a.b/

\n

mailto:a.b-c_d@a.b-

\n

mailto:a.b-c_d@a.b_

\n

xmpp:foo@bar.baz

\n

xmpp:foo@bar.baz.

", + "markdown": "mailto:foo@bar.baz\n\nmailto:a.b-c_d@a.b\n\nmailto:a.b-c_d@a.b.\n\nmailto:a.b-c_d@a.b/\n\nmailto:a.b-c_d@a.b-\n\nmailto:a.b-c_d@a.b_\n\nxmpp:foo@bar.baz\n\nxmpp:foo@bar.baz.", + "example": 633, + "shouldFail": true + }, + { + "section": "[extension] Autolinks", + "html": "

xmpp:foo@bar.baz/txt

\n

xmpp:foo@bar.baz/txt@bin

\n

xmpp:foo@bar.baz/txt@bin.com

", + "markdown": "xmpp:foo@bar.baz/txt\n\nxmpp:foo@bar.baz/txt@bin\n\nxmpp:foo@bar.baz/txt@bin.com", + "example": 634, + "shouldFail": true + }, + { + "section": "[extension] Autolinks", + "html": "

xmpp:foo@bar.baz/txt/bin

", + "markdown": "xmpp:foo@bar.baz/txt/bin", + "example": 635, + "shouldFail": true }, { "section": "[extension] Disallowed Raw HTML", "html": "

<title> <style>

\n
\n <xmp> is disallowed. <XMP> is also disallowed.\n
", "markdown": " <style> <em>\n\n<blockquote>\n <xmp> is disallowed. <XMP> is also disallowed.\n</blockquote>", - "example": 653, + "example": 657, "shouldFail": true } ] diff --git a/test/unit/Lexer.test.js b/test/unit/Lexer.test.js index 770cedddfb1..d29251dcb3d 100644 --- a/test/unit/Lexer.test.js +++ b/test/unit/Lexer.test.js @@ -436,7 +436,6 @@ a | b describe('list', () => { it('unordered', () => { expectTokens({ - log: true, md: ` - item 1 - item 2 diff --git a/test/update-specs.js b/test/update-specs.js index 15de5d6dcd4..b3aad7f0dd6 100644 --- a/test/update-specs.js +++ b/test/update-specs.js @@ -1,9 +1,12 @@ import fetch from 'node-fetch'; import { load } from 'cheerio'; -import marked from '../'; +import { Marked } from '../lib/marked.esm.js'; import { htmlIsEqual } from '@markedjs/testutils'; import { readdirSync, unlinkSync, writeFileSync } from 'node:fs'; -import { join, resolve } from 'node:path'; +import { join, resolve, dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); function removeFiles(dir) { readdirSync(dir).forEach(file => { @@ -19,11 +22,13 @@ async function updateCommonmark(dir, options) { const res2 = await fetch(`https://spec.commonmark.org/${version}/spec.json`); const json = await res2.json(); const specs = await Promise.all(json.map(async(spec) => { - const html = marked(spec.markdown, options); + const marked = new Marked(); + const html = marked.parse(spec.markdown, options); const isEqual = await htmlIsEqual(html, spec.html); if (!isEqual) { spec.shouldFail = true; } + return spec; })); writeFileSync(resolve(dir, `./commonmark.${version}.json`), JSON.stringify(specs, null, 2) + '\n'); console.log(`Saved CommonMark v${version} specs`); @@ -58,11 +63,13 @@ async function updateGfm(dir) { }); specs = await Promise.all(specs.map(async(spec) => { - const html = marked(spec.markdown, { gfm: true, pedantic: false }); + const marked = new Marked(); + const html = marked.parse(spec.markdown, { gfm: true, pedantic: false }); const isEqual = await htmlIsEqual(html, spec.html); if (!isEqual) { spec.shouldFail = true; } + return spec; })); writeFileSync(resolve(dir, `./gfm.${version}.json`), JSON.stringify(specs, null, 2) + '\n'); console.log(`Saved GFM v${version} specs.`);