markdownlint icon indicating copy to clipboard operation
markdownlint copied to clipboard

MD037: false positive for nested asterisks within an emphasized word

Open wvanderp opened this issue 2 years ago • 7 comments

markdownlint marks the following markdown as having an error:

**co****ha**bitation **pro**ject

image

I don't have any ideas for a fix but I am available for more questions. and I might be able to look into it some day

wvanderp avatar Jun 21 '22 13:06 wvanderp

Is this a real example? I think it could be written more simply in a way that would not trigger this violation.

DavidAnson avatar Jun 21 '22 15:06 DavidAnson

My idea to use "_" didn't work, but here is something that is a little more clear about what it's trying to do and doesn't produce a violation: **co\*\*\*\*ha**bitation **pro**ject

DavidAnson avatar Jun 21 '22 15:06 DavidAnson

My goal is to highlight co, ha, and pro.

So that it is cohabilitation project

Although I see now that removing the asterisks between the letters is a better option and that GitHubs markdown parser also struggles with my notation

**Co****ha**bilitation **pro**ject results in Co****habilitation project

wvanderp avatar Jun 21 '22 16:06 wvanderp

If your intent is not to include the asterisks, then your original text is not what do you want under CommonMark: http://markdown-it.github.io/#md3=%7B%22source%22%3A%22%2A%2Aco%2A%2A%2A%2Aha%2A%2Abitation%20%2A%2Apro%2A%2Aject%22%2C%22defaults%22%3A%7B%22html%22%3Afalse%2C%22xhtmlOut%22%3Afalse%2C%22breaks%22%3Afalse%2C%22langPrefix%22%3A%22language-%22%2C%22linkify%22%3Atrue%2C%22typographer%22%3Atrue%2C%22_highlight%22%3Atrue%2C%22_strict%22%3Afalse%2C%22_view%22%3A%22html%22%7D%7D

Why not just **coha** like you did with "project"?

DavidAnson avatar Jun 21 '22 18:06 DavidAnson

Thank you for working through the problem with me.

So my practical problem is solved now. But now, we are left with a theoretical problem.

When I look at the "ast" on the page you linked, then co****ha is marked as plain text surrounded by bold tags. and by extension, it doesn't have any problems

The inclusion of asterisks in the bolt tags messes up the parsing done by this program. Because it things bilitation is inside of the tags.

You can put this report at the bottom of the pile or close it because who would put asterisks inside of bold tags :) but I do honestly think that this is something to someday look at.

Thanks again for the quick responses and the help

wvanderp avatar Jun 21 '22 19:06 wvanderp

Yes, thanks, I am leaving this open because I really try not to report issues against valid Markdown.

DavidAnson avatar Jun 21 '22 19:06 DavidAnson

I'm going to tag this "Enhancement" instead of "Bug" which is technically a cheat, but this feels like a pretty unlikely scenario with seemingly unpredictable behavior that I think simple regular expression parsing isn't going to be able to deal with easily: example.

DavidAnson avatar Jun 22 '22 03:06 DavidAnson