Skip to content

Commit

Permalink
tools: fix nits in tools/doc/preprocess.js
Browse files Browse the repository at this point in the history
PR-URL: #19473
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
  • Loading branch information
vsemozhetbyt authored and MylesBorins committed Aug 17, 2018
1 parent e1c28b6 commit 2fb47a5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tools/doc/preprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = preprocess;
const path = require('path');
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 = {};

function preprocess(inputFile, input, cb) {
Expand All @@ -20,12 +20,12 @@ function stripComments(input) {
function processIncludes(inputFile, input, cb) {
const includes = input.match(includeExpr);
if (includes === null) return cb(null, input);
var errState = null;
var incCount = includes.length;
if (incCount === 0) cb(null, input);
includes.forEach(function(include) {
var fname = include.replace(/^@include\s+/, '');
if (!fname.match(/\.md$/)) fname = `${fname}.md`;
let errState = null;
let incCount = includes.length;

includes.forEach((include) => {
let fname = include.replace(/^@include\s+/, '');
if (!/\.md$/.test(fname)) fname = `${fname}.md`;

if (includeData.hasOwnProperty(fname)) {
input = input.split(include).join(includeData[fname]);
Expand Down

0 comments on commit 2fb47a5

Please sign in to comment.