Why does R Markdown to HTML insert <br/> when there is a new line of text?

jkanglim's Avatar

jkanglim

17 May, 2012 01:33 AM

My understanding of Markdown to HTML conversion is that the following markdown:

This is some text.
And this is some more text.

should be rendered:

<p>
This is some text.
And this is some more text.
</p>

but R studio 0.96 seems to render it

 <p>
 This is some text.<br/>
 And this is some more text.
 </p>

This is certainly the behaviour on StackExchange and I'm pretty sure it's the behaviour on Markdown.pl ( http://daringfireball.net/projects/markdown/ )

It enables the writer to use line breaks to improve readability without having formatting implications.

  • Is this a mistake or an intentional feature?
  • Is there a way of disabling it?

P.S. I'm really impressed with R Markdown in R Studio 0.96.

  1. Support Staff 2 Posted by Josh Paulson on 17 May, 2012 02:11 PM

    Josh Paulson's Avatar

    Hello,

    Thanks for the feedback and glad you are enjoying the new features in 0.96. Also this behavior is intended (currently no way to change this) as we use GitHub Flavored Markdown:

    http://github.github.com/github-flavored-markdown/

    See the section on newlines which explains why this change was made. Hope this helps.

    Josh

  2. 3 Posted by jkanglim on 17 May, 2012 11:48 PM

    jkanglim's Avatar

    Thanks for the clarification.
    From reading the github post it sounds like many people like github's line break behaviour.

    I'll probably just use a sed script to remove the pesky br tags.

  3. Support Staff 4 Posted by Josh Paulson on 18 May, 2012 04:12 AM

    Josh Paulson's Avatar

    Sounds good and thanks again for the feedback. We definitely appreciate it and let us know what else you like/dislike or new features to add.

    Josh

  4. Josh Paulson closed this discussion on 18 May, 2012 04:12 AM.

  5. JJ Allaire re-opened this discussion on 25 Jun, 2012 07:52 PM

  6. Support Staff 5 Posted by JJ Allaire on 25 Jun, 2012 07:52 PM

    JJ Allaire's Avatar

    We've now implemented the ability to customize the markdown back-end. It's available in daily build 0.96.315 (which we haven't formally released yet but will within the next week or so):

    http://www.rstudio.org/download/daily/

    This basically works by allowing you to provide a custom markdown rendering function. The docs are here:

    http://www.rstudio.org/docs/authoring/markdown_custom_rendering

    The docs include examples of using a custom stylesheet, overriding the <br/> behavior, as well as calling pandoc rather than the the markdown package. Hope this works the way you'd like it to, let us know if you have questions or any other suggestions.

    J.J.

  7. Josh Paulson closed this discussion on 28 Jun, 2012 12:53 PM.

Comments are currently closed for this discussion. You can start a new one.