summaryrefslogtreecommitdiffstats
path: root/packages/markdown/marked/test/specs/gfm/getSpecs.js
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2019-04-20 15:18:33 +0300
committerLauri Ojansivu <x@xet7.org>2019-04-20 15:18:33 +0300
commit73e265d8fd050ae3daa67472b4465a5c49d68910 (patch)
tree677b233934a43d8f873e24c794ce289d85e3a9b7 /packages/markdown/marked/test/specs/gfm/getSpecs.js
parent6117097a93bfb11c8bd4c87a23c44a50e22ceb87 (diff)
downloadwekan-73e265d8fd050ae3daa67472b4465a5c49d68910.tar.gz
wekan-73e265d8fd050ae3daa67472b4465a5c49d68910.tar.bz2
wekan-73e265d8fd050ae3daa67472b4465a5c49d68910.zip
Include to Wekan packages directory contents, so that meteor command would build all directly.
This also simplifies build scripts. Thanks to xet7 !
Diffstat (limited to 'packages/markdown/marked/test/specs/gfm/getSpecs.js')
-rw-r--r--packages/markdown/marked/test/specs/gfm/getSpecs.js44
1 files changed, 44 insertions, 0 deletions
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);
+ });