Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Embed extension #805

Merged
merged 1 commit into from
Feb 12, 2022
Merged

Add Embed extension #805

merged 1 commit into from
Feb 12, 2022

Conversation

colinodell
Copy link
Member

@colinodell colinodell commented Feb 6, 2022

Implements the ability to easily embed rich content from other websites via OEmbed and other such APIs.

Syntax

The syntax for using this extension is straight-forward - just drop a link on its own line anywhere in the Markdown document:

Check out this video!

https://www.youtube.com/watch?v=dQw4w9WgXcQ

More details about the syntax and usage of the extension can be found in the proposed documentation for this extension.

Previously Proposed Syntax

I initially proposed reusing the image syntax for this feature:

![](https://www.youtube.com/watch?v=dQw4w9WgXcQ)

But on further reflection this had some significant downsides:

Performance

It would be impossible to differentiate between an image and an embeddable resource without making an HTTP request each time image-like syntax appeared. Even if we managed to make those calls in parallel, it still requires extra wasted overhead.

Violates the spirit of Markdown

As John Gruber said:

The overriding design goal for Markdown’s formatting syntax is to make it as readable as possible. The idea is that a Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions.

Violates the spirit of OEmbed

The whole point of OEmbed is that users simply drop a link somewhere:

oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource

The experience should be seamless, just like it is when posting URLs on Twitter, Slack, etc.

Feedback Wanted

Any/all feedback on this feature would be greatly appreciated!

(Closes #740)

@colinodell colinodell added enhancement New functionality or behavior feedback wanted We need your input! labels Feb 6, 2022
@colinodell colinodell added this to the v2.3 milestone Feb 6, 2022
@colinodell colinodell self-assigned this Feb 6, 2022
@colinodell colinodell linked an issue Feb 6, 2022 that may be closed by this pull request
@colinodell colinodell force-pushed the embed-extension branch 3 times, most recently from 482534d to 60f2671 Compare February 6, 2022 01:03
@arabcoders
Copy link

arabcoders commented Feb 6, 2022

I honestly think directly parsing the URLs might be a really bad idea. sometimes you just want put a URL in the text.

I think the old proposal was on correct track as this is not a standard, i think you may even go further by using specific tags. like

![:video this is video example](url) ![:image this is image example](url) 

as such you dont have to parse the whole body and user get to choose if they want make it embeddable or something else, this extension could as well put the two functionality and let the user choose. and the domains should be extendable, for self hosted etc.

Violates the spirit of OEmbed

This might be applicable if you have some sort of URL textbox specific for URLs. However markdown usually used in text area with many many different text some which might look like a URL. In this case i dont think it's applicable.

Thank you.

@kleinmann
Copy link

I like limiting the embeds to standalone links and ignoring them in any other elements like inline with text.

I'm not sure if users would simultaneously want to embed stuff, but also show text links as separate blocks in the same document. I'd probably put the link in something like a blockquote, if I want to emphasize the link itself in such cases.
Those would then be excluded from the proposed embed solution, right?

I also follow the argument of not using any additional syntax (like image embeds) for this. This is comparable to the autolink extension for me, in that deactivating the extension still renders a perfectly fine document without extension-specific artifacts.

Looking forward to this extension 🙂

@colinodell
Copy link
Member Author

colinodell commented Feb 6, 2022

I honestly think directly parsing the URLs might be a really bad idea. sometimes you just want put a URL in the text.

This Embed extension will only attempt to embed URLs that:

  1. Are the only text within a paragraph (must have an empty line before and after, and no other text or syntax on the same line), and that paragraph must not be nested inside some other block (like a list, blockquote, etc)
  2. Start with https://
  3. Don't use the [label](url) or <url> syntax

Normally these URLs would be rendered as plain text (unless you use the Autolink extension).

If the given URL does not contain embeddable content, it will be rendered as a normal link instead (just like how Autolink would handle it).

And lastly, users would have to opt-in to using this extension - it would not be enabled by default. If somebody does enable this and they still want to place a URL on its own line without embedding it, they could use the <url> syntax instead to make it a link.

I'm not sure if users would simultaneously want to embed stuff, but also show text links as separate blocks in the same document. I'd probably put the link in something like a blockquote, if I want to emphasize the link itself in such cases.
Those would then be excluded from the proposed embed solution, right?

Yep, that's exactly right. You could nest it in a blockquote, wrap it with emphasis (* or _), or make it a code span to keep it as a non-clickable, unlinked text.

@some0ne2
Copy link

some0ne2 commented Feb 7, 2022

Will there be a way to "disable" this behavior / keep the old style?

All the best;

@colinodell
Copy link
Member Author

Will there be a way to "disable" this behavior / keep the old style?

Yes, this is an optional extension which will not be enabled by default. Only users who explicitly add and configure this additional extension will get this behavior.

@colinodell colinodell merged commit fd9d49e into main Feb 12, 2022
@colinodell colinodell deleted the embed-extension branch February 12, 2022 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New functionality or behavior feedback wanted We need your input!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] Embed Extension
4 participants