From 73e265d8fd050ae3daa67472b4465a5c49d68910 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Sat, 20 Apr 2019 15:18:33 +0300 Subject: Include to Wekan packages directory contents, so that meteor command would build all directly. This also simplifies build scripts. Thanks to xet7 ! --- .../markdown/marked/test/specs/gfm/getSpecs.js | 44 ++++++ .../markdown/marked/test/specs/gfm/gfm.0.29.json | 147 +++++++++++++++++++++ 2 files changed, 191 insertions(+) create mode 100644 packages/markdown/marked/test/specs/gfm/getSpecs.js create mode 100644 packages/markdown/marked/test/specs/gfm/gfm.0.29.json (limited to 'packages/markdown/marked/test/specs/gfm') diff --git a/packages/markdown/marked/test/specs/gfm/getSpecs.js b/packages/markdown/marked/test/specs/gfm/getSpecs.js new file mode 100644 index 00000000..2746bdbb --- /dev/null +++ b/packages/markdown/marked/test/specs/gfm/getSpecs.js @@ -0,0 +1,44 @@ +const fetch = require('node-fetch'); +const cheerio = require('cheerio'); +const marked = require('../../../'); +const htmlDiffer = require('../../helpers/html-differ.js'); +const fs = require('fs'); + +fetch('https://github.github.com/gfm/') + .then(res => res.text()) + .then(html => cheerio.load(html)) + .then($ => { + const version = $('.version').text().match(/\d+\.\d+/)[0]; + if (!version) { + throw new Error('No version found'); + } + const specs = []; + $('.extension').each((i, ext) => { + const section = $('.definition', ext).text().trim().replace(/^\d+\.\d+(.*?) \(extension\)[\s\S]*$/, '$1'); + $('.example', ext).each((j, exa) => { + const example = +$(exa).attr('id').replace(/\D/g, ''); + const markdown = $('.language-markdown', exa).text().trim(); + const html = $('.language-html', exa).text().trim(); + specs.push({ + section, + html, + markdown, + example + }); + }); + }); + + return [version, specs]; + }) + .then(([version, specs]) => { + specs.forEach(spec => { + const html = marked(spec.markdown, {gfm: true}); + if (!htmlDiffer.isEqual(html, spec.html)) { + spec.shouldFail = true; + } + }); + fs.writeFileSync(`gfm.${version}.json`, JSON.stringify(specs, null, 2) + '\n'); + }) + .catch((err) => { + console.error(err); + }); diff --git a/packages/markdown/marked/test/specs/gfm/gfm.0.29.json b/packages/markdown/marked/test/specs/gfm/gfm.0.29.json new file mode 100644 index 00000000..7d1d43e4 --- /dev/null +++ b/packages/markdown/marked/test/specs/gfm/gfm.0.29.json @@ -0,0 +1,147 @@ +[ + { + "section": "Tables", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n\n
foobar
bazbim
", + "markdown": "| foo | bar |\n| --- | --- |\n| baz | bim |", + "example": 198 + }, + { + "section": "Tables", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n\n
abcdefghi
barbaz
", + "markdown": "| abc | defghi |\n:-: | -----------:\nbar | baz", + "example": 199 + }, + { + "section": "Tables", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n
f|oo
b | az
b | im
", + "markdown": "| f\\|oo |\n| ------ |\n| b `\\|` az |\n| b **\\|** im |", + "example": 200 + }, + { + "section": "Tables", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n\n
abcdef
barbaz
\n
\n

bar

\n
", + "markdown": "| abc | def |\n| --- | --- |\n| bar | baz |\n> bar", + "example": 201 + }, + { + "section": "Tables", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
abcdef
barbaz
bar
\n

bar

", + "markdown": "| abc | def |\n| --- | --- |\n| bar | baz |\nbar\n\nbar", + "example": 202 + }, + { + "section": "Tables", + "html": "

| abc | def |\n| --- |\n| bar |

", + "markdown": "| abc | def |\n| --- |\n| bar |", + "example": 203 + }, + { + "section": "Tables", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
abcdef
bar
barbaz
", + "markdown": "| abc | def |\n| --- | --- |\n| bar |\n| bar | baz | boo |", + "example": 204 + }, + { + "section": "Tables", + "html": "\n\n\n\n\n\n\n
abcdef
", + "markdown": "| abc | def |\n| --- | --- |", + "example": 205 + }, + { + "section": "Task list items", + "html": "", + "markdown": "- [ ] foo\n- [x] bar", + "example": 279 + }, + { + "section": "Task list items", + "html": "", + "markdown": "- [x] foo\n - [ ] bar\n - [x] baz\n- [ ] bim", + "example": 280 + }, + { + "section": "Strikethrough", + "html": "

Hi Hello, world!

", + "markdown": "~~Hi~~ Hello, world!", + "example": 491 + }, + { + "section": "Strikethrough", + "html": "

This ~~has a

\n

new paragraph~~.

", + "markdown": "This ~~has a\n\nnew paragraph~~.", + "example": 492 + }, + { + "section": "Autolinks", + "html": "

www.commonmark.org

", + "markdown": "www.commonmark.org", + "example": 621 + }, + { + "section": "Autolinks", + "html": "

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

", + "markdown": "Visit www.commonmark.org/help for more information.", + "example": 622 + }, + { + "section": "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 + }, + { + "section": "Autolinks", + "html": "

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

\n

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

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

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

", + "markdown": "www.google.com/search?q=(business))+ok", + "example": 625 + }, + { + "section": "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 + }, + { + "section": "Autolinks", + "html": "

www.commonmark.org/he<lp

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

\n

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

\n

Anonymous FTP is available at ftp://foo.bar.baz.

", + "markdown": "http://commonmark.org\n\n(Visit https://encrypted.google.com/search?q=Markup+(business))\n\nAnonymous FTP is available at ftp://foo.bar.baz.", + "example": 628 + }, + { + "section": "Autolinks", + "html": "

foo@bar.baz

", + "markdown": "foo@bar.baz", + "example": 629 + }, + { + "section": "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 + }, + { + "section": "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 + }, + { + "section": "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, + "shouldFail": true + } +] -- cgit v1.2.3-1-g7c22