macteo / Marklight

Markdown syntax highlighter for iOS
Other
638 stars 44 forks source link

add support for bold-italic #6

Closed DivineDominion closed 7 years ago

DivineDominion commented 7 years ago

Have been tinkering away on this. And boy did the italics regex get longer ...

let strictItalicPattern: String = [
        "(^|[\\W_]) (?:(?!\\1)|(?=^))",
        "(\\*|_)(?:(?!\\2)|(?=\\2\\2)) (?=\\S)", // opening
            "(.*?(?!\\2)\\S)",                  // content
        "\\2(?:(?!\\2)|(?=\\2\\2))",            // closing
        "(?=[\\W_]|$)"
        ].joined(separator: "")

For reference, here's the Regex in a debugger: https://regex101.com/r/mveS1B/2