specify default output format (HMTL) for notebooks

pull/296/head
Shuhei Kadowaki 2020-03-27 20:34:06 +09:00
parent b6b4082977
commit a759dc10bd
2 changed files with 26 additions and 17 deletions

View File

@ -31,18 +31,23 @@ tangle
## Supported output formats
Weave sets the output format based on the file extension, but you can also set
it using `doctype` option. The rules for detecting the format are:
Weave automatically detects the output format based on the file extension.
The auto output format detection is handled by `detect_doctype(path::AbstractString)`:
```julia
ext == ".jl" && return "md2html"
contains(ext, ".md") && return "md2html"
contains(ext, ".rst") && return "rst"
contains(ext, ".tex") && return "texminted"
contains(ext, ".txt") && return "asciidoc"
return "pandoc"
function detect_doctype(path::AbstractString)
_, ext = lowercase.(splitext(path))
match(r"^\.(jl|.?md|ipynb)", ext) !== nothing && return "md2html"
ext == ".rst" && return "rst"
ext == ".tex" && return "texminted"
ext == ".txt" && return "asciidoc"
return "pandoc"
end
```
You can also manually specify it using the `doctype` keyword option.
You can get a list of supported output formats:
```@docs

View File

@ -131,16 +131,20 @@ function Base.run(
return doc
end
"""Detect the output format based on file extension"""
function detect_doctype(source::AbstractString)
ext = lowercase(splitext(source)[2])
ext == ".jl" && return "md2html"
occursin("md", ext) && return "md2html"
occursin("rst", ext) && return "rst"
occursin("tex", ext) && return "texminted"
occursin("txt", ext) && return "asciidoc"
"""
detect_doctype(path::AbstractString)
return "pandoc"
Detect the output format based on file extension.
"""
function detect_doctype(path::AbstractString)
_, ext = lowercase.(splitext(path))
match(r"^\.(jl|.?md|ipynb)", ext) !== nothing && return "md2html"
ext == ".rst" && return "rst"
ext == ".tex" && return "texminted"
ext == ".txt" && return "asciidoc"
return "pandoc"
end