Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get newlines to work properly #240

Closed
Tresky opened this issue Oct 31, 2018 · 4 comments
Closed

Can't get newlines to work properly #240

Tresky opened this issue Oct 31, 2018 · 4 comments
Labels
🙋 no/question This does not need any changes

Comments

@Tresky
Copy link

Tresky commented Oct 31, 2018

I'm attempting to render a string with newlines. I'm pulling my string from an object thats storing a whole mess of metadata for the application. When I try to render it from the object, no newlines are created and the \n's are left in the string to be displayed as normal characters.

However, if I put the exact same string as a string literal (rather than from the object), the newlines work properly.

Works

description () {
  return 'this is my new\nline string'
}
...
<ReactMarkdown source={this.description()} />

Does Not Work

constructor () {
  this.myDescription = 'this is my new\nline string'
}

description () {
  return this.myDescription
}
...
<ReactMarkdown source={this.description()} />

Any insight into this?

@pan-tom
Copy link

pan-tom commented Nov 6, 2018

For me it works only when I put double space before \n.

@jonathanmv
Copy link

See #105. As @pan-tom says, you need double space before the \n to break a line

@NishidaRyu416
Copy link

NishidaRyu416 commented Jan 5, 2020

In my case, I could resolve the issue by replacing \n with \n
I mean \n was considered as just a string somehow without the process.

@wooorm
Copy link
Member

wooorm commented Oct 8, 2020

newlines in paragraphs in markdown are just that: newlines. If you want them to cause br elements, use remark-breaks

@wooorm wooorm closed this as completed Oct 8, 2020
@wooorm wooorm added the 🙋 no/question This does not need any changes label Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 no/question This does not need any changes
Development

No branches or pull requests

5 participants