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

Marked doesn't work with literal newlines #45

Closed
OscarGodson opened this issue Apr 21, 2012 · 2 comments
Closed

Marked doesn't work with literal newlines #45

OscarGodson opened this issue Apr 21, 2012 · 2 comments

Comments

@OscarGodson
Copy link

Re: OscarGodson/EpicEditor#75

Think i figured it out. Marked doesn't know what to do with literal \n like this:

marked('hello  \
world');

I think this is in fact a bug with Marked since in this example, native JSON.parse will convert that and to get it to work with Marked we'd have to go and add \n (the text, not literal) in place of it. What do think?

@chjj
Copy link
Member

chjj commented Apr 21, 2012

There is no such thing as literal or non-literal newlines/line-feeds at runtime. Newlines are just bytes at runtime.

Your line feed there is being escaped by the backslash, which is why you're able to (syntactically) create a multiple-line string. A newline is not actually added to the string because it had to be escaped in order to do that. It's just a syntactic feature of javascript.

This is the case anywhere else in javascript too:

var a = 'hello  \
world';
console.log(a);
console.log(a.length);
console.log(a.indexOf('\n') === -1);
console.log(a !== 'hello  \nworld');

@OscarGodson
Copy link
Author

Awh, I see, ok thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants