# In julia rational numbers can be constructed with the `//` operator.
# Lets define two rational numbers, `x` and `y`:
## Define variable x and y
x = 1//3
y = 2//5
@ -14,4 +15,4 @@ z = x + y</code></pre><p>In the lines starting with <code>#</code> we can use re
@@ -14,4 +15,4 @@ z = x + y</code></pre><p>In the lines starting with <code>#</code> we can use re
#md # Literate.notebook
#md # Literate.markdown
#md # ```</code></pre><p>The lines in the example above would be filtered out in the preprocessing step, unless we are generating a markdown file. When generating a markdown file we would simple remove the leading <code>#md</code> from the lines. Beware that the space after the tag is also removed.</p><p>The <code>#src</code> token can also be placed at the <em>end</em> of a line. This is to make it possible to have code lines exclusive to the source code, and not just comment lines. For example, if the source file is included in the test suite we might want to add a <code>@test</code> at the end without this showing up in the outputs:</p><pre><codeclass="language-julia">using Test #src
@test result == expected_result #src</code></pre><h2><aclass="nav-anchor"id="Default-Replacements-1"href="#Default-Replacements-1"><strong>2.3.</strong> Default Replacements</a></h2><p>The following convenience "macros" are always expanded:</p><ul><li><p><code>@__NAME__</code></p><p>expands to the <code>name</code> keyword argument to <ahref="../outputformats/#Literate.markdown"><code>Literate.markdown</code></a>, <ahref="../outputformats/#Literate.notebook"><code>Literate.notebook</code></a> and <ahref="../outputformats/#Literate.script"><code>Literate.script</code></a> (defaults to the filename of the input file).</p></li><li><p><code>@__REPO__ROOT_URL__</code></p><p>expands to <code>https://github.com/$(ENV["TRAVIS_REPO_SLUG"])/blob/master/</code> and is a convenient way to use when you want to link to files outside the doc-build directory. For example <code>@__REPO__ROOT_URL__src/Literate.jl</code> would link to the source of the Literate module.</p></li><li><p><code>@__NBVIEWER_ROOT_URL__</code></p><p>expands to <code>https://nbviewer.jupyter.org/github/$(ENV["TRAVIS_REPO_SLUG"])/blob/gh-pages/$(folder)/</code> where <code>folder</code> is the folder that <code>Documenter.deploydocs</code> deploys too. This can be used if you want a link that opens the generated notebook in <ahref="http://nbviewer.jupyter.org/">http://nbviewer.jupyter.org/</a>.</p></li><li><p><code>@__BINDER_ROOT_URL__</code></p><p>expands to <code>https://mybinder.org/v2/gh/$(ENV["TRAVIS_REPO_SLUG"])/$(branch)?filepath=$(folder)/</code> where <code>branch</code>/<code>folder</code> is the branch and folder where <code>Documenter.deploydocs</code> deploys too. This can be used if you want a link that opens the generated notebook in <ahref="https://mybinder.org/">https://mybinder.org/</a>. To add a binder-badge in e.g. the HTML output you can use:</p><pre><codeclass="language-none">[](@__BINDER_ROOT_URL__path/to/notebook.inpynb)</code></pre></li></ul><footer><hr/><aclass="previous"href="../"><spanclass="direction">Previous</span><spanclass="title"><strong>1.</strong> Introduction</span></a><aclass="next"href="../pipeline/"><spanclass="direction">Next</span><spanclass="title"><strong>3.</strong> Processing pipeline</span></a></footer></article></body></html>
@test result == expected_result #src</code></pre><h2><aclass="nav-anchor"id="Default-Replacements-1"href="#Default-Replacements-1"><strong>2.3.</strong> Default Replacements</a></h2><p>The following convenience "macros" are always expanded:</p><ul><li><p><code>@__NAME__</code></p><p>expands to the <code>name</code> keyword argument to <ahref="../outputformats/#Literate.markdown"><code>Literate.markdown</code></a>, <ahref="../outputformats/#Literate.notebook"><code>Literate.notebook</code></a> and <ahref="../outputformats/#Literate.script"><code>Literate.script</code></a> (defaults to the filename of the input file).</p></li><li><p><code>@__REPO_ROOT_URL__</code></p><p>expands to <code>https://github.com/$(ENV["TRAVIS_REPO_SLUG"])/blob/master</code> and is a convenient way to use when you want to link to files outside the doc-build directory. For example <code>@__REPO_ROOT_URL__/src/Literate.jl</code> would link to the source of the Literate module.</p></li><li><p><code>@__NBVIEWER_ROOT_URL__</code></p><p>expands to <code>https://nbviewer.jupyter.org/github/$(ENV["TRAVIS_REPO_SLUG"])/blob/gh-pages/$(folder)</code> where <code>folder</code> is the folder that <code>Documenter.deploydocs</code> deploys too. This can be used if you want a link that opens the generated notebook in <ahref="http://nbviewer.jupyter.org/">http://nbviewer.jupyter.org/</a>.</p></li><li><p><code>@__BINDER_ROOT_URL__</code></p><p>expands to <code>https://mybinder.org/v2/gh/$(ENV["TRAVIS_REPO_SLUG"])/$(branch)?filepath=$(folder)</code> where <code>branch</code>/<code>folder</code> is the branch and folder where <code>Documenter.deploydocs</code> deploys too. This can be used if you want a link that opens the generated notebook in <ahref="https://mybinder.org/">https://mybinder.org/</a>. To add a binder-badge in e.g. the HTML output you can use:</p><pre><codeclass="language-none">[](@__BINDER_ROOT_URL__/path/to/notebook.inpynb)</code></pre></li></ul><divclass="admonition note"><divclass="admonition-title">Note</div><divclass="admonition-text"><p><code>@__REPO_ROOT_URL__</code> and <code>@__NBVIEWER_ROOT_URL__</code> works for documentation built with <ahref="https://github.com/JuliaDocs/DocumentationGenerator.jl">DocumentationGenerator.jl</a> but <code>@__BINDER_ROOT_URL__</code> does not, since <code>mybinder.org</code> requires the files to be located inside a git repository.</p></div></div><footer><hr/><aclass="previous"href="../"><spanclass="direction">Previous</span><spanclass="title"><strong>1.</strong> Introduction</span></a><aclass="next"href="../pipeline/"><spanclass="direction">Next</span><spanclass="title"><strong>3.</strong> Processing pipeline</span></a></footer></article></body></html>
z = x + y ┘ code</code></pre><p>In the last parsing step all empty leading and trailing lines for each chunk are removed, but empty lines <em>within the same</em> block are kept. The leading <code>#</code> tokens are also removed from the markdown chunks. Finally we would end up with the following 4 chunks:</p><p>Chunks #1:</p><pre><codeclass="language-markdown"># Rational numbers
In julia rational numbers can be constructed with the `//` operator.
Lets define two rational numbers, `x` and `y`:</code></pre><p>Chunk #2:</p><pre><codeclass="language-julia">x = 1 // 3
Lets define two rational numbers, `x` and `y`:</code></pre><p>Chunk #2:</p><pre><codeclass="language-julia"># Define variable x and y
x = 1 // 3
y = 2 // 5</code></pre><p>Chunk #3:</p><pre><codeclass="language-markdown">When adding `x` and `y` together we obtain a new rational number:</code></pre><p>Chunk #4:</p><pre><codeclass="language-julia">z = x + y</code></pre><p>It is then up to the <ahref="#Document-generation-1">Document generation</a> step to decide how these chunks should be treated.</p><h3><aclass="nav-anchor"id="Custom-control-over-chunk-splits-1"href="#Custom-control-over-chunk-splits-1">Custom control over chunk splits</a></h3><p>Sometimes it is convenient to be able to manually control how the chunks are split. For example, if you want to split a block of code into two, such that they end up in two different <code>@example</code> blocks or notebook cells. The <code>#-</code> token can be used for this purpose. All lines starting with <code>#-</code> are used as "chunk-splitters":</p><pre><codeclass="language-julia">x = 1 // 3