|
|
|
@ -3,19 +3,8 @@ |
|
|
|
When the source is parsed, and have been processed it is time to render the output. |
|
|
|
When the source is parsed, and have been processed it is time to render the output. |
|
|
|
We will consider the following source snippet: |
|
|
|
We will consider the following source snippet: |
|
|
|
|
|
|
|
|
|
|
|
```julia |
|
|
|
```@eval |
|
|
|
#' # Rational numbers |
|
|
|
Markdown.parse("```julia\n" * rstrip(read("outputformats.jl", String)) * "\n```") |
|
|
|
#' |
|
|
|
|
|
|
|
#' In julia rational numbers can be constructed with the `//` operator. |
|
|
|
|
|
|
|
#' Lets define two rational numbers, `x` and `y`: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
x = 1//3 |
|
|
|
|
|
|
|
#- |
|
|
|
|
|
|
|
y = 2//5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#' When adding `x` and `y` together we obtain a new rational number: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
z = x + y |
|
|
|
|
|
|
|
``` |
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
and see how this is rendered in each of the output formats. |
|
|
|
and see how this is rendered in each of the output formats. |
|
|
|
@ -24,29 +13,18 @@ and see how this is rendered in each of the output formats. |
|
|
|
|
|
|
|
|
|
|
|
The (default) markdown output of the source snippet above is as follows |
|
|
|
The (default) markdown output of the source snippet above is as follows |
|
|
|
|
|
|
|
|
|
|
|
````markdown |
|
|
|
```@eval |
|
|
|
# Rational numbers |
|
|
|
file = joinpath(@__DIR__, "src/generated/name.md") |
|
|
|
|
|
|
|
str = "````markdown\n" * rstrip(read(file, String)) * "\n````" |
|
|
|
In julia rational numbers can be constructed with the `//` operator. |
|
|
|
rm(file) |
|
|
|
Lets define two rational numbers, `x` and `y`: |
|
|
|
Markdown.parse(str) |
|
|
|
|
|
|
|
|
|
|
|
```@example name |
|
|
|
|
|
|
|
x = 1//3 |
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```@example name |
|
|
|
|
|
|
|
y = 2//5 |
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
When adding `x` and `y` together we obtain a new rational number: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```@example name |
|
|
|
|
|
|
|
z = x + y |
|
|
|
|
|
|
|
``` |
|
|
|
``` |
|
|
|
```` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
We note that lines starting with `#'` is printed as regular markdown, |
|
|
|
We note that lines starting with `#'` is printed as regular markdown, |
|
|
|
and the code lines have been wrapped in `@example` blocks. |
|
|
|
and the code lines have been wrapped in `@example` blocks. We also note that |
|
|
|
|
|
|
|
an `@meta` block have been added, that sets the `EditURL` variable. This is used |
|
|
|
|
|
|
|
by Documenter to redirect the "Edit on GitHub" link for the page, |
|
|
|
|
|
|
|
see [Interaction with Documenter](@ref). |
|
|
|
|
|
|
|
|
|
|
|
Some of the output rendering can be controlled with keyword arguments to |
|
|
|
Some of the output rendering can be controlled with keyword arguments to |
|
|
|
[`Literate.markdown`](@ref): |
|
|
|
[`Literate.markdown`](@ref): |
|
|
|
@ -57,25 +35,8 @@ Literate.markdown |
|
|
|
|
|
|
|
|
|
|
|
## [**4.2.** Notebook Output](@id Notebook-Output) |
|
|
|
## [**4.2.** Notebook Output](@id Notebook-Output) |
|
|
|
|
|
|
|
|
|
|
|
The (default) notebook output of the source snippet above is as follows |
|
|
|
The (default) notebook output of the source snippet can be seen here: |
|
|
|
|
|
|
|
[notebook.ipynb](generated/notebook.ipynb). |
|
|
|
``` |
|
|
|
|
|
|
|
│ # Rational numbers |
|
|
|
|
|
|
|
│ |
|
|
|
|
|
|
|
│ In julia rational numbers can be constructed with the `//` operator. |
|
|
|
|
|
|
|
│ Lets define two rational numbers, `x` and `y`: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
In[1]: │ x = 1//3 |
|
|
|
|
|
|
|
Out[1]: │ 1//3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
In[2]: │ y = 2//5 |
|
|
|
|
|
|
|
Out[2]: │ 2//5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
│ When adding `x` and `y` together we obtain a new rational number: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
In[3]: │ z = x + y |
|
|
|
|
|
|
|
Out[3]: │ 11/15 |
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
We note that lines starting with `#'` is put in markdown cells, |
|
|
|
We note that lines starting with `#'` is put in markdown cells, |
|
|
|
and the code lines have been put in code cells. By default the notebook |
|
|
|
and the code lines have been put in code cells. By default the notebook |
|
|
|
@ -93,12 +54,11 @@ Literate.notebook |
|
|
|
|
|
|
|
|
|
|
|
The (default) script output of the source snippet above is as follows |
|
|
|
The (default) script output of the source snippet above is as follows |
|
|
|
|
|
|
|
|
|
|
|
```julia |
|
|
|
```@eval |
|
|
|
x = 1//3 |
|
|
|
file = joinpath(@__DIR__, "src/generated/outputformats.jl") |
|
|
|
|
|
|
|
str = "```julia\n" * rstrip(read(file, String)) * "\n```" |
|
|
|
y = 2//5 |
|
|
|
rm(file) |
|
|
|
|
|
|
|
Markdown.parse(str) |
|
|
|
z = x + y |
|
|
|
|
|
|
|
``` |
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
We note that lines starting with `#'` are removed and only the |
|
|
|
We note that lines starting with `#'` are removed and only the |
|
|
|
|