Home

Awesome

docsify-codeblock-iframe

version download cnpmVersion cnpmDownload jsdelivr

A plugin that provides markdown extra codeblock-iframe syntax support for docsify, just for supporting iframe rendering securely!

简体中文 | English

Try it

Demo

Usage

Import dependencies from CDN

<script src="//cdn.jsdelivr.net/npm/codeblock-iframe@latest/dist/index.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify-codeblock-iframe@latest/dist/index.min.js"></script>

Following formats of src are supported!

www.baidu.com
//www.baidu.com
http://www.baidu.com
https://www.baidu.com
Attributes
src
height
width
align
frameborder
longdesc
marginheight
marginwidth
name
sandbox
scrolling
seamless
srcdoc
textContent

Why To Do

To be honest, Markdown supports HTML tags natively! But here are some issues we have to face as followed:

  1. If I didn't want my users insert ads in their posts via iframe but supported them using codepen to share their codes, how could I do?
  2. Sometimes we try to insert iframe in some markdown editor. For immediately rendering, the browser will send a lot of GET requests to our target website when we inputting, how could we optimize? Even it causes our page breakdown when developing and using SSR

How To Do

Code Block Renderer is easy for us to extend native markdown syntax, so we can limit the frequency of iframe rendering in this way.

Thanks