Skip to content

Commit

Permalink
Merge pull request #1470 from UziTech/gfm-0.29
Browse files Browse the repository at this point in the history
Gfm 0.29
  • Loading branch information
joshbruce authored Apr 13, 2019
2 parents 6d91c4f + 947e417 commit 9a6ca19
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 39 deletions.
127 changes: 127 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
],
"devDependencies": {
"@markedjs/html-differ": "^2.0.1",
"cheerio": "^1.0.0-rc.3",
"commonmark": "0.x",
"eslint": "^5.15.1",
"eslint-config-standard": "^12.0.0",
Expand Down
44 changes: 44 additions & 0 deletions test/specs/gfm/getSpecs.js
Original file line number Diff line number Diff line change
@@ -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);
});
Loading

0 comments on commit 9a6ca19

Please sign in to comment.