In Markdown, is there a way to stop images from being wrapped with

tags?

前端 未结 3 885
长情又很酷
长情又很酷 2021-01-01 23:06

I\'m using Jekyll and all my posts are in .md format for convenience. The problem is that the generator is automatically wrapping every line in paragraph tags.



        
3条回答
  •  天命终不由人
    2021-01-01 23:34

    Images are inline elements, intended to reside within a block-level element like a paragraph. Markdown parsers are therefore correcting your ‘mistake’ and wrapping the img inside a paragraph tag.

    Wrapping your img tag inside an appropriate block-level element, like figure should prevent this behaviour. Eg:

    If you want to automate things a little and you are not planning to generate your site on Github pages (where plugins are not allowed) then you can make use of a plugin to assist in this and make image insertion in your posts easier. I'm using a modified version of this plugin:

    https://github.com/opattison/jekyll-figure-image-tag/blob/master/figure_image_tag.rb

提交回复
热议问题