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 <tniessen@tnie.de>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
  • Loading branch information
vsemozhetbyt authored and targos committed Mar 24, 2018
1 parent d3833b0 commit 89e7a5f
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 89e7a5f

Please sign in to comment.