Skip to content

Instantly share code, notes, and snippets.

@adomingues
Last active March 21, 2018 14:25
Show Gist options
  • Save adomingues/96f6cc427cf991360a97 to your computer and use it in GitHub Desktop.
Save adomingues/96f6cc427cf991360a97 to your computer and use it in GitHub Desktop.
A simple wrapper to knit an Rmd file to output an html from the comand-line using Pandoc.
#!/bin/bash
infile=$1
if [[ $infile == *.Rmd ]]
then
echo "Knitting Rmd file"
Rscript -e "library(knitr); knit('$infile')";
name=${infile%.Rmd}
else
echo "Markdown file"
name=${infile%.md}
fi
# pandoc --from=markdown --to=html --output=$name".html" -s --highlight-style tango $name".md"
OUTFILE=$name
Rscript -e "rmarkdown::render('${OUTFILE}.md', 'html_document', output_file = '${OUTFILE}.html')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment