markdownToHTML should return a non-optional string
ole opened this issue · comments
Ole Begemann commented
public func markdownToHTML(markdown: String) -> String? {
let outString = cmark_markdown_to_html(markdown, markdown.utf8.count, 0)
return String(UTF8String: outString)
}
I think this function should return a String
instead. If you think about it, any text is valid Markdown, so the conversion can't really fail (or at least it shouldn't). The implementation currently returns nil
if String(UTF8String: outString)
fails, but this should never happen, either. We know cmark_markdown_to_html
returns a valid null-terminated UTF-8 string, after all.
Ole Begemann commented
The same goes for the html
, xml
, commonMark
, and latex
properties on Node
.
Chris Eidhof commented
You are right!