diff --git a/src/display_methods.jl b/src/display_methods.jl index a28becf..76b4162 100644 --- a/src/display_methods.jl +++ b/src/display_methods.jl @@ -106,7 +106,16 @@ end #Catch "rich_output" function Base.display(report::Report, m::MIME"text/markdown", data) s = repr(m, data) - report.rich_output *= "\n" * s + # Convert to "richer" type of possible + for m in report.mimetypes + if m == "text/html" || m == "text/latex" + display(Markdown.parse(s)) + break + elseif m == "text/markdown" + report.rich_output *= "\n" * s + break + end + end end function Base.display(report::Report, m::MIME"text/latex", data) diff --git a/src/formatters.jl b/src/formatters.jl index 7cef86e..9154ab1 100644 --- a/src/formatters.jl +++ b/src/formatters.jl @@ -88,6 +88,7 @@ const github = GithubMarkdown("Github markdown", :outputend=> "````\n\n", :fig_ext=> ".png", :extension=> "md", + :mimetypes => ["image/png", "image/svg+xml", "image/jpg", "text/markdown", "text/plain"], :doctype=> "github" )) @@ -144,8 +145,8 @@ const md2tex = JMarkdown2tex("Julia markdown to latex", Dict{Symbol,Any}( :fig_ext=> ".pdf", :extension=> "tex", :out_width => "\\linewidth", - :mimetypes => ["application/pdf", "image/png", "image/jpg", - "text/latex", "text/plain"], + :mimetypes => ["application/pdf", "image/png", "image/jpg", "text/latex", + "text/markdown", "text/plain"], :doctype=> "md2tex")) diff --git a/templates/skeleton_css.css b/templates/skeleton_css.css index e23b596..f255919 100644 --- a/templates/skeleton_css.css +++ b/templates/skeleton_css.css @@ -500,16 +500,15 @@ pre { } pre.hljl { + margin: 0 0 10px; display: block; background: #f5f5f5; border-radius: 4px; + padding : 5px; } pre.output { background: #ffffff; - /* matching hard-coded values in Highlights.jl */ - margin : 5px; - padding : 5px; } pre.julia-error { diff --git a/test/documents/markdown_output.jmd b/test/documents/markdown_output.jmd new file mode 100644 index 0000000..68769cc --- /dev/null +++ b/test/documents/markdown_output.jmd @@ -0,0 +1,31 @@ + + +```julia +display("text/markdown", +""" + +### Small markdown sample + +**Hello** from `code` block. + +""") +``` + + +```julia +struct Dummy + s::String +end + +function Base.show(io::IO, m::MIME"text/markdown", d::Dummy) + print(io, d.s) +end + +Dummy(""" + +* one +* two +* three + +""") +``` diff --git a/test/documents/multimedia/rich_output.github.ref b/test/documents/multimedia/rich_output.github.ref index 6ecce14..48237c9 100644 --- a/test/documents/multimedia/rich_output.github.ref +++ b/test/documents/multimedia/rich_output.github.ref @@ -40,7 +40,12 @@ ca -
a |
b |
c |
d |
a |
b |
c |
d |
1 | 1 |
2 | 2 |
3 | 3 |
Some Markdown
-Hello from code
block.
one
\ntwo
\nthree
\n