diff --git a/lib/main/build-site.js b/lib/main/build-site.js index 41cc22a6e..23dba1d38 100644 --- a/lib/main/build-site.js +++ b/lib/main/build-site.js @@ -11,12 +11,19 @@ var basePath = path.join(__dirname, '..', '..'), readmePath = path.join(docPath, 'README.md'); function build(type) { - var $ = marky(fs.readFileSync(readmePath, 'utf8'), { 'sanitize': false }), + // Load markddown and uncomment docdown HTML hints. + var markdown = fs + .readFileSync(readmePath, 'utf8') + .replace(/(<)!--\s*|\s*--(>)/g, '$1$2'); + + var $ = marky(markdown), $header = $('h1').first().remove(), version = _.trim($header.find('span').first().text()).slice(1); + // Remove docdown horizontal rules. $('hr').remove(); + // Remove marky-markdown additions. $('[id^="user-content-"]') .attr('class', null) .attr('id', null); @@ -26,9 +33,8 @@ function build(type) { $a.replaceWith($a.html()); }); - var html = _.trim($.html().replace(/(<)!--\s*|\s*--(>)/g, '$1$2')); - - html = [ + // Append YAML front matter. + var html = [ '---', 'id: docs', 'layout: docs', @@ -36,7 +42,7 @@ function build(type) { 'version: ' + (version || null), '---', '', - html, + _.trim($.html()), ].join('\n'); fs.writeFile(path.join(docPath, version + '.html'), html, util.pitch);