Skip to content

Commit

Permalink
tools: update doc tools to remark-parse@9.0.0
Browse files Browse the repository at this point in the history
PR-URL: #36049
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
  • Loading branch information
Trott authored and codebytere committed Nov 22, 2020
1 parent 500e709 commit 63494e4
Show file tree
Hide file tree
Showing 6 changed files with 1,362 additions and 63 deletions.
3 changes: 2 additions & 1 deletion tools/doc/addon-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ const { resolve } = require('path');
const vfile = require('to-vfile');
const unified = require('unified');
const remarkParse = require('remark-parse');
const gfm = require('remark-gfm');

const rootDir = resolve(__dirname, '..', '..');
const doc = resolve(rootDir, 'doc', 'api', 'addons.md');
const verifyDir = resolve(rootDir, 'test', 'addons');

const file = vfile.readSync(doc, 'utf8');
const tree = unified().use(remarkParse).parse(file);
const tree = unified().use(remarkParse).use(gfm).parse(file);
const addons = {};
let id = 0;
let currentHeader;
Expand Down
1 change: 1 addition & 0 deletions tools/doc/checkLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function findMarkdownFilesRecursively(dirPath) {
function checkFile(path) {
const tree = unified()
.use(require('remark-parse'))
.use(require('remark-gfm'))
.parse(fs.readFileSync(path));

const base = pathToFileURL(path);
Expand Down
2 changes: 2 additions & 0 deletions tools/doc/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const { promises: fs } = require('fs');
const path = require('path');
const unified = require('unified');
const markdown = require('remark-parse');
const gfm = require('remark-gfm');
const remark2rehype = require('remark-rehype');
const raw = require('rehype-raw');
const htmlStringify = require('rehype-stringify');
Expand Down Expand Up @@ -82,6 +83,7 @@ async function main() {
const content = await unified()
.use(replaceLinks, { filename, linksMapper })
.use(markdown)
.use(gfm)
.use(html.preprocessText, { nodeVersion })
.use(json.jsonAPI, { filename })
.use(html.firstHeader)
Expand Down
4 changes: 4 additions & 0 deletions tools/doc/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const unified = require('unified');
const find = require('unist-util-find');
const visit = require('unist-util-visit');
const markdown = require('remark-parse');
const gfm = require('remark-gfm');
const remark2rehype = require('remark-rehype');
const raw = require('rehype-raw');
const htmlStringify = require('rehype-stringify');
Expand Down Expand Up @@ -56,6 +57,7 @@ const gtocMD = fs.readFileSync(gtocPath, 'utf8')
.replace(/^<!--.*?-->/gms, '');
const gtocHTML = unified()
.use(markdown)
.use(gfm)
.use(remark2rehype, { allowDangerousHtml: true })
.use(raw)
.use(navClasses)
Expand Down Expand Up @@ -283,6 +285,7 @@ function parseYAML(text) {
meta.changes.forEach((change) => {
const description = unified()
.use(markdown)
.use(gfm)
.use(remark2rehype, { allowDangerousHtml: true })
.use(raw)
.use(htmlStringify)
Expand Down Expand Up @@ -381,6 +384,7 @@ function buildToc({ filename, apilinks }) {

file.toc = unified()
.use(markdown)
.use(gfm)
.use(remark2rehype, { allowDangerousHtml: true })
.use(raw)
.use(htmlStringify)
Expand Down
Loading

0 comments on commit 63494e4

Please sign in to comment.