mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Update MD035/hr-style to preserve embedded spaces in thematic break markup (fixes #498).
This commit is contained in:
parent
b447c809bd
commit
7a5886b976
9 changed files with 49 additions and 10 deletions
|
@ -3613,9 +3613,14 @@ module.exports = {
|
||||||
"description": "Horizontal rule style",
|
"description": "Horizontal rule style",
|
||||||
"tags": ["hr"],
|
"tags": ["hr"],
|
||||||
"function": function MD035(params, onError) {
|
"function": function MD035(params, onError) {
|
||||||
var style = String(params.config.style || "consistent");
|
var style = String(params.config.style || "consistent").trim();
|
||||||
filterTokens(params, "hr", function (token) {
|
filterTokens(params, "hr", function (token) {
|
||||||
var lineNumber = token.lineNumber, markup = token.markup;
|
var line = token.line, lineNumber = token.lineNumber;
|
||||||
|
var markup = token.markup;
|
||||||
|
var match = line.match(/[_*\-\s\t]+$/);
|
||||||
|
if (match) {
|
||||||
|
markup = match[0].trim();
|
||||||
|
}
|
||||||
if (style === "consistent") {
|
if (style === "consistent") {
|
||||||
style = markup;
|
style = markup;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,14 @@ module.exports = {
|
||||||
"description": "Horizontal rule style",
|
"description": "Horizontal rule style",
|
||||||
"tags": [ "hr" ],
|
"tags": [ "hr" ],
|
||||||
"function": function MD035(params, onError) {
|
"function": function MD035(params, onError) {
|
||||||
let style = String(params.config.style || "consistent");
|
let style = String(params.config.style || "consistent").trim();
|
||||||
filterTokens(params, "hr", (token) => {
|
filterTokens(params, "hr", (token) => {
|
||||||
const { lineNumber, markup } = token;
|
const { line, lineNumber } = token;
|
||||||
|
let { markup } = token;
|
||||||
|
const match = line.match(/[_*\-\s\t]+$/);
|
||||||
|
if (match) {
|
||||||
|
markup = match[0].trim();
|
||||||
|
}
|
||||||
if (style === "consistent") {
|
if (style === "consistent") {
|
||||||
style = markup;
|
style = markup;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,4 +36,4 @@ ___
|
||||||
>
|
>
|
||||||
> Text
|
> Text
|
||||||
|
|
||||||
{MD035:31} {MD035:33}
|
{MD035:23} {MD035:31} {MD035:33}
|
||||||
|
|
|
@ -36,4 +36,4 @@ ___
|
||||||
>
|
>
|
||||||
> Text
|
> Text
|
||||||
|
|
||||||
{MD035:29} {MD035:33}
|
{MD035:23} {MD035:29} {MD035:33}
|
||||||
|
|
|
@ -36,4 +36,4 @@ _ _ _
|
||||||
>
|
>
|
||||||
> Text
|
> Text
|
||||||
|
|
||||||
{MD035:29} {MD035:31}
|
{MD035:23} {MD035:29} {MD035:31}
|
||||||
|
|
28
test/hr-style-custom.md
Normal file
28
test/hr-style-custom.md
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# HR Style Custom
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
---
|
||||||
|
{MD035:5}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
- - -
|
||||||
|
{MD035:10}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
- - -
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
***
|
||||||
|
{MD035:19}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
<!-- markdownlint-configure-file {
|
||||||
|
"hr-style": {
|
||||||
|
"style": "- - -"
|
||||||
|
}
|
||||||
|
} -->
|
|
@ -20,4 +20,5 @@ _____
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
{MD035:3} {MD035:5} {MD035:7} {MD035:13} {MD035:15} {MD035:17} {MD035:19} {MD035:21}
|
{MD035:3} {MD035:5} {MD035:7} {MD035:11} {MD035:13}
|
||||||
|
{MD035:15} {MD035:17} {MD035:19} {MD035:21}
|
||||||
|
|
|
@ -20,4 +20,4 @@ _____
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
{MD035:7} {MD035:9} {MD035:11} {MD035:13} {MD035:15} {MD035:17} {MD035:19}
|
{MD035:5} {MD035:7} {MD035:9} {MD035:11} {MD035:13} {MD035:15} {MD035:17} {MD035:19}
|
||||||
|
|
|
@ -20,4 +20,4 @@ _____
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
{MD035:7} {MD035:9} {MD035:11} {MD035:13} {MD035:15} {MD035:17} {MD035:19}
|
{MD035:5} {MD035:7} {MD035:9} {MD035:11} {MD035:13} {MD035:15} {MD035:17} {MD035:19}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue