ReporteRs (version 0.8.5)

addCodeBlock: Add code block into a document object

Description

Add a code block into a document object

Usage

addCodeBlock(doc, file, text, ...)

## S3 method for class 'docx': addCodeBlock(doc, file, text, par.properties = parProperties(), text.properties = textProperties(color = "#A7947D"), bookmark, ...)

## S3 method for class 'bsdoc': addCodeBlock(doc, file, text, par.properties = parProperties(), text.properties = textProperties(color = "#A7947D"), ...)

## S3 method for class 'pptx': 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

Value

  • a document object

See Also

bsdoc, docx, pptx

Examples

Run this code
# docx example ---------
doc.filename = "ex_codeblock.docx"

options( "ReporteRs-fontsize" = 10 )
doc <- docx( )
doc <- addCodeBlock( doc, text = "ls -a\nwhich -a ls" )

writeDoc( doc, file = doc.filename )

# bsdoc example --------
doc.filename = "ex_codeblock/example.html"

options( "ReporteRs-fontsize" = 11 )
doc = bsdoc( )
doc <- addCodeBlock( doc, text = "ls -a\nwhich -a ls" )

writeDoc( doc, file = doc.filename )

# docx example ---------
doc.filename = "ex_codeblock.pptx"

options( "ReporteRs-fontsize" = 24 )
doc = pptx( title = "title" )

# add a slide with layout "Title and Content"
doc = addSlide( doc, slide.layout = "Title and Content" )

doc = addTitle( doc, "Title example 1" )
doc <- addCodeBlock( doc, text = "ls -a\nwhich -a ls" )

writeDoc( doc, file = doc.filename )

Run the code above in your browser using DataLab