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

showdown is adding new break lines #291

Closed
IngenieroFiestero opened this issue Sep 28, 2016 · 9 comments
Closed

showdown is adding new break lines #291

IngenieroFiestero opened this issue Sep 28, 2016 · 9 comments
Assignees

Comments

@IngenieroFiestero
Copy link

IngenieroFiestero commented Sep 28, 2016

Example:
Markdown code:

# Titulo MarkDown\r\nContenido markdown\r\nMas contenido markdown2\r\nMas contenido\r\n### Titulo 2\r\n```\r\nCodigo lelele\r\nmas codigo codigo codigo\r\nadadasdada\r\n<div id=\"someID\" class=\"clear\">\r\n<div id=\"someID\" class=\"clear\"></div>\r\n</div>\r\n```

Html result:

<h1 id=\"titulomarkdown\">Titulo MarkDown</h1>\n\n<p>Contenido markdown\nMas contenido markdown2\nMas contenido</p>\n\n<h3 id=\"titulo2\">Titulo 2</h3>\n\n<pre><code>Codigo lelele\nmas codigo codigo codigo\nadadasdada\n&lt;div id=\"someID\" class=\"clear\"&gt;\n&lt;div id=\"someID\" class=\"clear\"&gt;&lt;/div&gt;\n&lt;/div&gt;\n</code></pre>
@tivie tivie self-assigned this Sep 28, 2016
@tivie
Copy link
Member

tivie commented Sep 28, 2016

What do you mean? More linebreaks in the html output?
Why does it make any difference?

@IngenieroFiestero
Copy link
Author

In

# Titulo MarkDown\r\nContenido markdown\r\nMas contenido markdown

Should be

<h1 id=\"titulomarkdown\">Titulo MarkDown</h1>\n<p>Contenido markdown\nMas contenido markdown

And not

<h1 id=\"titulomarkdown\">Titulo MarkDown</h1>\n\n<p>Contenido markdown\nMas contenido markdown

Showdown is adding a \n after "h1" and after "p" and after "h3"

@tivie
Copy link
Member

tivie commented Sep 28, 2016

Yes, this is used to speed up the parser engine (blocks are wrapped in double linebreaks).
Linebreaks in HTML code are ignored anyways.
Why is it an issue to have extra linebreaks in the output?

@IngenieroFiestero
Copy link
Author

Because i dont want to add more linebreaks. Im saving a text from a textarea in mongodb as a markdown and at the same time saving the HTML generated text, and i want to be precise, I do not want to add anything extra.
I lost a good time thinking it might be, but apparently more markdown to html converters work the same way, I just want to know if there is any way to avoid such behavior.
Thanks

@tivie
Copy link
Member

tivie commented Sep 28, 2016

should be fixed at f97e072, at least partially.
Lists still retain double linebreaks, but those are needed for quickness of the internal parser.
I'm working on a way to remove them without hindering performance

@IngenieroFiestero
Copy link
Author

Wow Thank you very much

@tivie
Copy link
Member

tivie commented Sep 29, 2016

Ok, lists now should be fixed too.

@IngenieroFiestero
Copy link
Author

IngenieroFiestero commented Sep 29, 2016

Okey It works well.
If someone still wants to not let new lines between tags, all you have to do is delete more "\ n" the previous file. In my case following what has made tivie, I modified the dist/showdown.js file not to let "\n" between tags and so is less separately.

text = grafsOut.join('');
result += '<' + listType + '>' + processListItems(txt.slice(0, pos), !!trimTrailing) + '</' + listType + '>';

@IngenieroFiestero
Copy link
Author

IngenieroFiestero commented Sep 29, 2016

Resolved

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

No branches or pull requests

2 participants