1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-25 02:42:10 +02:00
video.js/build/current-changelog.js
2019-08-30 14:14:53 -04:00

36 lines
827 B
JavaScript

/* eslint-disable no-console */
const unified = require('unified');
const markdown = require('remark-parse');
const stringify = require('remark-stringify');
const fs = require('fs');
module.exports = function() {
const processor = unified()
.use(markdown, {commonmark: true})
.use(stringify);
const ast = processor.parse(fs.readFileSync('./CHANGELOG.md'));
const changelog = [];
changelog.push(processor.stringify(ast.children[0]));
// start at 1 so we get the first anchor tag
// and can break on the second
for (let i = 1; i < ast.children.length; i++) {
let item = processor.stringify(ast.children[i]);
if (/^<a name="/.test(item)) {
break;
}
if (/^###/.test(item)) {
item = '\n' + item + '\n';
}
changelog.push(item);
}
return changelog.join('\n');
};