3

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

1 Answers1

6

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

Mogztter
  • 421
  • 3
  • 3