jeziellago / compose-markdown

Markdown Text for Android Jetpack Compose 📋.
MIT License
508 stars 42 forks source link

No support for "\n" mark #43

Closed tryboxx closed 10 months ago

tryboxx commented 1 year ago

The \n mark in string is ignored when using MarkdownText - it appears as an empty space between the words.

Screenshot_20230512_094800

jeziellago commented 1 year ago

Hello, @tryboxx Can you provide a code snippet to reproduce this error? Make sure the content keeps the markdown standards.

vitorhugods commented 11 months ago
Multiple
Lines

Is rendered like:

MultipleLines

I've seen this behaviour happening on some Markdown editors already, and I remember it annoyed me. But at least GitHub and Confluence/Jira provide a WYSIWYG experience for this.

tryboxx commented 11 months ago

Sure @jeziellago, thats my implementation of the string from the screenshot:

"• low porosity hair\n• medium porosity hair\n• high porosity hair"

MarkdownText(
    markdown = highlightedSection.content,
    color = Color.Black,
    style = AppTheme.typography.normalText2
)
vitorhugods commented 11 months ago

Keep in mind that Markdown ignores single line break on purpose.

I'm not sure what would be the best solution for this case.

Maybe replacing \n with \n\n if you are sure that the content wasn't originally written with Markdown in mind.

tryboxx commented 11 months ago

You're right, but that's why I reported this issue - in my opinion, every markdown library should handle this case with some workaround, like Swift libraries do. It can be handled on library side, by default.

ArjixWasTaken commented 11 months ago

Usually when I want to go insert a new line, but markdown refuses to comply, I just use <br />. It doesn't leave the huge gap that double new lines leave.

(dunno if this library supports the <br /> tag, I just posted my general solution to this problem)

turik2304 commented 10 months ago

@jeziellago maybe add this plugin?

.usePlugin(SoftBreakAddsNewLinePlugin.create())