SimonFairbairn / SwiftyMarkdown

Converts Markdown files and strings into NSAttributedStrings with lots of customisation options.
MIT License
1.64k stars 275 forks source link

Crash when text starts with `---` #99

Open amadeu01 opened 3 years ago

amadeu01 commented 3 years ago

When we attempt to create a new SwiftyMarkdown using one string that starts with the characters --- it will break. It does not happen if you have something before the ---, such as . ---

How we are currently using the lib ⤵️

            let markDown = SwiftyMarkdown(string: text)
            self.descriptionLabel.attributedText = markDown.attributedString()

It might be related to ⤵️

static public var frontMatterRules = [
        FrontMatterRule(openTag: "---", closeTag: "---", keyValueSeparator: ":")
    ]
ellstang commented 3 years ago

I am the same issue in my project too Have to implement a string checking and insert a transparent character in the beginning of the string (if the first three characters are ---)

cometheart314 commented 2 years ago

I have the same issue with the frontMatterRules.

What is the frontMatterRules?

If the string that start with "---", the contents between the start "---" and the next "---" are all gone in the result attributed text.