markdown-it-html5-embed
Advanced tools
Comparing version 0.3.0 to 0.3.1
{ | ||
"name": "markdown-it-html5-embed", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"homepage": "https://github.com/cmrd-senya/markdown-it-html5-embed", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -46,3 +46,3 @@ /*! markdown-it-html5-embed https://github.com/cmrd-senya/markdown-it-html5-embed @license MIT */ | ||
if(mimetype_matches !== null && | ||
(!options.html5embed.is_allowed_mime_type || options.html5embed.is_allowed_mime_type(mimetype_matches))) { | ||
(!options.html5embed.isAllowedMimeType || options.html5embed.isAllowedMimeType(mimetype_matches))) { | ||
var media_type = mimetype_matches[1]; | ||
@@ -62,3 +62,3 @@ if(isLink) { | ||
if(options.html5embed.templateName) { | ||
if(!HandlebarsTemplates) { | ||
if(typeof HandlebarsTemplates === "undefined") { | ||
console.log("handlebars_assets is not on the assets pipeline; fall back to the usual mode"); | ||
@@ -90,7 +90,19 @@ } else { | ||
options = { html5embed: { | ||
use_image_syntax: true | ||
useImageSyntax: true | ||
} }; | ||
} | ||
if(options.html5embed.use_image_syntax) { | ||
if(typeof options.html5embed.useImageSyntax === "undefined") { | ||
options.html5embed.useImageSyntax = options.html5embed.use_image_syntax; | ||
} | ||
if(typeof options.html5embed.useLinkSyntax === "undefined") { | ||
options.html5embed.useLinkSyntax = options.html5embed.use_link_syntax; | ||
} | ||
if(typeof options.html5embed.isAllowedMimeType === "undefined") { | ||
options.html5embed.isAllowedMimeType = options.html5embed.is_allowed_mime_type; | ||
} | ||
if(options.html5embed.useImageSyntax) { | ||
var defaultRender = md.renderer.rules.image; | ||
@@ -103,3 +115,3 @@ md.renderer.rules.image = function(tokens, idx, opt, env, self) { | ||
if(options.html5embed.use_link_syntax) { | ||
if(options.html5embed.useLinkSyntax) { | ||
var defaultRender = md.renderer.rules.link_open || function(tokens, idx, options, env, self) { | ||
@@ -106,0 +118,0 @@ return self.renderToken(tokens, idx, options); |
{ | ||
"name": "markdown-it-html5-embed", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "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.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -19,9 +19,10 @@ # 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 | ||
useImageSyntax: true, // Enables video/audio embed with ![]() syntax (default) | ||
useLinkSyntax: 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>' | ||
// <source type="video/webm" src=https://example.com/file.webm></source> | ||
// untitled video | ||
// </video></p>' | ||
``` | ||
@@ -31,7 +32,7 @@ | ||
####use_image_syntax | ||
####useImageSyntax (or use_image_syntax) | ||
Boolean. Enables video/audio embed with ```![]()``` syntax (default) | ||
####use_link_syntax | ||
####useLinkSyntax (or use_link_syntax) | ||
@@ -53,3 +54,3 @@ Boolean. Enables video/audio embed with ```[]()``` syntax | ||
####is_allowed_mime_type | ||
####isAllowedMimeType (or is_allowed_mime_type) | ||
@@ -56,0 +57,0 @@ 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: |
@@ -30,4 +30,4 @@ 'use strict'; | ||
var option = { html5embed: { | ||
use_link_syntax: true, | ||
is_allowed_mime_type: function(mimetype) { | ||
useLinkSyntax: true, | ||
isAllowedMimeType: function(mimetype) { | ||
return (mimetype[0] == 'audio/mpeg') || (mimetype[0] == 'video/ogg'); | ||
@@ -41,1 +41,18 @@ } | ||
describe('markdown-it-html5-embed with handlebars', function() { | ||
before(function (){ | ||
var Handlebars = require("handlebars"); | ||
global.HandlebarsTemplates = {"template": Handlebars.compile( "<h1>{{title}}</h1><div class=\"body\"><{{media_type}} {{attributes}}><source type=\"{{mimetype}}\" src=\"{{source_url}}\"/></{{media_type}}></div>")}; | ||
}); | ||
var option = { html5embed: { | ||
useLinkSyntax: true, | ||
templateName: "template", | ||
attributes: "" | ||
} }; | ||
var md = require('markdown-it')().use(require('../lib'), option); | ||
generate(path.join(__dirname, 'fixtures/with-handlebars.txt'), md); | ||
}); | ||
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
167450
13
6957
78