markdown-it-html5-embed
Advanced tools
Comparing version 0.2.0 to 0.3.0
{ | ||
"name": "markdown-it-html5-embed", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"homepage": "https://github.com/cmrd-senya/markdown-it-html5-embed", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -27,2 +27,3 @@ /*! markdown-it-html5-embed https://github.com/cmrd-senya/markdown-it-html5-embed @license MIT */ | ||
var isLink; | ||
var title; | ||
var aIndex = token.attrIndex('src'); | ||
@@ -32,2 +33,5 @@ if(aIndex < 0) { | ||
isLink = true; | ||
title = tokens[idx+1].content; | ||
} else { | ||
title = token.attrs[token.attrIndex('alt')][1]; | ||
} | ||
@@ -49,2 +53,5 @@ // console.log('aindex of idx' + idx); | ||
} | ||
if(!title) { | ||
title = "untitled " + media_type; | ||
} | ||
if(typeof options.html5embed.attributes === "undefined"){ | ||
@@ -56,4 +63,19 @@ options.html5embed.attributes = {}; | ||
} | ||
if(options.html5embed.templateName) { | ||
if(!HandlebarsTemplates) { | ||
console.log("handlebars_assets is not on the assets pipeline; fall back to the usual mode"); | ||
} else { | ||
return HandlebarsTemplates[options.html5embed.templateName]({ | ||
media_type: media_type, | ||
attributes: options.html5embed.attributes[media_type], | ||
mimetype: mimetype, | ||
source_url: token.attrs[aIndex][1], | ||
title: title, | ||
needs_cover: media_type==="video" | ||
}); | ||
} | ||
} | ||
return ['<' + media_type +' ' + options.html5embed.attributes[media_type] + '>', | ||
'<source type="' + mimetype + '" src=' + token.attrs[aIndex][1] + '></source>', | ||
title, | ||
'</' + media_type + '>' | ||
@@ -60,0 +82,0 @@ ].join('\n'); |
{ | ||
"name": "markdown-it-html5-embed", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"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", |
@@ -70,4 +70,8 @@ # markdown-it-html5-embed | ||
####templateName | ||
String. If the plugin is used in a Rails asset pipeline along with the handlebars_assets gem, then you can use a Handlebars template to control the output of the plugin. This option specifies the name of the template to use, which will be picked from the HandlebarsTemplates array. | ||
## Credits | ||
Based on [the code](http://talk.commonmark.org/t/embedded-audio-and-video/441/16) written by @v3ss0n. |
@@ -7,2 +7,3 @@ Video with image syntax: | ||
<source type="video/webm" src=https://example.com/file.webm></source> | ||
untitled video | ||
</video></p> | ||
@@ -17,2 +18,3 @@ . | ||
<source type="audio/ogg" src=https://example.com/file.ogg></source> | ||
untitled audio | ||
</audio></p> | ||
@@ -19,0 +21,0 @@ . |
@@ -7,2 +7,3 @@ Video with link syntax: | ||
<source type="video/webm" src=https://example.com/file.webm></source> | ||
test link | ||
</video></p> | ||
@@ -17,2 +18,3 @@ . | ||
<source type="video/webm" src=https://example.com/file.webm></source> | ||
untitled video | ||
</video></p> | ||
@@ -19,0 +21,0 @@ . |
@@ -14,2 +14,3 @@ Webm is not allowed: | ||
<source type="audio/mpeg" src=https://example.com/file.mp3></source> | ||
untitled audio | ||
</audio></p> | ||
@@ -24,2 +25,3 @@ . | ||
<source type="video/ogg" src=https://example.com/file.ogv></source> | ||
test link | ||
</video></p> | ||
@@ -26,0 +28,0 @@ . |
Sorry, the diff of this file is too big to display
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
165418
915
6935
77
0