evilstreak / markdown-js

A Markdown parser for javascript
7.69k stars 863 forks source link

how to render a youtube link #171

Open ghost opened 10 years ago

ghost commented 10 years ago

I was using showdown.js until recently, but I want to try out markdown-js. Is it possible to render something like this:

^^http://youtube.com/watch?v=somestring

into this:

<iframe  src=//www.youtube.com/embed/somestring?rel=0 frameborder=0 allowfullscreen></iframe>

There is an extension for this on showdown, I am not sure how to extend this parser.

evilstreak commented 10 years ago

To do this you should create a new dialect and then add a new block level matcher which checks for a block starting with ^^. I suggest looking at how the Maruku dialect extends the Gruber dialect for reference.