Skip to content

Commit 9a6ca19

Browse files
authored
Merge pull request #1470 from UziTech/gfm-0.29
Gfm 0.29
2 parents 6d91c4f + 947e417 commit 9a6ca19

File tree

5 files changed

+205
-39
lines changed

5 files changed

+205
-39
lines changed

package-lock.json

Lines changed: 127 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
],
3131
"devDependencies": {
3232
"@markedjs/html-differ": "^2.0.1",
33+
"cheerio": "^1.0.0-rc.3",
3334
"commonmark": "0.x",
3435
"eslint": "^5.15.1",
3536
"eslint-config-standard": "^12.0.0",

test/specs/gfm/getSpecs.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const fetch = require('node-fetch');
2+
const cheerio = require('cheerio');
3+
const marked = require('../../../');
4+
const htmlDiffer = require('../../helpers/html-differ.js');
5+
const fs = require('fs');
6+
7+
fetch('https://github.github.com/gfm/')
8+
.then(res => res.text())
9+
.then(html => cheerio.load(html))
10+
.then($ => {
11+
const version = $('.version').text().match(/\d+\.\d+/)[0];
12+
if (!version) {
13+
throw new Error('No version found');
14+
}
15+
const specs = [];
16+
$('.extension').each((i, ext) => {
17+
const section = $('.definition', ext).text().trim().replace(/^\d+\.\d+(.*?) \(extension\)[\s\S]*$/, '$1');
18+
$('.example', ext).each((j, exa) => {
19+
const example = +$(exa).attr('id').replace(/\D/g, '');
20+
const markdown = $('.language-markdown', exa).text().trim();
21+
const html = $('.language-html', exa).text().trim();
22+
specs.push({
23+
section,
24+
html,
25+
markdown,
26+
example
27+
});
28+
});
29+
});
30+
31+
return [version, specs];
32+
})
33+
.then(([version, specs]) => {
34+
specs.forEach(spec => {
35+
const html = marked(spec.markdown, {gfm: true});
36+
if (!htmlDiffer.isEqual(html, spec.html)) {
37+
spec.shouldFail = true;
38+
}
39+
});
40+
fs.writeFileSync(`gfm.${version}.json`, JSON.stringify(specs, null, 2) + '\n');
41+
})
42+
.catch((err) => {
43+
console.error(err);
44+
});

0 commit comments

Comments
 (0)