Update MD026/no-trailing-punctuation to ignore the trailing semicolon of HTML entity references (fixes #320).

This commit is contained in:
David Anson 2020-11-23 15:23:39 -08:00
parent 09c5736385
commit c693a9a3d8
3 changed files with 33 additions and 1 deletions

View file

@ -922,6 +922,10 @@ allowed by default because of how common it is in headings of FAQ-style document
Setting the `punctuation` parameter to `""` allows all characters - and is
equivalent to disabling the rule.
Note: The trailing semicolon of
[HTML entity references](https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references)
like `©`, `©`, and `©` is ignored by this rule.
Rationale: Headings are not meant to be full sentences. More information:
<https://cirosantilli.com/markdown-style-guide#punctuation-at-the-end-of-headers>

View file

@ -5,6 +5,8 @@
const { addError, allPunctuationNoQuestion, escapeForRegExp, forEachHeading } =
require("../helpers");
const endOfLineHtmlEntityRe = /&#?[0-9a-zA-Z]+;$/;
module.exports = {
"names": [ "MD026", "no-trailing-punctuation" ],
"description": "Trailing punctuation in heading",
@ -20,7 +22,7 @@ module.exports = {
const { line, lineNumber } = heading;
const trimmedLine = line.replace(/[\s#]*$/, "");
const match = trailingPunctuationRe.exec(trimmedLine);
if (match) {
if (match && !endOfLineHtmlEntityRe.test(trimmedLine)) {
const fullMatch = match[0];
const column = match.index + 1;
const length = fullMatch.length;

View file

@ -0,0 +1,26 @@
# headings-with-html-entities
<!-- markdownlint-disable heading-style -->
## Copyright &copy; 2000
## Copyright 2001 &copy;
## Copyright 2002&copy;
## Copyright 2003 &COPY;
## Copyright 2004 &#x000A9;
## Copyright 2005 &#169;
## Copyright 2006 &#169; ##
Copyright 2007 &copy;
---------------------
## Copyright 2008 {MD026} copy;
## Copyright 2009 {MD026} #x000A9;
## Copyright 2010 {MD026} #169;