mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Update MD026/no-trailing-punctuation to ignore the trailing semicolon of HTML entity references (fixes #320).
This commit is contained in:
parent
09c5736385
commit
c693a9a3d8
3 changed files with 33 additions and 1 deletions
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
26
test/headings-with-html-entities.md
Normal file
26
test/headings-with-html-entities.md
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# headings-with-html-entities
|
||||
|
||||
<!-- markdownlint-disable heading-style -->
|
||||
|
||||
## Copyright © 2000
|
||||
|
||||
## Copyright 2001 ©
|
||||
|
||||
## Copyright 2002©
|
||||
|
||||
## Copyright 2003 ©
|
||||
|
||||
## Copyright 2004 ©
|
||||
|
||||
## Copyright 2005 ©
|
||||
|
||||
## Copyright 2006 © ##
|
||||
|
||||
Copyright 2007 ©
|
||||
---------------------
|
||||
|
||||
## Copyright 2008 {MD026} copy;
|
||||
|
||||
## Copyright 2009 {MD026} #x000A9;
|
||||
|
||||
## Copyright 2010 {MD026} #169;
|
||||
Loading…
Add table
Add a link
Reference in a new issue