markdown-js icon indicating copy to clipboard operation
markdown-js copied to clipboard

YouTube video markdown

Open kstubs opened this issue 11 years ago • 12 comments
trafficstars

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>

kstubs avatar Oct 31 '14 15:10 kstubs

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

jaredatron avatar Oct 31 '14 16:10 jaredatron

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.

kstubs avatar Oct 31 '14 17:10 kstubs

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

jaredatron avatar Oct 31 '14 17:10 jaredatron

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

kstubs avatar Oct 31 '14 17:10 kstubs

You would have to write your own dialect

jaredatron avatar Oct 31 '14 17:10 jaredatron

Do I provide a different dialect or function somehow?

Lol, how? Can you offer some tips?

kstubs avatar Oct 31 '14 17:10 kstubs

  1. read the README.md
  2. read the source code for the existing dialects
  3. write your own.

jaredatron avatar Oct 31 '14 21:10 jaredatron

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

grofit avatar Dec 04 '14 18:12 grofit

+1

jaredatron avatar Dec 04 '14 18:12 jaredatron

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 :)

codingisacopingstrategy avatar Dec 14 '14 23:12 codingisacopingstrategy

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

ghost avatar May 06 '16 08:05 ghost

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

bmamouri avatar Aug 08 '16 16:08 bmamouri