Add docs for inline output, make figure output inline

pull/202/head
Matti Pastell 2019-03-10 19:23:18 +02:00
parent 4ab1c09b8c
commit 3488af5534
3 changed files with 36 additions and 23 deletions

View File

@ -8,9 +8,9 @@ and Sweave.
**Current features**
* Markdown, script of Noweb syntax for input documents.
* Publish markdown directly to html and pdf using Julia or Pandoc markdown.
* Execute code as terminal or "script" chunks.
* Markdown, script of Noweb syntax for input documents
* Publish markdown directly to html and pdf using Julia or Pandoc markdown
* Execute code as terminal or "script" chunks
* Capture Plots.jl or Gadfly.jl figures
* Supports LaTex, Pandoc, Github markdown, MultiMarkdown, Asciidoc and reStructuredText output
* Simple caching of results

View File

@ -80,6 +80,37 @@ Markdown code chunks are defined using fenced code blocks with options following
[Sample document]( https://github.com/mpastell/Weave.jl/blob/master/examples/FIR_design.jmd)
## Inline code
You can also add inline code to your documents using
```
`j juliacode`
```
or
```
! juliacode
```
syntax. Using the `j code` syntax you can insert code anywhere in a line and with
the `! syntax` the whole line after `!` will be executed. The code will be replaced
with the output of running the code.
If the code produces figures the filename or base64 encoded string will be
added to output e.g. to include a Plots figure in markdown you can use:
```
![A plot](`j plot(1:10)`)
```
or to produce html output:
```
! display("text/html", "Header from julia");
```
### Noweb format
@ -105,22 +136,6 @@ Weave will remove the first empty space from each line of documentation.
[See sample document:](https://github.com/mpastell/Weave.jl/blob/master/examples/FIR_design.jl)
## Inline code
You can also add inline code to your documents using
```
`j juliacode`
```
syntax. The code will be replaced with the output of running the code.
If the code produces figures the filename or base64 encoded string will be
added to output e.g. to include a Plots figure in markdown you can use:
```
![A plot](`j plot(1:10)`)
```
## Setting document options in header
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. and default document options. Each of Weave command line arguments and chunk options can be set in header using `options` field. Below is an example that sets document `out_path` and `doctype` using the header.

View File

@ -151,8 +151,7 @@ function format_chunk(chunk::DocChunk, formatdict, docformat::JMarkdown2tex)
ioformat!(io, out)
write(out, addspace(inline.rich_output, inline))
elseif !isempty(inline.figures)
ioformat!(io, out)
write(out, addspace(inline.figures[end], inline))
write(io, inline.figures[end], inline)
elseif !isempty(inline.output)
write(io, addspace(inline.output, inline))
end
@ -172,8 +171,7 @@ function format_chunk(chunk::DocChunk, formatdict, docformat::JMarkdown2HTML)
ioformat!(io, out, fun)
write(out, addspace(inline.rich_output, inline))
elseif !isempty(inline.figures)
ioformat!(io, out, fun)
write(out, addspace(inline.figures[end], inline))
write(io, inline.figures[end]))
elseif !isempty(inline.output)
write(io, addspace(inline.output, inline))
end