# Including raw HTML in Julia Markdown

**URL:** <https://discourse.julialang.org/t/including-raw-html-in-julia-markdown/26165>\
**Category:** General Usage\
**Tags:** julia-markdown\
**Created:** [July 8, 2019, 11:27pm UTC](https://discourse.julialang.org/t/including-raw-html-in-julia-markdown/26165 "2019-07-08T23:27:09Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rajesh\_Talluri](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rajesh_talluri/32/10721_2.png) [@Rajesh\_Talluri](https://discourse.julialang.org/u/Rajesh_Talluri)\
**Post date:** [July 8, 2019, 11:27pm UTC](https://discourse.julialang.org/t/including-raw-html-in-julia-markdown/26165/1 "2019-07-08T23:27:09Z")

</div>

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:

1. Is raw HTML and JavaScript allowed in Julia markdown?
2. 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.

[Preserving HTML when processing Markdown](https://discourse.julialang.org/t/preserving-html-when-processing-markdown/12380)

Thanks for your time.

---

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [July 9, 2019, 3:39am UTC](https://discourse.julialang.org/t/including-raw-html-in-julia-markdown/26165/2 "2019-07-09T03:39:15Z")

</div>

How about using [`@raw html` block](https://juliadocs.github.io/Documenter.jl/stable/man/syntax/#@raw-format-block-1) in Documenter?

---

<div class="post-metadata">

**Author:** ![Rajesh\_Talluri](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rajesh_talluri/32/10721_2.png) [@Rajesh\_Talluri](https://discourse.julialang.org/u/Rajesh_Talluri)\
**Post date:** [July 9, 2019, 2:48pm UTC](https://discourse.julialang.org/t/including-raw-html-in-julia-markdown/26165/3 "2019-07-09T14:48:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [July 9, 2019, 7:31pm UTC](https://discourse.julialang.org/t/including-raw-html-in-julia-markdown/26165/4 "2019-07-09T19:31:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![HugoTrentesaux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hugotrentesaux/32/12583_2.png) [@HugoTrentesaux](https://discourse.julialang.org/u/HugoTrentesaux)\
**Post date:** [April 19, 2020, 4:41pm UTC](https://discourse.julialang.org/t/including-raw-html-in-julia-markdown/26165/5 "2020-04-19T16:41:01Z")

</div>

I asked the question here : [plain html in julia markdown - Stack Overflow](https://stackoverflow.com/questions/61307902/plain-html-in-julia-markdown) for builtin Julia Markdown. Did you get an answer that could fit?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [April 20, 2020, 5:52am UTC](https://discourse.julialang.org/t/including-raw-html-in-julia-markdown/26165/6 "2020-04-20T05:52:23Z")

</div>

Raw HTML in Markdown is at best a workaround, and it should not be encouraged — that Markdown may need to be rendered as something other than HTML.

What is the problem that you are trying to solve? Can’t you achieve it with CSS?

---

<div class="post-metadata">

**Author:** ![HugoTrentesaux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hugotrentesaux/32/12583_2.png) [@HugoTrentesaux](https://discourse.julialang.org/u/HugoTrentesaux)\
**Post date:** [April 20, 2020, 7:37am UTC](https://discourse.julialang.org/t/including-raw-html-in-julia-markdown/26165/7 "2020-04-20T07:37:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [April 20, 2020, 7:54am UTC](https://discourse.julialang.org/t/including-raw-html-in-julia-markdown/26165/8 "2020-04-20T07:54:08Z")

</div>

> [@HugoTrentesaux](#):
>
> add a class to an image

There are CSS-based techniques for that, eg see [the “Use CSS And Special URL Parameters” section here](https://www.xaprb.com/blog/how-to-style-images-with-markdown/).

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.

---

<div class="post-metadata">

**Author:** ![HugoTrentesaux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hugotrentesaux/32/12583_2.png) [@HugoTrentesaux](https://discourse.julialang.org/u/HugoTrentesaux)\
**Post date:** [April 20, 2020, 7:59am UTC](https://discourse.julialang.org/t/including-raw-html-in-julia-markdown/26165/9 "2020-04-20T07:59:55Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Post date:** [April 20, 2020, 8:08am UTC](https://discourse.julialang.org/t/including-raw-html-in-julia-markdown/26165/10 "2020-04-20T08:08:17Z")

</div>

An alternative is to use an auxiliary function `fd2html` exported by [Franklin.jl](https://github.com/tlienart/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
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>

```

---

<div class="post-metadata">

**Author:** ![HugoTrentesaux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hugotrentesaux/32/12583_2.png) [@HugoTrentesaux](https://discourse.julialang.org/u/HugoTrentesaux)\
**Post date:** [April 20, 2020, 8:33am UTC](https://discourse.julialang.org/t/including-raw-html-in-julia-markdown/26165/11 "2020-04-20T08:33:12Z")

</div>

Did not know Franklin before, it’s worth knowing it! The solution for html is interesting.  
Btw, there are missing images [here](https://franklinjl.org/code/eval-tricks/#preview__3).

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [April 20, 2020, 8:53am UTC](https://discourse.julialang.org/t/including-raw-html-in-julia-markdown/26165/12 "2020-04-20T08:53:15Z")

</div>

Also take a look at [GithubMarkdown.jl](https://github.com/pfitzseb/GithubMarkdown.jl), which allows you to render [gfm](https://github.github.com/gfm/) to HTML.

---

<div class="post-metadata">

**Author:** ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Post date:** [April 20, 2020, 9:01am UTC](https://discourse.julialang.org/t/including-raw-html-in-julia-markdown/26165/13 "2020-04-20T09:01:54Z")

</div>

thanks for that, now saved by [rick and morty](https://franklinjl.org/code/eval-tricks/#team_cards)
