Hi,
I am trying to create a report in Julia markdown using the Weave.jl Package. However, I got stuck when using raw HTML or JavaScript in the document as it does not get rendered correctly. Using pandoc to convert the markdown to HTML works fine when using pandoc markdown. My questions are:
Is raw HTML and JavaScript allowed in Julia markdown?
Is there anyway to add this functionality in Julia Markdown (Some resources would be helpful) or using pandoc is the only way for such reports for now?
There was one other topic similar to this last year which did not get answered, so I was wondering if something changed in this time.
Thank You @tkf . I guess this is the way I need to proceed even though it may be slightly cumbersome to include Documenter.jl markdown parsing into Weave.jl.
Is it too crazy to just use Documenter.jl instead of Weave.jl? You can use @example and @eval to execute Julia code. Isn’t it the main feature of Weave.jl? I’ve never used Weave.jl (as I use Literate.jl + Documenter.jl for literate programming) so I may be missing something, though.
I’m used to include basic html in my markdown files, let’s say to add a class to an image or to use features not covered by markdown. That’s why I was surprised Base.Markdown escaping all html. But I can escape myself what needs to be escaped and silence the existing escape function. This is an other workaround.
Originally Markdown was indeed developed for mixing in HTML entities. Then people started to utilize it as a general markup language for rendering to various other formats, which is pretty much the way Julia uses it. This use case does not mix well with HTML entities.
I did not know these CSS selectors. They require a separate stylesheet because for the same reason I can not include a <style> tag. I’m going to think about it…
An alternative is to use an auxiliary function fd2html exported by Franklin.jl which supports inclusion of HTML blocks. I’m not sure of your use case but assuming you want to write in Markdown and get some resulting HTML then that would do the job:
julia> using Franklin
julia> s = """
Some **Markdown** with _emphasis_ and `inline` code and then
~~~
<div class="blah">Hello</div>
~~~
Then more [markdown](https://daringfireball.net/projects/markdown/).
"""
julia> println(s |> fd2html)
<p>Some <strong>Markdown</strong> with <em>emphasis</em> and <code>inline</code> code and then
<div class="blah">Hello</div>
Then more <a href="https://daringfireball.net/projects/markdown/">markdown</a>.</p>