-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Marked-Extras (Youtube , Vimeo, DailyMotion, Viddler) #362
Comments
Good ideas ! |
Ohh... First comment of given gist disappears.. :D function mediaParser(provider, url) {
if (provider === 'youtube') {
var youtubeRegex = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
var youtubeMatch = url.match(youtubeRegex);
if (youtubeMatch && youtubeMatch[7].length == 11) {
return youtubeMatch[7];
} else {
return undefined;
}
} else if (provider === 'vimeo') {
var vimeoRegex = /^.*vimeo.com\/(\d+)/;
var vimeoMatch = url.match(vimeoRegex);
if (vimeoMatch && vimeoMatch[1].length == 8) {
return vimeoMatch[1];
} else {
return undefined;
}
} else if (provider === 'viddler') {
var viddlerRegex = /^.*((viddler.com\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
var viddlerMatch = url.match(viddlerRegex);
if (viddlerMatch && viddlerMatch[7].length == 8) {
return viddlerMatch[7];
} else {
return undefined;
}
} else if (provider === 'dailymotion') {
var dailymotionRegex = /^.+dailymotion.com\/((video|hub)\/([^_]+))?[^#]*(#video=([^_&]+))?/;
var dailymotionMatch = url.match(dailymotionRegex);
if (dailymotionMatch && (dailymotionMatch[5] || dailymotionMatch[3])) {
if (dailymotionMatch[5]) {
return dailymotionMatch[5];
}
if (dailymotionMatch[3]) {
return dailymotionMatch[3];
}
return undefined;
} else {
return undefined;
}
} /* Buggie...
else if (provider === 'html5') {
var html5Regex = /.(?:wav|mp3|ogg|mp4|wma|webm|mp3)$/i;
var html5Match = url.match(html5Regex);
var data = {
extension: html5Match,
link: url
};
return data;
} else {
return;
} */
} Works with huge variants of media links. :) PS: Wrong line, sorry. Edited to 559 !! |
@tunnckoCore i like project your, did you can share project :) with tutorial install, it's amazing! |
What project? It's addon to marked.js :) Just add above code to main marked.js file on line 559 and it works, nothing more :) PS: its possible to add more regex expressions for more medias (Flickr, Gist, JSFiddle, etc.) |
I extremely link your share demo ! Can you share me project :) 2014-03-17 1:18 GMT+07:00 tunnckoCore notifications@github.com:
Mr. Nguyen Dinh Tung tungnguyen@vsoft.vn | Phone: (04) 38.550.999 | Mobile. 0969.92.1080 VSOFT Solution Co., Ltd Trading office : Trung Yen 1 Tower - Vu Pham Ham str. - Cau Giay dist.- |
This works but I think it brakes the idea behind markdown. If html is needed, why not just disable the sanitize option; that way you can put any html like |
@nbari, its like http auto linking.. nothing more. Why have to put all sucking html (or custom iframe/embed codes), when just can paste link and if it is from "media" (like video sites) to be generate automatically Sorry for english, but its night here :) |
@jonschlinkert, have it in mind for your Also, it's good idea to see some of issues here. Live demo is moved to http://tunnckocore.github.io/blankr/markedjs/, old links edited. |
I have been thinking about this problem for some time and have posted my WIP thoughts to commonmark/commonmark-spec#123 |
closing.. we already have jonschlinkert/remarkable and also with him and few other guys we planing RegExps Org - more info for it |
Thanks for that link @tunnckoCore ! It looks like this library should help this concept nicely... https://github.com/rlidwka/remarkable-regexp |
@howardroark yea, it looks great! Thanks! |
Probably link to sources will help: https://github.com/tunnckoCore/blankr/tree/gh-pages/markedjs I'm curious why this is not under image markdown |
After review the demo this is a rework using image tag so you can control alternate property, title, width and height: Works for any image (img), video (html5), and common video providers (youtube, vimeo, Dailymotion, viddler):
usage examples:
|
@albfan good idea, definitely! But auto-linking and auto-embeding sounds better to me. Soooo, many years... jesus. 😆 |
Indeed you can add verbatim html, this is just if you want non technical users to deal with multimedia |
where add this code? |
Hello again :)
Only to announce that I made it - hell yea 😄 That with medias, without Fatdown and TextFormatter.
I don't know how practical it is, but I download marked.js and add simple function to it to support YouTube, Viddler, DailyMotion, Vimeo AND Autolinking for non-media sites. 😄 For now are only that, but if someone want can add more with simple if-else's
02 May 2014: Working marked.js with Extras
Link to latest commit of my marked.js
Latest Gist doc files
Jsbin example of regex url parser
The text was updated successfully, but these errors were encountered: