Internal space line is trimmed in converted plaintext
Convert markdown to plaintext using:
private fun convertMarkdownToPlaintext(markdown: String): String {
val parser = Parser.builder().build()
val document = parser.parse(markdown)
val renderer = TextContentRenderer.builder().build()
return renderer.render(document)
}
Example:
this
is
**note**
Expected behavior:
Expected plaintext:
this
is
note
Actual plaintext:
this
is
note
(Also see what the reference implementation does: https://spec.commonmark.org/dingus/)
您好!邮件已收到。
The plain text renderer is not really well-defined. But this is something we might change (CC @JinneeJ). Out of interest, what are you using it for?
I use this to convert markdown from a rich text editor on Android.
Ah this came up in https://github.com/commonmark/commonmark-java/issues/264 as well. Happy to accept a patch for this as an option on TextContentRenderer.Builder.
Closing as a duplicate of #264