Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

markdown-it-html5-embed

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-it-html5-embed

This is a plugin for markdown-it which adds support for embedding audio/video in the HTML5 way using image embedding syntax ![](url). This is done by replacing standard image renderer of markdown-it.

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
871
decreased by-4.81%
Maintainers
1
Weekly downloads
 
Created
Source

markdown-it-html5-embed

This is a plugin for markdown-it which adds support for embedding audio/video in the HTML5 way

Install

node.js, bower:

npm install markdown-it-html5-embed --save
bower install markdown-it-html5-embed --save

Use

var md = require('markdown-it')()
            .use(require('markdown-it-html5-embed'), {
              html5embed: {
                use_image_syntax: true, // Enables video/audio embed with ![]() syntax (default)
                use_link_syntax: true   // Enables video/audio embed with []() syntax
            }});

md.render('![](http://example.com/file.webm)'); // => '<p><video width="320" height="240" class="audioplayer" controls>
                                                //<source type="video/webm" src=http://example.com/file.webm></source>
                                                //</video></p>'

Options

####use_image_syntax

Boolean. Enables video/audio embed with ![]() syntax (default)

####use_link_syntax

Boolean. Enables video/audio embed with []() syntax

####attributes

Hash array. Attribute to pass to audio/video tag. Example:

    attributes: {
      'audio': 'width="320" controls class="audioplayer"',
      'video': 'width="320" height="240" class="audioplayer" controls'
    }

If not specified, the default value of controls preload="metadata" is used.

####is_allowed_mime_type

Function. If specified, allows to decided basing on the MIME type, wheter to embed element or not. If not, all audio/video content is embedded. In a web browser you can use following code to embed only supported media type:

      is_allowed_mime_type: function(mimetype) {
        var v = document.createElement(mimetype[1]);
        return v.canPlayType && v.canPlayType(mimetype[0]) !== '';
      }

This way, all unsupported media will be rendered with defualt renderer (e.g., as a link, if use_link_syntax is true).

The argument is a result of regexp match, and has a structure similar to that one:

[ 'audio/mpeg',
  'audio',
  index: 0,
  input: 'audio/mpeg' ]

Credits

Based on the code written by @v3ss0n.

Keywords

FAQs

Package last updated on 22 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc