Skip to content

MarkdownIt plugin allowing the integration of hundred of embeddable urls (thanks to the oEmbed standard): Youtube, Vimeo, Instagram, Giphy...

Notifications You must be signed in to change notification settings

ybouane/markdown-it-oembed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation

npm install markdown-it-oembed --save

How it works

This plugin uses a list of providers providers.json to match embeddable URLs and retrieves the HTML code required to display the embed. Since the oEmbed process requires making an HTTP request, it must be done asynchronously. I have reimplemented the MarkdownIt.render function to support that. The new function is called  MarkdownIt.renderAsync (or for inline: MarkdownIt.renderInlineAsync)

In the markdown code, you need to put the embed URL in the image tag as follows:

![Getting Started: Sktch.io](https://www.youtube.com/watch?v=CMfBj0U221k)

Example usage

const MarkdownIt 			= require('markdown-it');
const MarkdownItOEmbed 			= require('markdown-it-oembed');

var md = new MarkdownIt({
	linkify	: true,
	breaks	: false,
});
md.use(MarkdownItOEmbed);
(async () => {
	console.log(await md.renderAsync('![Getting Started: Sktch.io](https://www.youtube.com/watch?v=CMfBj0U221k)'));
})();

About

MarkdownIt plugin allowing the integration of hundred of embeddable urls (thanks to the oEmbed standard): Youtube, Vimeo, Instagram, Giphy...

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published