chrisdhaan / CDMarkdownKit

An extensive Swift framework providing simple and customizable markdown parsing.
MIT License
250 stars 65 forks source link

Fixed detection of bold and italic markdown within a word #9

Closed FelixLisczyk closed 3 years ago

FelixLisczyk commented 6 years ago

Goals :soccer:

This PR is just a small change to the regex of bold and italic style elements. I've noticed that they don't detect markdown within a word, e.g.

A**B** will now render correctly as AB.

Testing Details :mag:

No tests were added.

chrisdhaan commented 6 years ago

Hey @FelixII this is a great find. Thanks for putting up a fix. The bold fix seems to work fine but the italics fix breaks image parsing. I'm going to have to figure out why that is before merging this in.

FelixLisczyk commented 6 years ago

Oh yes, you're right. The problem is that the image URL in your sample project (https://upload.wikimedia.org/wikipedia/commons/thumb/1/14/Gatto_europeo4.jpg/250px-Gatto_europeo4.jpg) contains two underscores, which does now trigger the italic parser.

I could try to extend the regex to incorporate this edge case. But maybe it would be an even better option to modify the order of the parsed attributes? This way the more complex patterns would be handled first and wouldn't interfere with the more generic ones.

chrisdhaan commented 6 years ago

@FelixII I think that is a good approach. I'll take a look at it today.

FelixLisczyk commented 6 years ago

I've updated the regex again because they missed some special cases like **a** *b*. I've also changed the attribute order to resolve the conflict with images.

chrisdhaan commented 3 years ago

Closing as this is being addressed in #33