Markdown output is generated by [`Literate.markdown`](@ref). The (default) markdown output
Markdown output is generated by [`Literate.markdown`](@ref). There exist various "flavors"
of the source snippet above is as follows:
of markdown and Literate supports some different flavors, see [Markdown flavors](@ref).
The default flavor is `Literate.DocumenterFlavor()` and, as the name suggest, it generates
markdown files meant to be used together with [Documenter.jl]
(https://juliadocs.github.io/Documenter.jl). The output of the source snippet above is as
follows:
```@eval
```@eval
import Markdown
import Markdown
@ -29,7 +33,8 @@ 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,
by Documenter to redirect the "Edit on GitHub" link for the page,
see [Interaction with Documenter](@ref).
see [Interaction with Documenter](@ref).
The `@example` blocks are wrapped in 4 consecutive backticks so as to allow for docstrings containing triple backticks, for example:
The `@example` blocks are wrapped in 4 consecutive backticks so as to allow for docstrings
containing triple backticks, for example:
````julia
````julia
"""
"""
This function perform the following calculation:
This function perform the following calculation:
@ -39,7 +44,8 @@ This function perform the following calculation:
"""
"""
f(x) = x[1] + x[2]
f(x) = x[1] + x[2]
````
````
If your Julia code itself contains 4 consecutive backticks, you can use the keyword argument `codefence` to setup 5 backticks for code blocks, see [Configuration](@ref).
If your Julia code itself contains 4 consecutive backticks, you can use the keyword
argument `codefence` to setup 5 backticks for code blocks, see [Configuration](@ref).
It possible to configure `Literate.markdown` to also evaluate code snippets, capture the
It possible to configure `Literate.markdown` to also evaluate code snippets, capture the
result and include it in the output, by passing `execute=true` as a keyword argument.
result and include it in the output, by passing `execute=true` as a keyword argument.
@ -54,17 +60,14 @@ x = 1//3
`````
`````
In this example the output is just plain text. However, if the resulting value of the code
In this example the output is just plain text. However, if the resulting value of the code
block can be displayed as an image (png or jpeg) Literate will include the image
block can be displayed as an image (image/png or image/jpeg), HTML (text/html) or markdown
representation of the output.
(text/markdown) Literate will include the richest representation of the output.
!!! note
!!! note
Since Documenter executes and captures results of `@example` block it is not necessary
Since Documenter executes and captures results of `@example` block it is not necessary
to use `execute=true` for markdown output that is meant to be used as input to
to use `execute=true` for markdown output that is meant to be used as input to
Documenter.
Documenter.
!!! compat "Literate 2.4"
Code execution of markdown output requires at least Literate version 2.4.
See the section about [Configuration](@ref) for more information about how to configure the
See the section about [Configuration](@ref) for more information about how to configure the
behavior and resulting output of [`Literate.markdown`](@ref).
behavior and resulting output of [`Literate.markdown`](@ref).
@ -74,20 +77,16 @@ Literate.markdown
### Markdown flavors
### Markdown flavors
Literate supports different "flavors" to the markdown output. To specify a flavor pass the
Literate can output markdown in different flavors. The flavor is specified using the
`flavor` keyword argument to [`Literate.markdown`](@ref). The default flavor
`flavor` keyword argument. The following flavors are currently supported:
(`Literate.DefaultFlavor`) is the Documenter compatible output used throughout most examples.
Another supported flavor is `Literate.FranklinFlavor` for output compatible with the
[Franklin.jl](https://franklinjl.org/) static site generator. Currently the only difference
is that the Franklin flavor supports `text/html` MIME output when executing the markdown