Project

codemark

0.0
No commit activity in last 3 years
No release in over 3 years
Makes Rmd text into R comments and unfences code chunks
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 5.14
~> 0.14
~> 0.13

Runtime

~> 3.5, >= 3.5.1
 Project Readme

CodeMark Gem

Ruby gem to convert RMarkdown (.Rmd) files to pure R scripts (.R)

Main Features

  • Strips out Rmd headers
  • Converts Rmd regular text to R comments
    • Converts headers to comment, marking the header level
    • Wraps text to 80 chars/line and makes each line a comment
    • Converts horizontal rules to commented series of many dashes
  • Converts Rmd code chunks to regular R code
    • Does not copy over non-echoed code (i.e., ignores echo={FALSE|false|F})

Usage

Execute in shell using:

codemark <filename.Rmd> 

CodeMark will produce a corresponding file called filename.R

Testing

There is only one test currently, and it ensures that fixtures are processed accurately (i.e., a given Rmd file is correctly converted into a given R file).

rake spec

If the R file is accurately produced, minitest helpfully shows line diffs between the fixture R file and the generated R script.

If you deliberately change the behavior of CodeMark so that it produces different R output, then you must update the R script fixture:

rake install      # builds and reinstalls codemark gem locally
cd spec/fixtures
codemark sem-intro.Rmd

Contribute

Pull requests and issues are welcome on Github