evilstreak / markdown-js

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

YouTube video markdown #226

Open kstubs opened 9 years ago

kstubs commented 9 years ago

This works great to produce a link to a YouTube video, but if I want to produce YouTubes embed tag into my html, so basically an iFrame widget, how would I go about doing this? Do I provide a different dialect or function somehow?

markdown.toHTML('[![Bronwyn’s Perfect 10 on Vault](http://img.youtube.com/vi/LVbbC4cmI9I/0.jpg)](http://www.youtube.com/watch?v=LVbbC4cmI9I)')

Produces quite nicely:

<p><a href="http://www.youtube.com/watch?v=LVbbC4cmI9I"><img alt="Bronwyn’s Perfect 10 on Vault" src="http://img.youtube.com/vi/LVbbC4cmI9I/0.jpg"/></a></p>
jaredatron commented 9 years ago

Markdown does not support YouTube anything but it does support HTML. Just paste the YouTube embed code directly into your document.

kstubs commented 9 years ago

Not sure if I'm following you exactly. My challenge is: my document source is a Google Document. Google Documents do not support embeded videos so my solution is to provide the video via markdown code and then parse it on the client. This is working great, I'm just not sure how to add a different markdown output than what is currently being produced: an image that links to youtube video.

jaredatron commented 9 years ago

I have no idea how to solve your weird google docs thing. But in terms of markdown, markdown supports HTML :)

kstubs commented 9 years ago

Lol. Ok forget Google Docs. The real question here is: how can I generate a custom markdown result?

jaredatron commented 9 years ago

You would have to write your own dialect

kstubs commented 9 years ago

Do I provide a different dialect or function somehow?

Lol, how? Can you offer some tips?

jaredatron commented 9 years ago
  1. read the README.md
  2. read the source code for the existing dialects
  3. write your own.
grofit commented 9 years ago

I must admit the existing dialects are not the easiest to decipher, a section in the documentation about this would go a long way.

jaredatron commented 9 years ago

+1

codingisacopingstrategy commented 9 years ago

Maybe a simpler example, this a dialect my co-worker made. Writing dialects might not be very straightforward, but it’s easier to do than in most Markdown implementations: https://github.com/aleray/markdown-js/blob/9373b6b4b435aff47ed533f1cf111b9c884d430a/src/dialects/aa.js

Your linked image solution seems a pretty efficient though :)

ghost commented 8 years ago

I'm using this in tiddlywiki plugin and I can't achieve to embed vimeo videos. It's supposed that markdown allow html embed, but this library does not:

<figure class="center">
<iframe src="https://player.vimeo.com/video/159057636" width="600" height="337" frameborder="0" allowfullscreen=""></iframe>
<figcaption>
<small>
<p><em><a href="http://www.rtve.es/alacarta/videos/telediario/telediario-15-horas-24-12-15/3421858/">Telediario 15:00</a></em> de TVE1 (24/12/2015). &copy; RTVE 2015 (disponible <a href="/media/content/activities/La-lluna-plena/act3.webm">localment</a>).</p>
</small>
</figcaption>
</figure>

Related to fully support HTML

bmamouri commented 7 years ago

@deadlyicon markdown does support HTML but markdown-js escape HTML tags!