tools: fix nits in tools/doc/preprocess.js
PR-URL: https://github.com/nodejs/node/pull/19473 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
This commit is contained in:
parent
41193bcf2f
commit
1d42b2018f
@ -5,7 +5,7 @@ module.exports = preprocess;
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const includeExpr = /^@include\s+([A-Za-z0-9-_]+)(?:\.)?([a-zA-Z]*)$/gmi;
|
const includeExpr = /^@include\s+[\w-]+\.?[a-zA-Z]*$/gmi;
|
||||||
const includeData = {};
|
const includeData = {};
|
||||||
|
|
||||||
function preprocess(inputFile, input, cb) {
|
function preprocess(inputFile, input, cb) {
|
||||||
@ -20,12 +20,12 @@ function stripComments(input) {
|
|||||||
function processIncludes(inputFile, input, cb) {
|
function processIncludes(inputFile, input, cb) {
|
||||||
const includes = input.match(includeExpr);
|
const includes = input.match(includeExpr);
|
||||||
if (includes === null) return cb(null, input);
|
if (includes === null) return cb(null, input);
|
||||||
var errState = null;
|
let errState = null;
|
||||||
var incCount = includes.length;
|
let incCount = includes.length;
|
||||||
if (incCount === 0) cb(null, input);
|
|
||||||
includes.forEach(function(include) {
|
includes.forEach((include) => {
|
||||||
var fname = include.replace(/^@include\s+/, '');
|
let fname = include.replace(/^@include\s+/, '');
|
||||||
if (!fname.match(/\.md$/)) fname = `${fname}.md`;
|
if (!/\.md$/.test(fname)) fname = `${fname}.md`;
|
||||||
|
|
||||||
if (includeData.hasOwnProperty(fname)) {
|
if (includeData.hasOwnProperty(fname)) {
|
||||||
input = input.split(include).join(includeData[fname]);
|
input = input.split(include).join(includeData[fname]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user