marionettejs.com icon indicating copy to clipboard operation
marionettejs.com copied to clipboard

Line breaks in the markdown docs are translated as `<br />` tags erroneously.

Open thenickcox opened this issue 11 years ago • 9 comments

This has been bothering me about the docs for a while. I recently had a documentation PR merged in Marionette core, and part of that removed the line breaks in the docs because they were being converted to <br /> tags. But I was browsing the Markdown docs today, and a Markdown parser should only insert a <br /> tag if there are two line breaks. This is not the case on these docs; each single line break in the docs is parsed as a <br /> tag. (To verify, check the compiled HTML)

I did some digging and thought maybe it was an issue with marked, the markdown parsing library used to compile the docs here. So I made a Codepen to test some markdown with a line break in it, and it correctly renders as a space.

My conclusion at this point is that it's something in the compile-docs.js task. But nothing immediately jumps out to me as being at fault.

I'm filing this issue because I'm working on a PR for some docs, and I had been removing the line breaks so that they don't render as <br /> tags, but I'm now convinced that's not a great solution, because it makes them harder to read.

thenickcox avatar Mar 30 '15 04:03 thenickcox

@thenickcox The only other piece of the process would be our fork of docco that @peterblazejewicz did.

@peterblazejewicz any thoughts?

samccone avatar Mar 30 '15 13:03 samccone

Now that we're talking about it, there is a call in the getDescription method in the compile-docs.js that specifically replaces <br> tags, which shouldn't be necessary with marked's default output. It occurred to me to do the same thing in the compileContent call, but that feels hacky.

thenickcox avatar Mar 30 '15 14:03 thenickcox

hmm open to ideas of fixes that you think can make it better, but yeah all of the docs require a bit of massaging to get "right"

samccone avatar Mar 30 '15 14:03 samccone

I mean, if the core team thought that would be an acceptable fix, far be it from me to say otherwise. Let me know if you'd like me to submit a PR with that same function call (or abstracted to avoid duplication), and I'll go ahead with that.

thenickcox avatar Mar 30 '15 14:03 thenickcox

@thenickcox that would be awesome!

samccone avatar Mar 30 '15 14:03 samccone

Great. The only downside I could see to that is that any intentional <br> tag in the docs would get thrown out. We could add a check for a class like "no-replace" or something, but I don't think I've ever intentionally used a <br> in markdown.

thenickcox avatar Mar 30 '15 14:03 thenickcox

@samccone @thenickcox do compile-docs download only release-based content? So 2.4.1 tagged release content is downloaded, not the current docs from master - if that is true, the changes (line breaks and tweeks) from linked PR are not yet within compiled docs - I've check paragraphs, e.g.: https://github.com/marionettejs/backbone.marionette/commit/18d3227dbdf2b2f515136f30e6516f791b3937a8#diff-65e45658842b27540d8f45490a59c2fbL120

peterblazejewicz avatar Mar 30 '15 19:03 peterblazejewicz

Okay. Thanks to @peterblazejewicz's fix, I should be able to take a look at this tonight.

thenickcox avatar Mar 30 '15 22:03 thenickcox