ReporteRs (version 0.8.6)

addCodeBlock: Add code block into a document object

Description

Add a code block into a document object

Usage

addCodeBlock(doc, file, text, ...)
"addCodeBlock"(doc, file, text, par.properties = parProperties(), text.properties = textProperties(color = "#A7947D"), bookmark, ...)
"addCodeBlock"(doc, file, text, par.properties = parProperties(), text.properties = textProperties(color = "#A7947D"), ...)
"addCodeBlock"(doc, file, text, par.properties = parProperties(), text.properties = textProperties(color = "#A7947D"), append = FALSE, ...)

Arguments

doc
document object
file
script file. Not used if text is provided.
text
character vector. The text to parse. Not used if file is provided.
...
further arguments passed to other methods
par.properties
code block paragraph properties. An object of class parProperties
text.properties
code block text properties. An object of class textProperties
bookmark
Only for docx. A character value ; id of the Word bookmark to replace by the script. optional. See bookmark.
append
Only for pptx. boolean default to FALSE. If TRUE, paragraphs will be appened in the current shape instead of beeing sent into a new shape. Paragraphs can only be appended on shape containing paragraphs (i.e. you can not add paragraphs after a FlexTable).

Value

a document object

See Also

bsdoc, docx, pptx

Examples

Run this code

cb <- "ls -a\nwhich -a ls"

options( "ReporteRs-fontsize" = 11 )

# docx example ---------
doc = docx( )
doc <- addCodeBlock( doc, text = cb )
writeDoc( doc, file = "ex_codeblock.docx" )


# bsdoc example ---------
doc = bsdoc( )
doc <- addCodeBlock( doc, text = cb )
writeDoc( doc, file = "ex_codeblock/example.html" )


# pptx example ---------
doc = pptx( )
doc = addSlide( doc, slide.layout = "Title and Content" )
doc <- addCodeBlock( doc, text = cb )
writeDoc( doc, file = "ex_codeblock.pptx" )


Run the code above in your browser using DataLab