Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed javascript in markdown

I'm using the Maruku markdown processor. I'd like this

*blah* blah "blah" in [markdown](blah)  <script src="http://code.jquery.com/jquery-1.4.2.min.js"></script> <script> ...do stuff... </script> 

but it complains when I render it with a multitude of errors. The first one being

 ___________________________________________________________________________ | Maruku tells you: +--------------------------------------------------------------------------- | Could you please format this better? | I see that "<script type='text/javascript'>" is left after the raw HTML. | At line 31 |   raw_html     |<script src='http://code.jquery.com/jquery-1.4.2.min.js' /><script type='text/javascript'>| |       text --> |//<![CDATA[| 

and then the rest seems like the parser is going nuts. Then it renders the javascript into a div on the page. I've tried making it a CDATA block and extra spacing between the jquery and my script.

Help?

like image 748
Paul Tarjan Avatar asked May 02 '10 17:05

Paul Tarjan


People also ask

Can you embed JavaScript in markdown?

Markdown supports inline XHTML but not Javascript.

How do you add a script to markdown?

You have two options: You could include raw HTML <script> tags in your Markdown, or you could use MkDocs' extra_javascript setting to point to your own JavaScript file.

Can you embed JavaScript?

You can add JavaScript code in an HTML document by employing the dedicated HTML tag <script> that wraps around JavaScript code. The <script> tag can be placed in the <head> section of your HTML or in the <body> section, depending on when you want the JavaScript to load.


Video Answer


1 Answers

I had this same problem, but I managed to get JavaScript to appear in my code by putting a newline after the opening tag.

like image 78
S M Avatar answered Oct 11 '22 19:10

S M