From 96dec7e0d93ef40da037b8e60ca52cf2a4ad807d Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Tue, 20 Mar 2018 13:25:45 +0200 Subject: [PATCH] tools: fix nits in tools/doc/preprocess.js --- tools/doc/preprocess.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/doc/preprocess.js b/tools/doc/preprocess.js index 652f12a9f05472..5b6901153dc61f 100644 --- a/tools/doc/preprocess.js +++ b/tools/doc/preprocess.js @@ -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) { @@ -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]);