Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AsciiDoc: How to embed youtube videos in github-flavored asciidoc?

I'm writing documentation using the asciidoc markup language and pushing it to a github repo. Github renders asciidoc files (*.adoc) automatically but does for (me) unknown reasons not want to accept my embedding of a youtube video.

I've tried the recommended way from the asciidoc writer's guide (e.g.)

video::rAteGra5-xM[youtube]

The preview in atom editor works, export to HTML version works. Can you help? What is the preferred way to get this to work in github rendered asciidoc pages?

Thanks

like image 235
Matthias Kubisch Avatar asked Oct 17 '25 18:10

Matthias Kubisch


1 Answers

GitHub strips away <iframe> (for security reasons I guess) so you won't be able to embed a YouTube video in your README.

As a workaround you can do the following:

ifdef::env-github[]
image:https://img.youtube.com/vi/rAteGra5-xM/maxresdefault.jpg[link=https://youtu.be/rAteGra5-xM]
endif::[]

ifndef::env-github[]
video::rAteGra5-xM[youtube]
endif::[]

In the above example, I'm using the image macro to show the thumbnail of the YouTube video with a link to the video on YouTube when the README is rendered on GitHub. Otherwise I'm using the video macro.

And here's the result on GitHub:

result

And if I click on the image, it will open https://youtu.be/rAteGra5-xM

like image 58
Mogztter Avatar answered Oct 19 '25 14:10

Mogztter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!