Skip to content

Commit 89e7a5f

Browse files
vsemozhetbyttargos
authored andcommitted
tools: fix nits in tools/doc/preprocess.js
PR-URL: #19473 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
1 parent d3833b0 commit 89e7a5f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tools/doc/preprocess.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = preprocess;
55
const path = require('path');
66
const fs = require('fs');
77

8-
const includeExpr = /^@include\s+([A-Za-z0-9-_]+)(?:\.)?([a-zA-Z]*)$/gmi;
8+
const includeExpr = /^@include\s+[\w-]+\.?[a-zA-Z]*$/gmi;
99
const includeData = {};
1010

1111
function preprocess(inputFile, input, cb) {
@@ -20,12 +20,12 @@ function stripComments(input) {
2020
function processIncludes(inputFile, input, cb) {
2121
const includes = input.match(includeExpr);
2222
if (includes === null) return cb(null, input);
23-
var errState = null;
24-
var incCount = includes.length;
25-
if (incCount === 0) cb(null, input);
26-
includes.forEach(function(include) {
27-
var fname = include.replace(/^@include\s+/, '');
28-
if (!fname.match(/\.md$/)) fname = `${fname}.md`;
23+
let errState = null;
24+
let incCount = includes.length;
25+
26+
includes.forEach((include) => {
27+
let fname = include.replace(/^@include\s+/, '');
28+
if (!/\.md$/.test(fname)) fname = `${fname}.md`;
2929

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

0 commit comments

Comments
 (0)