Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress line breaks created by RMarkdown

I am using a Rmarkdown (.Rmd) document to generate a markdown (.md) document for use with a Jekyll blog. I use knitr to create the .md file from the .Rmd file and there are additional line breaks in the .md file that were not in the original .Rmd document. These line breaks are not visible when the post displays on my Jekyll blog, but unfortunately the line breaks are visible when the post displays on R-Bloggers.

Is there a way I can configure my knit settings so that additional line breaks are not created when generating my .md document? Links to my Rmarkdown and outputted Markdown file are below for reference.

EDIT - Note that the files linked to below are now updated with the pandoc_args solution suggested below. Before the pandoc_args argument was added to the YAML, the .md file had extra line breaks.

  • .Rmd file
  • .md file
like image 367
Jesse Cambon Avatar asked Oct 21 '25 03:10

Jesse Cambon


1 Answers

These line breaks are (probably) caused by pandoc and can be controlled with the --wrap option. You should use --wrap=none or --wrap=preserve. You can specify such options in the YAML header:

output:
  md_document:
    pandoc_args: ["--wrap=preserve"]
like image 73
Ralf Stubner Avatar answered Oct 22 '25 18:10

Ralf Stubner