EVOLUTION-MANAGER
Edit File: highr-custom.html
<!DOCTYPE html> <html> <head> <title>Customization of the <code>highr</code> package</title> <meta charset="utf-8"> <meta name="generator" content="knitr" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/7.3/styles/github.min.css"> <style type="text/css"> /* Derived from the Docco package by Jeremy Ashkenas: https://github.com/jashkenas/docco/ */ body { font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif; height:100%; font-size: 16px; line-height: 24px; color: #30404f; margin: 0; padding: 0; } h1, h2, h3, h4, h5, h6 { color: #112233; line-height: 1em; font-weight: normal; margin: 0 0 15px 0; } p { margin: 0 0 15px 0; font-size:17px; } #footer p{ margin:0; font-size:12px; text-align: center; } a{ color:#0088cc; text-decoration:none; } a:hover,a:focus{ color:#005580; text-decoration:underline; } #container { position: relative; margin: 0; height:100%; } body > #container { height: auto; min-height: 100%; } table{ width:100%; border: 0; outline: 0; } td.docs{ width: 50%; text-align: left; vertical-align: top; padding: 10px 25px 1px 50px; } td.code{ background: #f5f5ff; padding: 10px 25px 1px 50px; overflow-x: hidden; vertical-align: top; } code{ font-size:12px; margin: 0; padding: 0; } td.docs code{ background: #f8f8ff; border: 1px solid #dedede; font-size: 80%; padding: 0 0.2em; } td.docs img{ max-width: 100%; } pre code{ padding:2px 4px; background:#f5f5ff; } td.code pre code{ line-height: 18px; } .pilwrap { position: relative; } .pilcrow { font: 12px Arial; text-decoration: none; color: rgb(69, 69, 69); position: absolute; top: 3px; left: -20px; padding: 1px 2px; opacity: 0; } td.docs:hover .pilcrow { opacity: 1; } blockquote { border-left: 4px solid #DDD; padding: 0 15px; color: #777; } div.handler{ width: 5px; padding: 0; cursor: col-resize; position: absolute; z-index: 5; } </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/7.3/highlight.min.js"></script> <script type="text/javascript"> hljs.LANGUAGES.r=function(a){var b="([a-zA-Z]|\\.[a-zA-Z.])[a-zA-Z0-9._]*";return{c:[a.HCM,{b:b,l:b,k:{keyword:"function if in break next repeat else for return switch while try tryCatch|10 stop warning require library attach detach source setMethod setGeneric setGroupGeneric setClass ...|10",literal:"NULL NA TRUE FALSE T F Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10"},r:0},{cN:"number",b:"0[xX][0-9a-fA-F]+[Li]?\\b",r:0},{cN:"number",b:"\\d+(?:[eE][+\\-]?\\d*)?L\\b",r:0},{cN:"number",b:"\\d+\\.(?!\\d)(?:i\\b)?",r:0},{cN:"number",b:"\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d*)?i?\\b",r:0},{cN:"number",b:"\\.\\d+(?:[eE][+\\-]?\\d*)?i?\\b",r:0},{b:"`",e:"`",r:0},{cN:"string",b:'"',e:'"',c:[a.BE],r:0},{cN:"string",b:"'",e:"'",c:[a.BE],r:0}]}}(hljs); </script> <script>hljs.initHighlightingOnLoad();</script> <script src="https://yihui.name/js/center-img.js"></script> </head> <body> <div id="container"> <table><!--table start--> <tr id="row1"><td class="docs"><div class="pilwrap"><a class="pilcrow" href="#row1">¶</a></div><!-- %\VignetteEngine{knitr::docco_classic} %\VignetteIndexEntry{Customization of the highr package} --> <h1>Customization of the <code>highr</code> package</h1> <p>If you are not satisfied with the default syntax highlighting commands in the <strong>highr</strong> package, you can just use your own tags/commands. In this vignette, we show a brief example.</p> </td><td class="code"></td></tr><tr id="row2"><td class="docs"><div class="pilwrap"><a class="pilcrow" href="#row2">¶</a></div><p>The default highlighting commands are stored in two internal data frames <code>cmd_latex</code> and <code>cmd_html</code>:</p></td><td class="code"><pre><code class="r">library(highr) highr:::cmd_latex </code></pre> <pre><code>## cmd1 cmd2 ## COMMENT \\hlcom{ } ## FUNCTION \\hlkwa{ } ## IF \\hlkwa{ } ## ELSE \\hlkwa{ } ## WHILE \\hlkwa{ } ## FOR \\hlkwa{ } ## IN \\hlkwa{ } ## BREAK \\hlkwa{ } ## REPEAT \\hlkwa{ } ## NEXT \\hlkwa{ } ## NULL_CONST \\hlkwa{ } ## LEFT_ASSIGN \\hlkwb{ } ## EQ_ASSIGN \\hlkwb{ } ## RIGHT_ASSIGN \\hlkwb{ } ## SYMBOL_FORMALS \\hlkwc{ } ## SYMBOL_SUB \\hlkwc{ } ## SLOT \\hlkwc{ } ## SYMBOL_FUNCTION_CALL \\hlkwd{ } ## NUM_CONST \\hlnum{ } ## '+' \\hlopt{ } ## '-' \\hlopt{ } ## '*' \\hlopt{ } ## '/' \\hlopt{ } ## '^' \\hlopt{ } ## '$' \\hlopt{ } ## '@' \\hlopt{ } ## ':' \\hlopt{ } ## '?' \\hlopt{ } ## '~' \\hlopt{ } ## '!' \\hlopt{ } ## SPECIAL \\hlopt{ } ## GT \\hlopt{ } ## GE \\hlopt{ } ## LT \\hlopt{ } ## LE \\hlopt{ } ## EQ \\hlopt{ } ## NE \\hlopt{ } ## AND \\hlopt{ } ## AND2 \\hlopt{ } ## OR \\hlopt{ } ## OR2 \\hlopt{ } ## NS_GET \\hlopt{ } ## NS_GET_INT \\hlopt{ } ## STANDARD \\hlstd{ } ## STR_CONST \\hlstr{ } </code></pre></td></tr><tr id="row3"><td class="docs"><div class="pilwrap"><a class="pilcrow" href="#row3">¶</a></div> <p>This data frame is passed to the <code>markup</code> argument in <code>hilight()</code>, so we are free to pass a modified version there. Suppose I want to use the command <code>\my<*></code> instead of <code>\hl<*></code>:</p></td><td class="code"><pre><code class="r">m = highr:::cmd_latex m[, 1] = sub("\\hl", "\\my", m[, 1], fixed = TRUE) head(m) </code></pre> <pre><code>## cmd1 cmd2 ## COMMENT \\mycom{ } ## FUNCTION \\mykwa{ } ## IF \\mykwa{ } ## ELSE \\mykwa{ } ## WHILE \\mykwa{ } ## FOR \\mykwa{ } </code></pre></td></tr><tr id="row4"><td class="docs"><div class="pilwrap"><a class="pilcrow" href="#row4">¶</a></div> <p>Then</p></td><td class="code"><pre><code class="r">hilight("x = 1+1 # a comment") # default markup </code></pre> <pre><code>## [1] "\\hlstd{x} \\hlkwb{=} \\hlnum{1}\\hlopt{+}\\hlnum{1} \\hlcom{# a comment}" </code></pre> <pre><code class="r">hilight("x = 1+1 # a comment", markup = m) # custom markup </code></pre> <pre><code>## [1] "\\mystd{x} \\mykwb{=} \\mynum{1}\\myopt{+}\\mynum{1} \\mycom{# a comment}" </code></pre></td></tr><tr id="row5"><td class="docs"><div class="pilwrap"><a class="pilcrow" href="#row5">¶</a></div> <p>This allows one to use arbitrary commands around the text symbols in the R code. See <a href="https://github.com/yihui/highr/blob/master/R/highlight.R">https://github.com/yihui/highr/blob/master/R/highlight.R</a> for how <code>cmd_latex</code> and <code>cmd_html</code> were generated in <strong>highr</strong>.</p> </td><td class="code"></td></tr> </table><!--table end--> </div> <script src="https://code.jquery.com/jquery-2.1.1.min.js"></script> <script src="https://yihui.name/knitr/js/docco-resize.js"></script> </body> </html>