support oEmbed media embedding #211

Closed
opened 2026-01-29 14:30:31 +00:00 by claunia · 4 comments
Owner

Originally created by @damageboy on GitHub (May 25, 2018).

markdig currently supports a very specific list of media embedding as described in:
https://github.com/lunet-io/markdig/blob/master/src/Markdig.Tests/Specs/MediaSpecs.md

I was wondering if there was ever serious consideration of implementing an oEmbed client inside markdig and support embedding of foreign content in a more generalized way...

There seems to be a very full functional client called embedo which does all the magic, in theroy of embedding various 3rd part contents inside existing html.

Would using embedo (as in generating embedo code on the generated html) be something markdig devs would accept as a PR?
If not, would implementing oEmbed calls be something that markdig devs would be willing to incorporate?

From what I see there a various embedding "specs" to consider:

http://oembed.com/

http://ogp.me/

https://dev.twitter.com/cards/overview

Originally created by @damageboy on GitHub (May 25, 2018). markdig currently supports a very specific list of media embedding as described in: https://github.com/lunet-io/markdig/blob/master/src/Markdig.Tests/Specs/MediaSpecs.md I was wondering if there was ever serious consideration of implementing an oEmbed client inside markdig and support embedding of foreign content in a more generalized way... There seems to be a very full functional client called embedo which does all the magic, in theroy of embedding various 3rd part contents inside existing html. Would using embedo (as in generating embedo code on the generated html) be something markdig devs would accept as a PR? If not, would implementing oEmbed calls be something that markdig devs would be willing to incorporate? From what I see there a various embedding "specs" to consider: http://oembed.com/ http://ogp.me/ https://dev.twitter.com/cards/overview
claunia added the enhancement label 2026-01-29 14:30:31 +00:00
Author
Owner

@xoofx commented on GitHub (May 25, 2018):

Do you have a simple example how this would be integrated in markdig, what kind of output it would produce?...etc. (sorry, don't have time to read all the specs, just looking for a high level view of the usage/results 😅 )

@xoofx commented on GitHub (May 25, 2018): Do you have a simple example how this would be integrated in markdig, what kind of output it would produce?...etc. (sorry, don't have time to read all the specs, just looking for a high level view of the usage/results 😅 )
Author
Owner

@damageboy commented on GitHub (May 26, 2018):

Sure... Let's take oEmbed for youtube's case:

Vidoe:
https://www.youtube.com/watch?v=M3r2XDceM6A

That video, in it's html <head> has the following <link>:

<link rel="alternate" href="http://www.youtube.com/oembed?format=json&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DM3r2XDceM6A" title="Amazing Nintendo Facts" type="application/json+oembed">

Folowing that link (either during HTML rendering or markdown, or by embedding JS libs like embedo
would retrieve the following json:

{
  "author_url": "https://www.youtube.com/user/ZackScott",
  "width": 480,
  "version": "1.0",
  "author_name": "ZackScott",
  "provider_url": "https://www.youtube.com/",
  "thumbnail_height": 360,
  "height": 270,
  "provider_name": "YouTube",
  "type": "video",
  "thumbnail_url": "https://i.ytimg.com/vi/M3r2XDceM6A/hqdefault.jpg",
  "title": "Amazing Nintendo Facts",
  "html": "<iframe width=\"480\" height=\"270\" src=\"https://www.youtube.com/embed/M3r2XDceM6A?feature=oembed\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen></iframe>",
  "thumbnail_width": 480
}

The json basically provides enough data/metadata to do the youtube embedding of the video...

Is that the sort of description you had in mind?

@damageboy commented on GitHub (May 26, 2018): Sure... Let's take oEmbed for youtube's case: Vidoe: https://www.youtube.com/watch?v=M3r2XDceM6A That video, in it's html `<head>` has the following `<link>`: ``` <link rel="alternate" href="http://www.youtube.com/oembed?format=json&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DM3r2XDceM6A" title="Amazing Nintendo Facts" type="application/json+oembed"> ``` Folowing that link (either during HTML rendering or markdown, or by embedding JS libs like embedo would retrieve the following json: ``` { "author_url": "https://www.youtube.com/user/ZackScott", "width": 480, "version": "1.0", "author_name": "ZackScott", "provider_url": "https://www.youtube.com/", "thumbnail_height": 360, "height": 270, "provider_name": "YouTube", "type": "video", "thumbnail_url": "https://i.ytimg.com/vi/M3r2XDceM6A/hqdefault.jpg", "title": "Amazing Nintendo Facts", "html": "<iframe width=\"480\" height=\"270\" src=\"https://www.youtube.com/embed/M3r2XDceM6A?feature=oembed\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen></iframe>", "thumbnail_width": 480 } ``` The json basically provides enough data/metadata to do the youtube embedding of the video... Is that the sort of description you had in mind?
Author
Owner

@xoofx commented on GitHub (May 28, 2018):

Thanks.

So If I understand it correctly, it would require an extension to perform the download of the JSON, analyze it and output the correct link instead... Is that correct?

If it is the case, I'm fine for an extension to do this, but I would prefer not to integrate this as part of markdig repo as it will require a dependency on HTTP client (not by default on netstandard) and JSON. If you would like this feature, you could develop your own extension of markdig in a separate repo.

@xoofx commented on GitHub (May 28, 2018): Thanks. So If I understand it correctly, it would require an extension to perform the download of the JSON, analyze it and output the correct link instead... Is that correct? If it is the case, I'm fine for an extension to do this, but I would prefer not to integrate this as part of markdig repo as it will require a dependency on HTTP client (not by default on netstandard) and JSON. If you would like this feature, you could develop your own extension of markdig in a separate repo.
Author
Owner

@damageboy commented on GitHub (May 29, 2018):

OK, I think I understand your thinking about this.

@damageboy commented on GitHub (May 29, 2018): OK, I think I understand your thinking about this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#211