Reimplement MD037/no-space-in-emphasis to better handle multiple fixes on a line and more scenarios (fixes #251).

This commit is contained in:
David Anson 2020-03-28 14:16:28 -07:00
parent de86a26e4e
commit 29f16bf402
4 changed files with 121 additions and 40 deletions

View file

@ -1,28 +1,42 @@
# Heading
## Single-character markers
None are valid emphasis without spaces.
Escaped asterisks \* should \* be ignored by MD037.
Escaped asterisks \* should * be ignored by MD037.
Escaped asterisks * should \* be ignored by MD037.
Escaped asterisks \** should ** be ignored by MD037.
Escaped asterisks *\* should ** be ignored by MD037.
Escaped asterisks ** should \** be ignored by MD037.
Escaped asterisks ** should *\* be ignored by MD037.
Escaped underscores \_ should \_ be ignored by MD037.
Escaped underscores \_ should _ be ignored by MD037.
Escaped underscores _ should \_ be ignored by MD037.
Escaped underscores \__ should __ be ignored by MD037.
## Double-character markers, start
Escaped underscores _\_ should __ be ignored by MD037.
All should be reported because they are valid single-character
marker emphasis without spaces.
Escaped asterisks \** should ** be ignored by MD037. {MD037}
Escaped asterisks *\* should ** be ignored by MD037. {MD037}
Escaped underscores \__ should __ be ignored by MD037. {MD037}
Escaped underscores _\_ should __ be ignored by MD037. {MD037}
## Double-character markers, end
All should be reported, but are ignored because they look like
the start of an embedded emphasis.
Escaped asterisks ** should \** be ignored by MD037.
Escaped asterisks ** should *\* be ignored by MD037.
Escaped underscores __ should \__ be ignored by MD037.

View file

@ -44,9 +44,11 @@ One-sided *broken emphasis * {MD037}
One-sided * broken emphasis* {MD037}
Don't _flag on _words with underscores before them.
Will _flag on _words with underscores before them. {MD037}
The same goes for words* with asterisks* after them.
The same goes for words* with asterisks* after them. {MD037}
But not with escaped\* asterisks\* \_and \_underscores.
* Emphasis* with left space is recognized as a list
@ -95,3 +97,31 @@ ___Strong and emphasis ___ with right space {MD037}
{MD037} Right space __strong __
{MD037} Right space ___strong and emphasis ___
**Multiple ** spaces **in ** emphasis **at ** once. {MD037}
**Multiple ** spaces ** in** emphasis ** at ** once. {MD037}
This is * an ambiguous * scenario {MD037}
* List item *with emphasis* on the
first and *second lines*.
* List * item* {MD037}
* List *item * {MD037}
* List * item * {MD037}
* List item with
*hanging* emphasis
and * some* lines {MD037}
with *space * problems {MD037}
throughout * the * content {MD037}
Uncommon scenarios from the CommonMark specification:
***strong emph***
***strong** in emph*
***emph* in strong**
**in strong *emph***
*in emph **strong***
```markdown
Violations * are * allowed in code blocks where emphasis does not apply.
```