Embed javascript in markdown

后端 未结 11 2508
[愿得一人]
[愿得一人] 2020-12-13 02:23

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

*blah* blah \"blah\" in [markdown](blah)



        
相关标签:
11条回答
  • 2020-12-13 02:52

    Different solution that might work in some cases: (the selected answer didn't work for me when I was trying to embed a CodePen example)

    • add this to your default layout:

      <!-- Custom JavaScript files set in YAML front matter -->
      {% for js in page.customjs %}
      <script async type="text/javascript" src="{{ js }}"></script>
      {% endfor %}
      
    • In posts where you need some JavaScript files, you can add them in the YAML front matter like so:

      ---
      layout: post
      title: Adding custom JavaScript for a specific post
      category: posts
      customjs:
       - http://code.jquery.com/jquery-1.4.2.min.js
       - http://yourdomain.com/yourscript.js
      ---
      

    The async might not be necessary or wanted but you could probably add that as a parameter in customjs. (see YAML front matter for Jekyll and nested lists for details)

    0 讨论(0)
  • 2020-12-13 02:53

    The example they give on their site shows an empty <script> tag containing a newline. Maybe that's it?

    0 讨论(0)
  • 2020-12-13 03:01

    Markdown supports inline XHTML but not Javascript.

    0 讨论(0)
  • 2020-12-13 03:02

    You could use pandoc, which handles this input (and javascript generally) just fine.

    0 讨论(0)
  • 2020-12-13 03:03

    I use this code to write JavaScript code in markdown.

    just add js after "```" , and you'll have your JavaScript code highlighted.

    
     ```js
       const myvar = "hello"
       module.exports.response = response = ()=>{mycode here}
        ```
    
    0 讨论(0)
提交回复
热议问题