Markdownosaur
Markdownosaur copied to clipboard
Port to macOS, watchOS and adds support for soft line breaks
These changes make Markdownosaur work on MacOS and iOS
I implemented your soft break implementation and it works, but isn't up to spec with regards to Markdown line breaks. So if you are rendering content, your render might end up looking different than someone else rendering the same content.
Markdown line breaks should be 2 spaces and then a break -> " \n"
I implemented some code to account for this surrounding your soft line break implementation.
mutating public func visitSoftBreak(_ softBreak: SoftBreak) -> NSAttributedString {
return NSAttributedString(string: " ")
}
mutating public func visitLineBreak(_ lineBreak: LineBreak) -> NSAttributedString {
let result = NSMutableAttributedString()
for child in lineBreak.children {
result.append(visit(child))
}
result.append(.singleNewline(withFontSize: baseFontSize))
return result
}
Soft line breaks being turned into spaces, since this would cause some new sentences to not have a space in front of them without this soft break inserting one in its place. Hope this helps! Thank you for your useful PR.