I found the solution to my problem on the developer forums, thanks to Alex Hay!
Check out App.swift
. I'm reading the Sample.md
file by loading it with String(contentsOf:
and then displaying the content.
The first 3 versions are with Apple's built-in Markdown rendering.
- Parses correctly the string with the breaklines, but sadly without Markdown.
- Parses correctly the Markdown, but without the break lines.
- Is the trick. More later.
- Uses the better MarkdownUI and boy is it simpler!
- If there's no new line after the first line, it's because I'm not adding 2 spaces at the end of the line.
- This also means that Apple isn't Markdown conform in their Library...
- MarkdownUI renders this correctly...
So you need to call this cumbersome options: .init(interpretedSyntax: .inlineOnlyPreservingWhitespace)
, which never refers to break line.
To me, this is a bug, which I'm going to file at Apple now.
Because I'm trying to avoid using external libraries when not absolutely necessary, for now, I will not use MarkdownUI, but sooner or later, I might have to, also because it renders a whole more Markdown!