This can be done using the <%@include file="..."%>
RSP preprocessing construct.
From R:
> R.rsp::rfile('main.md.rsp', postprocess=FALSE)
RspFileProduct:
Pathname: C:/Users/hb/braju.com.R/R.rsp/main.md
File size: 66 bytes
Content type: application/x-markdown
Has processor: TRUE
From the command line:
Rscript -e R.rsp::rfile main.md.rsp --postprocess=FALSE
or just
rfile main.md.rsp --postprocess=FALSE
if you add system.file(package='R.rsp', 'exec')
to your PATH
.
All outputs a file main.md
:
# An Example
A list:
1. One
1. Two.
1. Three
That's it!
There's also rcat
for outputting to standard output instead of writing to file.
Clarification: The <%@include ...%>
construct is a preprocessing construct independent of the R language, i.e. there is nothing preventing this from being implemented in another language. This is in contrast to using <%=paste(readLines('child.md'), collapse='\n')%>
, which is specific to R.