diff --git a/demo/markdownlint-browser.js b/demo/markdownlint-browser.js index 1333667c..de7bad92 100644 --- a/demo/markdownlint-browser.js +++ b/demo/markdownlint-browser.js @@ -2979,7 +2979,7 @@ module.exports = { var trailingPunctuationRe = new RegExp("\\s*[" + escapeForRegExp(punctuation) + "]+$"); forEachHeading(params, function (heading) { var line = heading.line, lineNumber = heading.lineNumber; - var trimmedLine = line.replace(/[\s#]*$/, ""); + var trimmedLine = line.replace(/([^\s#])[\s#]+$/, "$1"); var match = trailingPunctuationRe.exec(trimmedLine); if (match && !endOfLineHtmlEntityRe.test(trimmedLine)) { var fullMatch = match[0]; diff --git a/lib/md026.js b/lib/md026.js index d9bb0c26..0a517d79 100644 --- a/lib/md026.js +++ b/lib/md026.js @@ -20,7 +20,7 @@ module.exports = { new RegExp("\\s*[" + escapeForRegExp(punctuation) + "]+$"); forEachHeading(params, (heading) => { const { line, lineNumber } = heading; - const trimmedLine = line.replace(/[\s#]*$/, ""); + const trimmedLine = line.replace(/([^\s#])[\s#]+$/, "$1"); const match = trailingPunctuationRe.exec(trimmedLine); if (match && !endOfLineHtmlEntityRe.test(trimmedLine)) { const fullMatch = match[0];