macteo / Marklight

Markdown syntax highlighter for iOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

add support for bold-italic

DivineDominion opened this issue · comments

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