<htmllang="en"><head><metacharset="UTF-8"/><metaname="viewport"content="width=device-width, initial-scale=1.0"/><title>7. Example · Literate.jl</title><linkhref="https://cdnjs.cloudflare.com/ajax/libs/normalize/4.2.0/normalize.min.css"rel="stylesheet"type="text/css"/><linkhref="https://fonts.googleapis.com/css?family=Lato|Roboto+Mono"rel="stylesheet"type="text/css"/><linkhref="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css"rel="stylesheet"type="text/css"/><linkhref="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"rel="stylesheet"type="text/css"/><script>documenterBaseURL=".."</script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.min.js"data-main="../assets/documenter.js"></script><scriptsrc="../siteinfo.js"></script><scriptsrc="../../versions.js"></script><linkhref="../assets/documenter.css"rel="stylesheet"type="text/css"/></head><body><navclass="toc"><h1>Literate.jl</h1><selectid="version-selector"onChange="window.location.href=this.value"style="visibility: hidden"></select><formclass="search"id="search-form"action="../search.html"><inputid="search-query"name="q"type="text"placeholder="Search docs"/></form><ul><li><aclass="toctext"href="../index.html"><strong>1.</strong> Introduction</a></li><li><aclass="toctext"href="../fileformat.html"><strong>2.</strong> File Format</a></li><li><aclass="toctext"href="../pipeline.html"><strong>3.</strong> Processing pipeline</a></li><li><aclass="toctext"href="../outputformats.html"><strong>4.</strong> Output Formats</a></li><li><aclass="toctext"href="../customprocessing.html"><strong>5.</strong> Custom pre- and post-processing</a></li><li><aclass="toctext"href="../documenter.html"><strong>6.</strong> Interaction with Documenter.jl</a></li><liclass="current"><aclass="toctext"href="example.html"><strong>7.</strong> Example</a><ulclass="internal"></ul></li></ul></nav><articleid="docs"><header><nav><ul><li><ahref="example.html"><strong>7.</strong> Example</a></li></ul><aclass="edit-page"href="https://github.com/fredrikekre/Literate.jl/blob/master/examples/example.jl"><spanclass="fa"></span> Edit on GitHub</a></nav><hr/><divid="topbar"><span>7. Example</span><aclass="fa fa-bars"href="#"></a></div></header><h1><aclass="nav-anchor"id="**7.**-Example-1"href="#**7.**-Example-1"><strong>7.</strong> Example</a></h1><p>This is an example generated with Literate based on this source file: <ahref="https://github.com/fredrikekre/Literate.jl/blob/master/examples/example.jl"><code>example.jl</code></a>. You are seeing the html-output which Documenter have generated based on a markdown file generated with Literate. The corresponding notebook can be found here: <ahref="https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/latest/generated/example.ipynb"><code>example.ipynb</code></a>, and the plain script output can be found here: <ahref="example.jl"><code>example.jl</code></a>.</p><p>It is recommended to have the <ahref="https://github.com/fredrikekre/Literate.jl/blob/master/examples/example.jl">source file</a> available when reading this, to better understand how the syntax in the source file corresponds to the output you are seeing.</p><h3><aclass="nav-anchor"id="Basic-syntax-1"href="#Basic-syntax-1">Basic syntax</a></h3><p>The basic syntax for Literate is simple, lines starting with <code>#'</code> is interpreted as markdown, and all the other lines are interpreted as code. Here is some code:</p><div><pre><codeclass="language-julia">x = 1//3
<htmllang="en"><head><metacharset="UTF-8"/><metaname="viewport"content="width=device-width, initial-scale=1.0"/><title>7. Example · Literate.jl</title><linkhref="https://cdnjs.cloudflare.com/ajax/libs/normalize/4.2.0/normalize.min.css"rel="stylesheet"type="text/css"/><linkhref="https://fonts.googleapis.com/css?family=Lato|Roboto+Mono"rel="stylesheet"type="text/css"/><linkhref="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css"rel="stylesheet"type="text/css"/><linkhref="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"rel="stylesheet"type="text/css"/><script>documenterBaseURL=".."</script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.min.js"data-main="../assets/documenter.js"></script><scriptsrc="../siteinfo.js"></script><scriptsrc="../../versions.js"></script><linkhref="../assets/documenter.css"rel="stylesheet"type="text/css"/></head><body><navclass="toc"><h1>Literate.jl</h1><selectid="version-selector"onChange="window.location.href=this.value"style="visibility: hidden"></select><formclass="search"id="search-form"action="../search.html"><inputid="search-query"name="q"type="text"placeholder="Search docs"/></form><ul><li><aclass="toctext"href="../index.html"><strong>1.</strong> Introduction</a></li><li><aclass="toctext"href="../fileformat.html"><strong>2.</strong> File Format</a></li><li><aclass="toctext"href="../pipeline.html"><strong>3.</strong> Processing pipeline</a></li><li><aclass="toctext"href="../outputformats.html"><strong>4.</strong> Output Formats</a></li><li><aclass="toctext"href="../customprocessing.html"><strong>5.</strong> Custom pre- and post-processing</a></li><li><aclass="toctext"href="../documenter.html"><strong>6.</strong> Interaction with Documenter.jl</a></li><liclass="current"><aclass="toctext"href="example.html"><strong>7.</strong> Example</a><ulclass="internal"></ul></li></ul></nav><articleid="docs"><header><nav><ul><li><ahref="example.html"><strong>7.</strong> Example</a></li></ul><aclass="edit-page"href="https://github.com/fredrikekre/Literate.jl/blob/master/examples/example.jl"><spanclass="fa"></span> Edit on GitHub</a></nav><hr/><divid="topbar"><span>7. Example</span><aclass="fa fa-bars"href="#"></a></div></header><h1><aclass="nav-anchor"id="**7.**-Example-1"href="#**7.**-Example-1"><strong>7.</strong> Example</a></h1><p>This is an example generated with Literate based on this source file: <ahref="https://github.com/fredrikekre/Literate.jl/blob/master/examples/example.jl"><code>example.jl</code></a>. You are seeing the html-output which Documenter have generated based on a markdown file generated with Literate. The corresponding notebook can be found here: <ahref="https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/latest/generated/example.ipynb"><code>example.ipynb</code></a>, and the plain script output can be found here: <ahref="example.jl"><code>example.jl</code></a>.</p><p>It is recommended to have the <ahref="https://github.com/fredrikekre/Literate.jl/blob/master/examples/example.jl">source file</a> available when reading this, to better understand how the syntax in the source file corresponds to the output you are seeing.</p><h3><aclass="nav-anchor"id="Basic-syntax-1"href="#Basic-syntax-1">Basic syntax</a></h3><p>The basic syntax for Literate is simple, lines starting with <code>#'</code> is interpreted as markdown, and all the other lines are interpreted as code. Here is some code:</p><div><pre><codeclass="language-julia">x = 1//3
y = 2//5</code></pre><pre><codeclass="language-none">2//5</code></pre></div><p>In markdown sections we can use markdown syntax. For example, we can write <em>text in italic font</em>, <strong>text in bold font</strong> and use <ahref="https://www.youtube.com/watch?v=dQw4w9WgXcQ">links</a>.</p><p>It is possible to filter lines by starting it with <code>#md</code>, <code>#nb</code> or <code>#jl</code> for markdown, notebook and script output only, respectively. This line is filtered out for notebook and script output.</p><p>The source file is parsed in chunks of markdown and code. Starting a line with <code>#-</code> manually inserts a chunk break. For example, if we want to display the output of the following operations we may insert <code>#-</code> in between. These two code blocks will now end up in different <code>@example</code>-blocks in the markdown output, and two different notebook cells in the notebook output.</p><div><pre><codeclass="language-julia">x + y</code></pre><pre><codeclass="language-none">11//15</code></pre></div><div><pre><codeclass="language-julia">x * y</code></pre><pre><codeclass="language-none">2//15</code></pre></div><h3><aclass="nav-anchor"id="Custom-processing-1"href="#Custom-processing-1">Custom processing</a></h3><p>It is possible to give Literate custom pre- and post-processing functions. For example, here we insert two placeholders, which we will replace with something else at time of generation. We have here replaced our placeholders with <code>z</code> and <code>1.0 + 2.0im</code>:</p><div><pre><codeclass="language-julia">z = 1.0 + 2.0im</code></pre><pre><codeclass="language-none">1.0 + 2.0im</code></pre></div><h3><aclass="nav-anchor"id="documenter-interaction-1"href="#documenter-interaction-1">Documenter.jl interaction</a></h3><p>In the source file it is possible to use Documenter.jl style references, such as <code>@ref</code> and <code>@id</code>. These will be filtered out in the notebook output. For example, <ahref="example.html#documenter-interaction-1">here is a link</a>, but it is only visible as a link if you are reading the markdown output. We can also use equations:</p><div>\[\int f(x) dx\]</div><p>using Documenters math syntax. This is automatically changed to <code>\begin{equation} ... \end{equation}</code> in the notebook output to display correctly in the notebook too.</p><p><em>This page was generated using <ahref="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p><footer><hr/><aclass="previous"href="../documenter.html"><spanclass="direction">Previous</span><spanclass="title"><strong>6.</strong> Interaction with Documenter.jl</span></a></footer></article></body></html>
y = 2//5</code></pre><pre><codeclass="language-none">2//5</code></pre></div><p>In markdown sections we can use markdown syntax. For example, we can write <em>text in italic font</em>, <strong>text in bold font</strong> and use <ahref="https://www.youtube.com/watch?v=dQw4w9WgXcQ">links</a>.</p><p>It is possible to filter lines by starting it with <code>#md</code>, <code>#nb</code> or <code>#jl</code> for markdown, notebook and script output only, respectively. This line is filtered out for notebook and script output.</p><p>The source file is parsed in chunks of markdown and code. Starting a line with <code>#-</code> manually inserts a chunk break. For example, if we want to display the output of the following operations we may insert <code>#-</code> in between. These two code blocks will now end up in different <code>@example</code>-blocks in the markdown output, and two different notebook cells in the notebook output.</p><div><pre><codeclass="language-julia">x + y</code></pre><pre><codeclass="language-none">11//15</code></pre></div><div><pre><codeclass="language-julia">x * y</code></pre><pre><codeclass="language-none">2//15</code></pre></div><h3><aclass="nav-anchor"id="Output-Capturing-1"href="#Output-Capturing-1">Output Capturing</a></h3><p>Code chunks are by default placed in Documenter <code>@example</code> blocks in the generated markdown. This means that the output will be captured in a block when Documenter is building the docs. In notebooks the output is captured in output cells, if the <code>execute</code> keyword argument is set to true. Output to <code>stdout</code>/<code>stderr</code> is also captured.</p><div><pre><codeclass="language-julia">function foo()
println("This string is printed to stdout.")
return [1, 2, 3, 4]
end
foo()</code></pre><pre><codeclass="language-none">This string is printed to stdout.
4-element Array{Int64,1}:
1
2
3
4</code></pre></div><h3><aclass="nav-anchor"id="Custom-processing-1"href="#Custom-processing-1">Custom processing</a></h3><p>It is possible to give Literate custom pre- and post-processing functions. For example, here we insert two placeholders, which we will replace with something else at time of generation. We have here replaced our placeholders with <code>z</code> and <code>1.0 + 2.0im</code>:</p><div><pre><codeclass="language-julia">z = 1.0 + 2.0im</code></pre><pre><codeclass="language-none">1.0 + 2.0im</code></pre></div><h3><aclass="nav-anchor"id="documenter-interaction-1"href="#documenter-interaction-1">Documenter.jl interaction</a></h3><p>In the source file it is possible to use Documenter.jl style references, such as <code>@ref</code> and <code>@id</code>. These will be filtered out in the notebook output. For example, <ahref="example.html#documenter-interaction-1">here is a link</a>, but it is only visible as a link if you are reading the markdown output. We can also use equations:</p><div>\[\int_\Omega \nabla v \cdot \nabla u\ \mathrm{d}\Omega = \int_\Omega v f\ \mathrm{d}\Omega\]</div><p>using Documenters math syntax. Documenters syntax is automatically changed to <code>\begin{equation} ... \end{equation}</code> in the notebook output to display correctly.</p><p><em>This page was generated using <ahref="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p><footer><hr/><aclass="previous"href="../documenter.html"><spanclass="direction">Previous</span><spanclass="title"><strong>6.</strong> Interaction with Documenter.jl</span></a></footer></article></body></html>
@ -27,7 +27,7 @@ When adding `x` and `y` together we obtain a new rational number:
```@example name
```@example name
z = x + y
z = x + y
```</code></pre><p>We note that lines starting with <code>#'</code> is printed as regular markdown, and the code lines have been wrapped in <code>@example</code> blocks.</p><p>Some of the output rendering can be controlled with keyword arguments to <ahref="outputformats.html#Literate.markdown"><code>Literate.markdown</code></a>:</p><sectionclass="docstring"><divclass="docstring-header"><aclass="docstring-binding"id="Literate.markdown"href="#Literate.markdown"><code>Literate.markdown</code></a> — <spanclass="docstring-category">Function</span>.</div><div><pre><codeclass="language-none">Literate.markdown(inputfile, outputdir; kwargs...)</code></pre><p>Generate a markdown file from <code>inputfile</code> and write the result to the directory<code>outputdir</code>.</p><p>Keyword arguments:</p><ul><li><p><code>name</code>: name of the output file, excluding <code>.md</code>. <code>name</code> is also used to name all the <code>@example</code> blocks, and to replace <code>@__NAME__</code>. Defaults to the filename of <code>inputfile</code>.</p></li><li><p><code>preprocess</code>, <code>postprocess</code>: custom pre- and post-processing functions, see the <ahref="customprocessing.html#Custom-pre-and-post-processing-1">Custom pre- and post-processing</a> section of the manual. Defaults to <code>identity</code>.</p></li><li><p><code>documenter</code>: boolean that tells if the output is intended to use with Documenter.jl. Defaults to <code>true</code>. See the the manual section on <ahref="documenter.html#Interaction-with-Documenter-1">Interaction with Documenter</a>.</p></li><li><p><code>codefence</code>: A <code>Pair</code> of opening and closing code fence. Defaults to</p><pre><codeclass="language-none">"```@example $(name)" =>"```"</code></pre><p>if <code>documenter = true</code> and</p><pre><codeclass="language-none">"```julia" =>"```"</code></pre><p>if <code>documenter = false</code>.</p></li></ul></div><aclass="source-link"target="_blank"href="https://github.com/fredrikekre/Literate.jl/blob/7cea759377db9f2a59ace4809202c3625b1ca874/src/Literate.jl#L266-L291">source</a></section><h2><aclass="nav-anchor"id="Notebook-Output-1"href="#Notebook-Output-1"><strong>4.2.</strong> Notebook Output</a></h2><p>The (default) notebook output of the source snippet above is as follows</p><pre><codeclass="language-none"> │ # Rational numbers
```</code></pre><p>We note that lines starting with <code>#'</code> is printed as regular markdown, and the code lines have been wrapped in <code>@example</code> blocks.</p><p>Some of the output rendering can be controlled with keyword arguments to <ahref="outputformats.html#Literate.markdown"><code>Literate.markdown</code></a>:</p><sectionclass="docstring"><divclass="docstring-header"><aclass="docstring-binding"id="Literate.markdown"href="#Literate.markdown"><code>Literate.markdown</code></a> — <spanclass="docstring-category">Function</span>.</div><div><pre><codeclass="language-none">Literate.markdown(inputfile, outputdir; kwargs...)</code></pre><p>Generate a markdown file from <code>inputfile</code> and write the result to the directory<code>outputdir</code>.</p><p>Keyword arguments:</p><ul><li><p><code>name</code>: name of the output file, excluding <code>.md</code>. <code>name</code> is also used to name all the <code>@example</code> blocks, and to replace <code>@__NAME__</code>. Defaults to the filename of <code>inputfile</code>.</p></li><li><p><code>preprocess</code>, <code>postprocess</code>: custom pre- and post-processing functions, see the <ahref="customprocessing.html#Custom-pre-and-post-processing-1">Custom pre- and post-processing</a> section of the manual. Defaults to <code>identity</code>.</p></li><li><p><code>documenter</code>: boolean that tells if the output is intended to use with Documenter.jl. Defaults to <code>true</code>. See the the manual section on <ahref="documenter.html#Interaction-with-Documenter-1">Interaction with Documenter</a>.</p></li><li><p><code>codefence</code>: A <code>Pair</code> of opening and closing code fence. Defaults to</p><pre><codeclass="language-none">"```@example $(name)" =>"```"</code></pre><p>if <code>documenter = true</code> and</p><pre><codeclass="language-none">"```julia" =>"```"</code></pre><p>if <code>documenter = false</code>.</p></li></ul></div><aclass="source-link"target="_blank"href="https://github.com/fredrikekre/Literate.jl/blob/0d424b6081ef2599ccb1659b947efc76e19a01ab/src/Literate.jl#L269-L294">source</a></section><h2><aclass="nav-anchor"id="Notebook-Output-1"href="#Notebook-Output-1"><strong>4.2.</strong> Notebook Output</a></h2><p>The (default) notebook output of the source snippet above is as follows</p><pre><codeclass="language-none"> │ # Rational numbers
│
│
│ In julia rational numbers can be constructed with the `//` operator.
│ In julia rational numbers can be constructed with the `//` operator.
│ Lets define two rational numbers, `x` and `y`:
│ Lets define two rational numbers, `x` and `y`:
@ -41,8 +41,8 @@ Out[2]: │ 2//5
│ When adding `x` and `y` together we obtain a new rational number:
│ When adding `x` and `y` together we obtain a new rational number:
In[3]: │ z = x + y
In[3]: │ z = x + y
Out[3]: │ 11/15</code></pre><p>We note that lines starting with <code>#'</code> is put in markdown cells, and the code lines have been put in code cells. By default the notebook is also executed and output cells populated. The current working directory is set to the specified output directory the notebook is executed. Some of the output rendering can be controlled with keyword arguments to <ahref="outputformats.html#Literate.notebook"><code>Literate.notebook</code></a>:</p><sectionclass="docstring"><divclass="docstring-header"><aclass="docstring-binding"id="Literate.notebook"href="#Literate.notebook"><code>Literate.notebook</code></a> — <spanclass="docstring-category">Function</span>.</div><div><pre><codeclass="language-none">Literate.notebook(inputfile, outputdir; kwargs...)</code></pre><p>Generate a notebook from <code>inputfile</code> and write the result to <code>outputdir</code>.</p><p>Keyword arguments:</p><ul><li><p><code>name</code>: name of the output file, excluding <code>.ipynb</code>. <code>name</code> is also used to replace <code>@__NAME__</code>. Defaults to the filename of <code>inputfile</code>.</p></li><li><p><code>preprocess</code>, <code>postprocess</code>: custom pre- and post-processing functions, see the <ahref="customprocessing.html#Custom-pre-and-post-processing-1">Custom pre- and post-processing</a> section of the manual. Defaults to <code>identity</code>.</p></li><li><p><code>execute</code>: a boolean deciding if the generated notebook should also be executed or not. Defaults to <code>true</code>. The current working directory is set to <code>outputdir</code> when executing the notebook.</p></li><li><p><code>documenter</code>: boolean that says if the source contains Documenter.jl specific things to filter out during notebook generation. Defaults to <code>true</code>. See the the manual section on <ahref="documenter.html#Interaction-with-Documenter-1">Interaction with Documenter</a>.</p></li></ul></div><aclass="source-link"target="_blank"href="https://github.com/fredrikekre/Literate.jl/blob/7cea759377db9f2a59ace4809202c3625b1ca874/src/Literate.jl#L362-L379">source</a></section><h2><aclass="nav-anchor"id="Script-Output-1"href="#Script-Output-1"><strong>4.3.</strong> Script Output</a></h2><p>The (default) script output of the source snippet above is as follows</p><pre><codeclass="language-julia">x = 1//3
Out[3]: │ 11/15</code></pre><p>We note that lines starting with <code>#'</code> is put in markdown cells, and the code lines have been put in code cells. By default the notebook is also executed and output cells populated. The current working directory is set to the specified output directory the notebook is executed. Some of the output rendering can be controlled with keyword arguments to <ahref="outputformats.html#Literate.notebook"><code>Literate.notebook</code></a>:</p><sectionclass="docstring"><divclass="docstring-header"><aclass="docstring-binding"id="Literate.notebook"href="#Literate.notebook"><code>Literate.notebook</code></a> — <spanclass="docstring-category">Function</span>.</div><div><pre><codeclass="language-none">Literate.notebook(inputfile, outputdir; kwargs...)</code></pre><p>Generate a notebook from <code>inputfile</code> and write the result to <code>outputdir</code>.</p><p>Keyword arguments:</p><ul><li><p><code>name</code>: name of the output file, excluding <code>.ipynb</code>. <code>name</code> is also used to replace <code>@__NAME__</code>. Defaults to the filename of <code>inputfile</code>.</p></li><li><p><code>preprocess</code>, <code>postprocess</code>: custom pre- and post-processing functions, see the <ahref="customprocessing.html#Custom-pre-and-post-processing-1">Custom pre- and post-processing</a> section of the manual. Defaults to <code>identity</code>.</p></li><li><p><code>execute</code>: a boolean deciding if the generated notebook should also be executed or not. Defaults to <code>true</code>. The current working directory is set to <code>outputdir</code> when executing the notebook.</p></li><li><p><code>documenter</code>: boolean that says if the source contains Documenter.jl specific things to filter out during notebook generation. Defaults to <code>true</code>. See the the manual section on <ahref="documenter.html#Interaction-with-Documenter-1">Interaction with Documenter</a>.</p></li></ul></div><aclass="source-link"target="_blank"href="https://github.com/fredrikekre/Literate.jl/blob/0d424b6081ef2599ccb1659b947efc76e19a01ab/src/Literate.jl#L365-L382">source</a></section><h2><aclass="nav-anchor"id="Script-Output-1"href="#Script-Output-1"><strong>4.3.</strong> Script Output</a></h2><p>The (default) script output of the source snippet above is as follows</p><pre><codeclass="language-julia">x = 1//3
y = 2//5
y = 2//5
z = x + y</code></pre><p>We note that lines starting with <code>#'</code> are removed and only the code lines have been kept. Some of the output rendering can be controlled with keyword arguments to <ahref="outputformats.html#Literate.script"><code>Literate.script</code></a>:</p><sectionclass="docstring"><divclass="docstring-header"><aclass="docstring-binding"id="Literate.script"href="#Literate.script"><code>Literate.script</code></a> — <spanclass="docstring-category">Function</span>.</div><div><pre><codeclass="language-none">Literate.script(inputfile, outputdir; kwargs...)</code></pre><p>Generate a plain script file from <code>inputfile</code> and write the result to <code>outputdir</code>.</p><p>Keyword arguments:</p><ul><li><p><code>name</code>: name of the output file, excluding <code>.jl</code>. <code>name</code> is also used to replace <code>@__NAME__</code>. Defaults to the filename of <code>inputfile</code>.</p></li><li><p><code>preprocess</code>, <code>postprocess</code>: custom pre- and post-processing functions, see the <ahref="customprocessing.html#Custom-pre-and-post-processing-1">Custom pre- and post-processing</a> section of the manual. Defaults to <code>identity</code>.</p></li><li><p><code>documenter</code>: boolean that says if the source contains Documenter.jl specific things to filter out during script generation. Defaults to <code>true</code>. See the the manual section on <ahref="documenter.html#Interaction-with-Documenter-1">Interaction with Documenter</a>.</p></li><li><p><code>keep_comments</code>: boolean that, if set to <code>true</code>, keeps markdown lines (<code>#'</code>) as comments in the output script. Defaults to <code>false</code>.</p></li></ul></div><aclass="source-link"target="_blank"href="https://github.com/fredrikekre/Literate.jl/blob/7cea759377db9f2a59ace4809202c3625b1ca874/src/Literate.jl#L202-L218">source</a></section><footer><hr/><aclass="previous"href="pipeline.html"><spanclass="direction">Previous</span><spanclass="title"><strong>3.</strong> Processing pipeline</span></a><aclass="next"href="customprocessing.html"><spanclass="direction">Next</span><spanclass="title"><strong>5.</strong> Custom pre- and post-processing</span></a></footer></article></body></html>
z = x + y</code></pre><p>We note that lines starting with <code>#'</code> are removed and only the code lines have been kept. Some of the output rendering can be controlled with keyword arguments to <ahref="outputformats.html#Literate.script"><code>Literate.script</code></a>:</p><sectionclass="docstring"><divclass="docstring-header"><aclass="docstring-binding"id="Literate.script"href="#Literate.script"><code>Literate.script</code></a> — <spanclass="docstring-category">Function</span>.</div><div><pre><codeclass="language-none">Literate.script(inputfile, outputdir; kwargs...)</code></pre><p>Generate a plain script file from <code>inputfile</code> and write the result to <code>outputdir</code>.</p><p>Keyword arguments:</p><ul><li><p><code>name</code>: name of the output file, excluding <code>.jl</code>. <code>name</code> is also used to replace <code>@__NAME__</code>. Defaults to the filename of <code>inputfile</code>.</p></li><li><p><code>preprocess</code>, <code>postprocess</code>: custom pre- and post-processing functions, see the <ahref="customprocessing.html#Custom-pre-and-post-processing-1">Custom pre- and post-processing</a> section of the manual. Defaults to <code>identity</code>.</p></li><li><p><code>documenter</code>: boolean that says if the source contains Documenter.jl specific things to filter out during script generation. Defaults to <code>true</code>. See the the manual section on <ahref="documenter.html#Interaction-with-Documenter-1">Interaction with Documenter</a>.</p></li><li><p><code>keep_comments</code>: boolean that, if set to <code>true</code>, keeps markdown lines (<code>#'</code>) as comments in the output script. Defaults to <code>false</code>.</p></li></ul></div><aclass="source-link"target="_blank"href="https://github.com/fredrikekre/Literate.jl/blob/0d424b6081ef2599ccb1659b947efc76e19a01ab/src/Literate.jl#L205-L221">source</a></section><footer><hr/><aclass="previous"href="pipeline.html"><spanclass="direction">Previous</span><spanclass="title"><strong>3.</strong> Processing pipeline</span></a><aclass="next"href="customprocessing.html"><spanclass="direction">Next</span><spanclass="title"><strong>5.</strong> Custom pre- and post-processing</span></a></footer></article></body></html>
@ -280,6 +280,14 @@ var documenterSearchIndex = {"docs": [
"text":"The basic syntax for Literate is simple, lines starting with #\' is interpreted as markdown, and all the other lines are interpreted as code. Here is some code:x = 1//3\ny = 2//5In markdown sections we can use markdown syntax. For example, we can write text in italic font, text in bold font and use links.It is possible to filter lines by starting it with #md, #nb or #jl for markdown, notebook and script output only, respectively. This line is filtered out for notebook and script output.The source file is parsed in chunks of markdown and code. Starting a line with #- manually inserts a chunk break. For example, if we want to display the output of the following operations we may insert #- in between. These two code blocks will now end up in different @example-blocks in the markdown output, and two different notebook cells in the notebook output.x + yx * y"
"text":"The basic syntax for Literate is simple, lines starting with #\' is interpreted as markdown, and all the other lines are interpreted as code. Here is some code:x = 1//3\ny = 2//5In markdown sections we can use markdown syntax. For example, we can write text in italic font, text in bold font and use links.It is possible to filter lines by starting it with #md, #nb or #jl for markdown, notebook and script output only, respectively. This line is filtered out for notebook and script output.The source file is parsed in chunks of markdown and code. Starting a line with #- manually inserts a chunk break. For example, if we want to display the output of the following operations we may insert #- in between. These two code blocks will now end up in different @example-blocks in the markdown output, and two different notebook cells in the notebook output.x + yx * y"
"text":"Code chunks are by default placed in Documenter @example blocks in the generated markdown. This means that the output will be captured in a block when Documenter is building the docs. In notebooks the output is captured in output cells, if the execute keyword argument is set to true. Output to stdout/stderr is also captured.function foo()\n println(\"This string is printed to stdout.\")\n return [1, 2, 3, 4]\nend\n\nfoo()"
@ -293,7 +301,7 @@ var documenterSearchIndex = {"docs": [
"page":"7. Example",
"page":"7. Example",
"title":"Documenter.jl interaction",
"title":"Documenter.jl interaction",
"category":"section",
"category":"section",
"text":"In the source file it is possible to use Documenter.jl style references, such as @ref and @id. These will be filtered out in the notebook output. For example, here is a link, but it is only visible as a link if you are reading the markdown output. We can also use equations:int f(x) dxusing Documenters math syntax. This is automatically changed to \\begin{equation} ... \\end{equation} in the notebook output to display correctly in the notebook too.This page was generated using Literate.jl."
"text":"In the source file it is possible to use Documenter.jl style references, such as @ref and @id. These will be filtered out in the notebook output. For example, here is a link, but it is only visible as a link if you are reading the markdown output. We can also use equations:int_Omega nabla v cdot nabla u mathrmdOmega = int_Omega v f mathrmdOmegausing Documenters math syntax. Documenters syntax is automatically changed to \\begin{equation} ... \\end{equation} in the notebook output to display correctly.This page was generated using Literate.jl."