2020-04-01 10:46:19 +02:00
|
|
|
# Publishing to HTML and PDF
|
2016-04-22 14:04:15 +02:00
|
|
|
|
2020-04-01 10:46:19 +02:00
|
|
|
You can also publish any supported input format to HTML and PDF documents.
|
2016-04-22 14:04:15 +02:00
|
|
|
|
2020-04-01 10:46:19 +02:00
|
|
|
!!! note
|
|
|
|
Producing PDF output requires that you have XeLaTex installed and in your path.
|
2016-04-22 14:04:15 +02:00
|
|
|
|
2020-04-01 10:46:19 +02:00
|
|
|
You can use a YAML header in the beginning of the input document delimited with `---`
|
|
|
|
to set the document title, author and date, e.g.:
|
2016-12-15 20:08:49 +01:00
|
|
|
```
|
|
|
|
---
|
|
|
|
title : Weave example
|
|
|
|
author : Matti Pastell
|
|
|
|
date: 15th December 2016
|
|
|
|
---
|
|
|
|
```
|
2016-04-22 14:04:15 +02:00
|
|
|
|
2020-04-01 10:46:19 +02:00
|
|
|
Here are sample input and outputs:
|
2020-05-18 15:59:18 +02:00
|
|
|
- input (Julia markdown format): [`FIR_design_plots.jl`](../examples/FIR_design_plots.jl) (its path is bound to `Weave.SAMPLE_JL_DOC`)
|
2020-04-01 10:46:19 +02:00
|
|
|
- HTML output: [`FIR_design_plots.html`](../examples/FIR_design_plots.html)
|
|
|
|
- PDF output: [`FIR_design_plots.pdf`](../examples/FIR_design_plots.pdf)
|
2016-04-22 14:04:15 +02:00
|
|
|
|
2020-04-01 10:46:19 +02:00
|
|
|
They are generated as follows:
|
2016-12-12 20:40:05 +01:00
|
|
|
```julia
|
2020-05-18 15:59:18 +02:00
|
|
|
weave(Weave.SAMPLE_JL_DOC)) # default to md2html output format
|
|
|
|
weave(Weave.SAMPLE_JL_DOC; doctype = "md2pdf")
|
2016-04-22 14:04:15 +02:00
|
|
|
```
|
|
|
|
|
2020-05-18 15:59:18 +02:00
|
|
|
!!! tips
|
|
|
|
`Weave.SAMPLE_JL_DOC` is the path of [FIR_design.jl](../examples/FIR_design.jl).
|
|
|
|
|
2020-04-01 10:46:19 +02:00
|
|
|
!!! note
|
|
|
|
`"md2html"` and `"md2pdf"` assume Julia markdown format as an input,
|
|
|
|
while `pandoc2pdf` and `pandoc2html` assume Noweb input format (i.e. Pandoc markdown).
|
|
|
|
|
2016-12-19 20:45:01 +01:00
|
|
|
|
|
|
|
## Templates
|
|
|
|
|
2020-04-01 10:46:19 +02:00
|
|
|
You can use a custom template with `md2html` and `md2pdf` formats with `template` keyword option,
|
|
|
|
e.g.: `weave("FIR_design_plots.jl", template = "custom.tpl"`.
|
2016-12-19 20:45:01 +01:00
|
|
|
|
2020-04-01 10:46:19 +02:00
|
|
|
As starting point, you can use the existing templates:
|
|
|
|
|
|
|
|
- HTML (`md2html`): [julia_html.tpl](https://github.com/mpastell/Weave.jl/blob/master/templates/julia_html.tpl)
|
|
|
|
- LaTex (`md2pdf`): [julia_tex.tpl](https://github.com/mpastell/Weave.jl/blob/master/templates/julia_tex.tpl)
|
2016-12-19 20:45:01 +01:00
|
|
|
|
|
|
|
Templates are rendered using [Mustache.jl](https://github.com/jverzani/Mustache.jl).
|
2019-03-04 14:42:16 +01:00
|
|
|
|
2020-04-01 10:46:19 +02:00
|
|
|
|
2019-03-04 14:42:16 +01:00
|
|
|
## Supported Markdown syntax
|
|
|
|
|
2020-04-01 10:46:19 +02:00
|
|
|
The markdown variant used by Weave is [Julia markdown](https://docs.julialang.org/en/v1/stdlib/Markdown/#).
|
|
|
|
In addition Weave supports few additional Markdown features:
|
2019-03-04 14:42:16 +01:00
|
|
|
|
2020-04-01 10:46:19 +02:00
|
|
|
### Comments
|
2019-03-04 14:42:16 +01:00
|
|
|
|
|
|
|
You can add comments using html syntax: `<!-- -->`
|
|
|
|
|
2020-04-01 10:46:19 +02:00
|
|
|
### Multiline equations
|
2019-03-04 14:42:16 +01:00
|
|
|
|
|
|
|
You can add multiline equations using:
|
|
|
|
|
|
|
|
```
|
|
|
|
$$
|
|
|
|
x^2 = x*x
|
|
|
|
$$
|
|
|
|
```
|