mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Update MD037 to handle violations at the start/end of a line.
This commit is contained in:
parent
4d436be500
commit
dd3bd3d7ee
2 changed files with 36 additions and 2 deletions
|
|
@ -11,10 +11,10 @@ module.exports = {
|
||||||
"function": function MD037(params, onError) {
|
"function": function MD037(params, onError) {
|
||||||
shared.forEachInlineChild(params, "text", function forToken(token) {
|
shared.forEachInlineChild(params, "text", function forToken(token) {
|
||||||
let left = true;
|
let left = true;
|
||||||
let match = /\s(\*\*?|__?)\s.+\1/.exec(token.content);
|
let match = /(?:^|\s)(\*\*?|__?)\s.+\1/.exec(token.content);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
left = false;
|
left = false;
|
||||||
match = /(\*\*?|__?).+\s\1\s/.exec(token.content);
|
match = /(\*\*?|__?).+\s\1(?:\s|$)/.exec(token.content);
|
||||||
}
|
}
|
||||||
if (match) {
|
if (match) {
|
||||||
const text = match[0].trim();
|
const text = match[0].trim();
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Heading
|
||||||
|
|
||||||
Line with *Normal emphasis*
|
Line with *Normal emphasis*
|
||||||
|
|
||||||
Line with **Normal strong**
|
Line with **Normal strong**
|
||||||
|
|
@ -33,3 +35,35 @@ One-sided * broken emphasis* {MD037}
|
||||||
Don't _flag on _words with underscores before them.
|
Don't _flag on _words with underscores before them.
|
||||||
|
|
||||||
The same goes for words* with asterisks* after them.
|
The same goes for words* with asterisks* after them.
|
||||||
|
|
||||||
|
* Emphasis* with left space is recognized as a list
|
||||||
|
|
||||||
|
** Strong** with left space {MD037}
|
||||||
|
|
||||||
|
_ Emphasis_ with left space {MD037}
|
||||||
|
|
||||||
|
__ Strong__ with left space {MD037}
|
||||||
|
|
||||||
|
*Emphasis * with right space {MD037}
|
||||||
|
|
||||||
|
**Strong ** with right space {MD037}
|
||||||
|
|
||||||
|
_Emphasis _ with right space {MD037}
|
||||||
|
|
||||||
|
__Strong __ with right space {MD037}
|
||||||
|
|
||||||
|
{MD037} Left space * emphasis*
|
||||||
|
|
||||||
|
{MD037} Left space ** strong**
|
||||||
|
|
||||||
|
{MD037} Left space _ emphasis_
|
||||||
|
|
||||||
|
{MD037} Left space __ strong__
|
||||||
|
|
||||||
|
{MD037} Right space *emphasis *
|
||||||
|
|
||||||
|
{MD037} Right space **strong **
|
||||||
|
|
||||||
|
{MD037} Right space _emphasis _
|
||||||
|
|
||||||
|
{MD037} Right space __strong __
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue