<html lang="en"> <head> <title>Testing text output</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link href="https://unpkg.com/@stencila/thema@2/dist/themes/latex/styles.css" rel="stylesheet"> <script src="https://unpkg.com/@stencila/thema@2/dist/themes/latex/index.js" type="text/javascript"></script> <script src="https://unpkg.com/@stencila/components@<=1/dist/stencila-components/stencila-components.esm.js" type="module"></script> <script src="https://unpkg.com/@stencila/components@<=1/dist/stencila-components/stencila-components.js" type="text/javascript" nomodule=""></script> </head> <body> <main role="main"> <article itemscope="" itemtype="http://schema.org/Article" data-itemscope="root"> <h1 itemprop="headline">Testing text output</h1> <meta itemprop="image" content="https://via.placeholder.com/1200x714/dbdbdb/4a4a4a.png?text=Testing%20text%20output"> <span itemscope="" itemtype="http://schema.org/Organization" itemprop="publisher"> <meta itemprop="name" content="Unknown"><span itemscope="" itemtype="http://schema.org/ImageObject" itemprop="logo"> <meta itemprop="url" content="https://via.placeholder.com/600x60/dbdbdb/4a4a4a.png?text=Unknown"> </span> </span> <p itemscope="" itemtype="http://schema.stenci.la/Paragraph">See if chunk options like <code itemscope="" itemtype="http://schema.stenci.la/CodeFragment">tidy</code>, <code itemscope="" itemtype="http://schema.stenci.la/CodeFragment">prompt</code> and <code itemscope="" itemtype="http://schema.stenci.la/CodeFragment">echo</code>, etc work as expected.</p> <h3 itemscope="" itemtype="http://schema.stenci.la/Heading" id="a-normal-chunk">A normal chunk</h3> <figure itemscope="" itemtype="http://schema.stenci.la/Figure" title="demo"><label data-itemprop="label">demo</label> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-programminglanguage="r"> <pre class="language-r" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code>1+1 for (i in 1:10) { # nothing before 10 if(i>=10)print(i) } # two blank lines below dnorm(0)</code></pre> </stencila-code-chunk> </figure> <h3 itemscope="" itemtype="http://schema.stenci.la/Heading" id="do-not-evaluate">Do not evaluate</h3> <figure itemscope="" itemtype="http://schema.stenci.la/Figure" title="demo"><label data-itemprop="label">demo</label> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-eval="FALSE" data-programminglanguage="r"> <pre class="language-r" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code></code></pre> <figure slot="outputs"><span itemscope="" itemtype="http://schema.stenci.la/Array">[{type:'Heading',depth:2,content:['Add prompts']},{type:'CodeBlock',text:'',programmingLanguage:'{r',meta:{'demo,':'',prompt:'TRUE'}}]</span> </figure> </stencila-code-chunk> </figure> <h3 itemscope="" itemtype="http://schema.stenci.la/Heading" id="no-evaluate-or-tidy">No evaluate or tidy</h3> <figure itemscope="" itemtype="http://schema.stenci.la/Figure" title="demo"><label data-itemprop="label">demo</label> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-eval="FALSE" data-tidy="FALSE" data-programminglanguage="r"> <pre class="language-r" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code></code></pre> <figure slot="outputs"><span itemscope="" itemtype="http://schema.stenci.la/Array">[{type:'Heading',depth:2,content:['Do not tidy']},{type:'CodeBlock',text:'',programmingLanguage:'{r',meta:{'demo,':'',tidy:'FALSE'}}]</span> </figure> </stencila-code-chunk> </figure> <h3 itemscope="" itemtype="http://schema.stenci.la/Heading" id="do-not-echo">Do not echo </h3> <figure itemscope="" itemtype="http://schema.stenci.la/Figure" title="demo"><label data-itemprop="label">demo</label> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-echo="FALSE" data-programminglanguage="r"> <pre class="language-r" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code></code></pre> <figure slot="outputs"><span itemscope="" itemtype="http://schema.stenci.la/Array">[{type:'Heading',depth:2,content:['Do not comment out results']},{type:'CodeBlock',text:'',programmingLanguage:'{r',meta:{'demo,':'',comment:'NA'}}]</span> </figure> </stencila-code-chunk> </figure> <h3 itemscope="" itemtype="http://schema.stenci.la/Heading" id="do-not-echo-the-2nd-expression">Do not echo the 2nd expression</h3> <figure itemscope="" itemtype="http://schema.stenci.la/Figure" title="demo"><label data-itemprop="label">demo</label> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-echo="-2" data-programminglanguage="r"> <pre class="language-r" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code></code></pre> <figure slot="outputs"><span itemscope="" itemtype="http://schema.stenci.la/Array">[{type:'Heading',depth:2,content:['Do not evaluate, echo the 2nd expression']},{type:'CodeBlock',text:'',programmingLanguage:'{r',meta:{'demo,':'',eval:'FALSE,',echo:'2'}}]</span> </figure> </stencila-code-chunk> </figure> <h3 itemscope="" itemtype="http://schema.stenci.la/Heading" id="only-evaluate-the-first-two-expressions">Only evaluate the first two expressions</h3> <figure itemscope="" itemtype="http://schema.stenci.la/Figure" title="demo"><label data-itemprop="label">demo</label> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-eval="1:2" data-programminglanguage="r"> <pre class="language-r" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code></code></pre> <figure slot="outputs"><span itemscope="" itemtype="http://schema.stenci.la/Array">[{type:'Heading',depth:2,content:['Add prompts but no tidy']},{type:'CodeBlock',text:'',programmingLanguage:'{r',meta:{'demo,':'',tidy:'FALSE,',prompt:'TRUE'}}]</span> </figure> </stencila-code-chunk> </figure> <h3 itemscope="" itemtype="http://schema.stenci.la/Heading" id="prompts-no-evaluate-or-tidy">Prompts, no evaluate or tidy</h3> <figure itemscope="" itemtype="http://schema.stenci.la/Figure" title="demo"><label data-itemprop="label">demo</label> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-eval="FALSE" data-tidy="FALSE" data-prompt="TRUE" data-programminglanguage="r"> <pre class="language-r" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code></code></pre> <figure slot="outputs"><span itemscope="" itemtype="http://schema.stenci.la/Array">[{type:'Heading',depth:2,content:['Change prompts']},{type:'CodeBlock',text:"options(prompt='R> ', continue='+ ')",programmingLanguage:'{r}'}]</span></figure> </stencila-code-chunk> </figure> <figure itemscope="" itemtype="http://schema.stenci.la/Figure" title="demo"><label data-itemprop="label">demo</label> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-prompt="TRUE" data-programminglanguage="r"> <pre class="language-r" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code></code></pre> <figure slot="outputs"><span itemscope="" itemtype="http://schema.stenci.la/Array">[{type:'Heading',depth:2,content:['Backslashes']},{type:'CodeBlock',text:"{\n# can you deal with \\code{foo} or \\n, \\a?\ngsub('\\\\.', '\\\\\\\\', 'a.b.c') # \\link{bar}\n}\ncat('a\\tb\\nc')",programmingLanguage:'{r}'}]</span></figure> </stencila-code-chunk> </figure> <h3 itemscope="" itemtype="http://schema.stenci.la/Heading" id="other-formatr-options">Other formatR options</h3> <p itemscope="" itemtype="http://schema.stenci.la/Paragraph">We can set <strong itemscope="" itemtype="http://schema.stenci.la/Strong">formatR</strong> options globally:</p> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-programminglanguage="r"> <pre class="language-r" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code>options(formatR.blank = FALSE)</code></pre> </stencila-code-chunk> <figure itemscope="" itemtype="http://schema.stenci.la/Figure" title="demo"><label data-itemprop="label">demo</label> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-eval="FALSE" data-programminglanguage="r"> <pre class="language-r" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code></code></pre> <figure slot="outputs"><span itemscope="" itemtype="http://schema.stenci.la/Array">[{type:'Paragraph',content:['Or locally in one chunk via ',{text:'tidy.opts',type:'CodeFragment'},'. Do not keep comments:']},{type:'CodeBlock',text:'',programmingLanguage:'{r',meta:{'demo,':'',eval:'FALSE,','tidy.opts':'list(comment'}}]</span> </figure> </stencila-code-chunk> </figure> <p itemscope="" itemtype="http://schema.stenci.la/Paragraph">Move left braces to the next line:</p> <figure itemscope="" itemtype="http://schema.stenci.la/Figure" title="demo"><label data-itemprop="label">demo</label> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-eval="2" data-echo="2" data-tidyopts="list(brace.newline" data-programminglanguage="r"> <pre class="language-r" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code></code></pre> <figure slot="outputs"><span itemscope="" itemtype="http://schema.stenci.la/Array">[{type:'Paragraph',content:['Indent by 2 spaces:']},{type:'CodeBlock',text:'',programmingLanguage:'{r',meta:{'demo,':'',eval:'FALSE,','tidy.opts':'list(indent'}}]</span> </figure> </stencila-code-chunk> </figure> <p itemscope="" itemtype="http://schema.stenci.la/Paragraph">See <a href="http://yihui.org/formatR" itemscope="" itemtype="http://schema.stenci.la/Link">http://yihui.org/formatR</a> for details.</p> <h3 itemscope="" itemtype="http://schema.stenci.la/Heading" id="empty-chunks">Empty chunks </h3> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-programminglanguage="r"> <pre class="language-r" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code></code></pre> <figure slot="outputs"><span itemscope="" itemtype="http://schema.stenci.la/Array">[{type:'Heading',depth:2,content:['Messages']},{type:'Paragraph',content:['Do not include messages:']},{type:'CodeBlock',text:"1+1\nmessage('helloooo!')",programmingLanguage:'{r',meta:{message:'FALSE'}}]</span> </figure> </stencila-code-chunk> <p itemscope="" itemtype="http://schema.stenci.la/Paragraph">No warnings:</p> <figure itemscope="" itemtype="http://schema.stenci.la/Figure" title="test-w"><label data-itemprop="label">test-w</label> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-warning="FALSE" data-programminglanguage="r"> <pre class="language-r" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code>1:2+1:3 warning('no no no')</code></pre> </stencila-code-chunk> </figure> <p itemscope="" itemtype="http://schema.stenci.la/Paragraph">Select warnings using numeric indices:</p> <figure itemscope="" itemtype="http://schema.stenci.la/Figure" title="test-w"><label data-itemprop="label">test-w</label> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-warning="-1" data-programminglanguage="r"> <pre class="language-r" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code></code></pre> <figure slot="outputs"><span itemscope="" itemtype="http://schema.stenci.la/Array">[{type:'Paragraph',content:['Invalid indices will select nothing:']},{type:'CodeBlock',text:'',programmingLanguage:'{r',meta:{'test-w,':'',warning:'3'}}]</span> </figure> </stencila-code-chunk> </figure> <h3 itemscope="" itemtype="http://schema.stenci.la/Heading" id="the-results-option">The results option</h3> <p itemscope="" itemtype="http://schema.stenci.la/Paragraph">Do not show text results:</p> <figure itemscope="" itemtype="http://schema.stenci.la/Figure" title="demo"><label data-itemprop="label">demo</label> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-results="" data-hide="" data-programminglanguage="r"> <pre class="language-r" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code></code></pre> <figure slot="outputs"><span itemscope="" itemtype="http://schema.stenci.la/Array">[{type:'Paragraph',content:['Flush all results to the end of a chunk:']},{type:'CodeBlock',text:'',programmingLanguage:'r',meta:{'demo,':'',results:'hold'}}]</span> </figure> </stencila-code-chunk> </figure> <p itemscope="" itemtype="http://schema.stenci.la/Paragraph">Output as is:</p> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-results="" data-asis="" data-programminglanguage="r"> <pre class="language-r" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code>cat('_Markdown_,', 'oh yeah, **Markdown**')</code></pre> </stencila-code-chunk> </article> </main> </body> </html>