Update MD037 to handle violations at the start/end of a line.

This commit is contained in:
David Anson 2019-03-04 19:24:57 -08:00
parent 4d436be500
commit dd3bd3d7ee
2 changed files with 36 additions and 2 deletions

View file

@ -11,10 +11,10 @@ module.exports = {
"function": function MD037(params, onError) {
shared.forEachInlineChild(params, "text", function forToken(token) {
let left = true;
let match = /\s(\*\*?|__?)\s.+\1/.exec(token.content);
let match = /(?:^|\s)(\*\*?|__?)\s.+\1/.exec(token.content);
if (!match) {
left = false;
match = /(\*\*?|__?).+\s\1\s/.exec(token.content);
match = /(\*\*?|__?).+\s\1(?:\s|$)/.exec(token.content);
}
if (match) {
const text = match[0].trim();

View file

@ -1,3 +1,5 @@
# Heading
Line with *Normal emphasis*
Line with **Normal strong**
@ -33,3 +35,35 @@ One-sided * broken emphasis* {MD037}
Don't _flag on _words with underscores before 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 __