Implemented asciidoc formatter, closes #16

pull/22/head
Matti Pastell 2014-12-20 17:36:02 +02:00
parent f333b53a73
commit 6910d6e707
2 changed files with 61 additions and 1 deletions

View File

@ -0,0 +1,18 @@
<<term=true>>=
using Gadfly
x = linspace(0, 2π, 200)
plot(x=x, y = sin(x), Geom.line)
y = 20
plot(x=x, y = cos(x), Geom.line)
@
<<>>=
x = linspace(0, 200)
println(x)
@
<<fig_cap="Cosine function">>=
plot(x=x, y = cos(x), Geom.line)
@

View File

@ -195,6 +195,23 @@ const rst = Rest("reStructuredText and Sphinx",
:doctype => "rst"
))
type AsciiDoc
description::String
formatdict::Dict{Symbol,Any}
end
#asciidoc -b html5 -a source-highlighter=pygments ...
const adoc = AsciiDoc("AsciiDoc",
@compat Dict{Symbol,Any}(
:codestart => "[source,julia]\n--------------------------------------",
:codeend => "--------------------------------------\n\n",
:outputstart => "--------------------------------------",
:outputend => "--------------------------------------\n\n",
:fig_ext => ".png",
:extension => "txt",
:out_width => "600",
:doctype => "asciidoc"
))
function formatfigures(chunk, docformat::Tex)
@ -284,10 +301,35 @@ function formatfigures(chunk, docformat::Rest)
end
function formatfigures(chunk, docformat::AsciiDoc)
fignames = chunk[:figure]
caption = chunk[:fig_cap]
width = chunk[:out_width]
result = ""
figstring = ""
for fig=fignames
figstring *= @sprintf("image::%s[width=%s]\n", fig, width)
end
if caption != nothing
result *= string("image::$(fignames[1])",
"[width=$width,",
"title=\"$caption\"]")
else
result *= figstring
return result
end
end
#Add new supported formats here
const formats = @compat Dict{String, Any}("tex" => tex,
"texminted" => texminted,
"pandoc" => pandoc,
"github" => github,
"rst" => rst
"rst" => rst,
"asciidoc" => adoc
)