EVOLUTION-MANAGER
Edit File: raw_output.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Mark character strings as raw output that should not be...</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for extract_raw_output {knitr}"><tr><td>extract_raw_output {knitr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Mark character strings as raw output that should not be converted</h2> <h3>Description</h3> <p>These functions provide a mechanism to protect the character output of R code chunks. The output is annotated with special markers in <code>raw_output</code>; <code>extract_raw_output()</code> will extract raw output wrapped in the markers, and replace the raw output with its MD5 digest; <code>restore_raw_output()</code> will restore the MD5 digest with the original raw output. </p> <h3>Usage</h3> <pre> extract_raw_output(text, markers = raw_markers) restore_raw_output(text, chunks, markers = raw_markers) raw_output(x, markers = raw_markers, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>text</code></td> <td> <p>For <code>extract_raw_output()</code>, the content of the input file (e.g. Markdown); for <code>restore_raw_output()</code>, the content of the output file (e.g. HTML generated by Pandoc from Markdown).</p> </td></tr> <tr valign="top"><td><code>markers</code></td> <td> <p>A length-2 character vector to be used to wrap <code>x</code>; see <code>knitr:::raw_markers</code> for the default value.</p> </td></tr> <tr valign="top"><td><code>chunks</code></td> <td> <p>A named character vector returned from <code>extract_raw_output()</code>.</p> </td></tr> <tr valign="top"><td><code>x</code></td> <td> <p>The character vector to be protected.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Arguments to be passed to <code><a href="asis_output.html">asis_output</a>()</code>.</p> </td></tr> </table> <h3>Details</h3> <p>This mechanism is designed primarily for R Markdown pre/post-processors. In an R code chunk, you generate <code>raw_output()</code> to the Markdown output. In the pre-processor, you can <code>extract_raw_output()</code> from the Markdown file, store the raw output and MD5 digests, and remove the actual raw output from Markdown so Pandoc will never see it. In the post-processor, you can read the Pandoc output (e.g., an HTML or RTF file), and restore the raw output. </p> <h3>Value</h3> <p>For <code>extract_raw_output()</code>, a list of two components: <code>value</code> (the <code>text</code> with raw output replaced by MD5 digests) and <code>chunks</code> (a named character vector, of which the names are MD5 digests and values are the raw output). For <code>restore_raw_output()</code>, the restored <code>text</code>. </p> <h3>Examples</h3> <pre> library(knitr) out = c("*hello*", raw_output("<special>content</special> *protect* me!"), "*world*") pre = extract_raw_output(out) str(pre) pre$value = gsub("[*]([^*]+)[*]", "<em>\\1</em>", pre$value) # think this as Pandoc conversion pre$value # raw output was protected from the conversion (e.g. # *protect* was not converted) restore_raw_output(pre$value, pre$chunks) </pre> <hr /><div style="text-align: center;">[Package <em>knitr</em> version 1.29 <a href="00Index.html">Index</a>]</div> </body></html>