Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pelican: How to embed html and javascript in markdown

I want to embed a few html elements and javascript in a blog post. This is my markdown file.

Title: Foo
Tags: Bar

Some Content here 

        <div id="foo">
        </div>

        <script type="text/javascript" src="static/js/bar.js"> </script>

But pelican is wrapping the html tags in a pre. So the code is not getting executed.

I'm using the Markdown library installed from pip install Markdown, version 2.3.1

I checked the docs, but to no avail.

How to avoid this from happening, either through markdown or in a pelican setting?

like image 834
Pramod Avatar asked Sep 26 '13 19:09

Pramod


People also ask

Can you embed HTML in Markdown?

Markdown supports HTML, so if you need to, say, embed a YouTube video, you can just copy and paste the embed code from them, drop it into a Markdown document, and you should be good to go.

Can you add JavaScript to Markdown?

You can do this by adding the name of the language on the same line as your opening three back ticks. In the example above, if instead of the first line being ``` you could write ```js, then JavaScript highlighting will be applied to the block. Just remember, not all markdown engines will apply syntax highlighting.


1 Answers

Probably the reason its not working is that you've indented your code, which means that it gets inserted as a <code> block in the HTML, according to the Markdown spec: daringfireball.net/projects/markdown/syntax#precode

like image 166
darthbith Avatar answered Oct 23 '22 03:10

darthbith