Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gfm 0.29 #1470

Merged
merged 3 commits into from Apr 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Expand Up @@ -30,6 +30,7 @@
],
"devDependencies": {
"@markedjs/html-differ": "^2.0.1",
"cheerio": "^1.0.0-rc.3",
styfle marked this conversation as resolved.
Show resolved Hide resolved
"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
@@ -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);
});