I tried a couple of markdown support libraries and they all seem to work except for one fact which they all have in common. They don't recognize a single \n , unless I enter \n\n. The libraries I have used are commonmark/ markwon/ bypass. No luck with any of them yet. Anyone else had a similar issue? P.S: the text I am applying a markdown on is uneditable and returned from an API ,
something like "text" = __this__: __name__ \n __that__ : __name__
Any idea how to go about that?
I had the same problem and found a solution.
I used the Markwon library with the following plugin, as mentioned in the Markwon Docs.
Since 4.3.0 there is a dedicated plugin to insert a new line for markdown soft breaks - SoftBreakAddsNewLinePlugin:
final Markwon markwon = Markwon.builder(this) .usePlugin(SoftBreakAddsNewLinePlugin.create()) .build();
This works because a /n is parsed as a softbreak according to the CommonMark Spec.
A single newline has no meaning in Markdown.
For example, the first sentence that I typed into this answer really looks like:
A
single
newline
has
no
meaning
in
Markdown.
A blank line (e.g., two newlines) serves as a block separator for paragraphs, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With