The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Title: Pre-Knitting Processing and Post HTML-Rendering Processing
Version: 0.1.0
Date: 2016-06-05
Author: Chin Soon Lim [aut]
Maintainer: Chin Soon Lim <chinsoon12@hotmail.com>
Description: Dynamize headers or R code within 'Rmd' files to prevent proliferation of 'Rmd' files for similar reports. Add in external HTML document within 'rmarkdown' rendered HTML doc.
Depends: R (≥ 3.3.0)
Imports: utils, tools, XML (≥ 3.98-1.4), knitr (≥ 1.13), rmarkdown (≥ 0.9.6)
SystemRequirements: pandoc (>= 1.12.3) - http://johnmacfarlane.net/pandoc
License: GPL-2 | GPL-3 | file LICENSE [expanded from: GPL (≥ 2) | file LICENSE]
RoxygenNote: 5.0.1
URL: https://github.com/chinsoon12/PreKnitPostHTMLRender
BugReports: https://github.com/chinsoon12/PreKnitPostHTMLRender
NeedsCompilation: no
Packaged: 2016-06-06 12:11:55 UTC; ChinSoon
Repository: CRAN
Date/Publication: 2016-06-06 17:56:44

Eval a character array of code

Description

Evaluate an array of code line by line and capture output

Usage

eval_src(srcCharVec, ...)

Arguments

srcCharVec

- code character array

...

- arguments to be passed on to other functions


Post HTML-Rendering Processing

Description

Evaluates code chunks in between ' these code chunks with evaluated output captured using capture.output function. Typically, we want to insert an external HTML file and we can use ' This function will read in the external html file and replace this ' contents in the html file.

Usage

post_html_render_proc(inhtml, outhtml = NULL)

Arguments

inhtml

- input file for be processed

outhtml

- output file name


Pre-knitting Processing

Description

Evaluates code chunks which are marked as between adjacent lines of @@s. Replace these code chunks with evaluated output captured using capture.output function.

Usage

pre_knit_proc(infile, outfile = NULL)

Arguments

infile

- input file for be processed

outfile

- output file name


First Pre-knitting Processing, then knitr::knit, then rmarkdown::render, then Post HTML-rendering Processing

Description

1) In pre-knitting processing, function takes in a Rmd file, evaluates code chunks which are marked as between adjacent lines of @@@s, and then replace these code chunks with evaluated output captured using capture.output function. 2) Function then calls knitr::knit followed by rmarkdown::render. 3) After which, in post HTML-rendering processing, function evaluates code chunks in between ' captured using capture.output function. Typically, we want to insert an external HTML file and we can use ' This function will read in the external html file and replace this ' contents in the html file.

Usage

preknit_knit_render_postrender(pRmdfile, outhtml = NULL)

Arguments

pRmdfile

- input Rmd file

outhtml

- output html file

Value

The output html file will have the codes between @@@ and/or \'%%% \' (where \' is a backtick) code chunks evaluated

Examples


oldwd <- getwd()
setwd(tempdir())

#pandoc.exe is required to run this code
samplermd <- tempfile('test', getwd(), '.Rmd')
addhtml <- 'test__test.html'

#generate the test Rmd file
writeLines(c('---',
'title: "Example Usage"',
'output: html_document',
'---',
'',
'This document is used for various similar reports.',
'',
'@@@',
"cat(paste('#Dynamic Header1', rnorm(1)))",
'@@@',
'',
'`%%% writeLines(readLines("test__test.html"))`',
'',
'@@@',
'cat(paste("##Dynamic Header2", rnorm(1)))',
'@@@',
'',
'Some content is invariant across different reports.'), samplermd)

#generate test html file
writeLines(c('<ul>',
'<li>Item 1</li>',
'<li>Item 2</li>',
'<li>Item 3</li>',
'</ul>'), addhtml)

#Pre-knit processing and post HTML render processing
preknit_knit_render_postrender(samplermd, "sample__html.html")

#output 'sample__html.html' is in tempdir()

setwd(oldwd)



Eval a line of code and capture output

Description

Run a line of code and capture output into a character string

Usage

run_code(oneline, envir)

Arguments

oneline

- code line

envir

- environment to evaluate the code in

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.