markup icon indicating copy to clipboard operation
markup copied to clipboard

Will it ever be possible to embed gist snippets in github flavored markdown?

Open missinglink opened this issue 13 years ago • 40 comments

Will it ever be possible to embed gist snippets in github flavored markdown?

What are the technical issues involved with this, we obviously can't have people injecting random script tags in the page, but there must be another solution?

related: http://stackoverflow.com/questions/11622509/github-how-to-embed-a-gist-into-readme-md

Apologies is this is a duplicate, I assume this has been discussed at some point..

missinglink avatar May 03 '13 18:05 missinglink

+1

ysokolovski avatar Jun 06 '14 20:06 ysokolovski

I've been sitting on this for a while since @missinglink was in my ear about this, and I meant to write up some thoughts about it.

What are the technical issues involved with this, we obviously can't have people injecting random script tags in the page, but there must be another solution?

Off the top of my head, there's a number of questions I have about a hypothetical implementation of this:

  • the obvious security risks with injecting arbitrary content - there's no consistent concept of safe_mode with Markdown, so do we need to address that as part of this?
  • what does the implementation of the tag look like?
    • Is it HTML or a new Markdown tag?
    • do you provide a gist id or just a URL?
    • do you have fallback content for parsers which don't understand GHfM?
  • gists can consist of multiple files - you can link to one file with the # placeholder, but what about multiple files? Or do we just embed them all and you're on your own?
  • gists have revisions - what does the syntax look like if you want to display a specific revision?

But I'll leave it up to others who are more involved with the Gist project to make the final decision.

For some context: I experimented with this problem on a project ages ago. I used HTML comment tags to anchor the dynamic content (in this case, code snippets) around documentation. A script would then search for placeholders, and their associated contents, and update them in one fell swoop.

shiftkey avatar Jun 07 '14 11:06 shiftkey

the obvious security risks with injecting arbitrary content - there's no consistent concept of safe_mode with Markdown, so do we need to address that as part of this?

You could try https://developers.google.com/caja/ Although, it may be overkill. They also have a JsHtmlSanitizer script.

what does the implementation of the tag look like?

I would expect it to work just like linking issues through URLs, except that in this case it recognizes it as a Github gist and expands it. Hackpad does currently expand Github gists for example: https://hackpad.com/Look-Ma-a-Github-gist-EuAaGS6VHmd

do you have fallback content for parsers which don't understand GHfM?

Since it is a URL, other parsers would just show the URL I guess.

gists can consist of multiple files - you can link to one file with the # placeholder, but what about multiple files? Or do we just embed them all and you're on your own?

Hackpad seems to embed them all which I think is fine. If I wanted them separated I would create multiple gists.

gists have revisions - what does the syntax look like if you want to display a specific revision?

Last revision would be fine to begin with, users will let you know if they need more than that.

c4milo avatar Jun 07 '14 16:06 c4milo

I agree with all @c4milo said. As for revisions, it could be interesting to use a simple mark like in jsperf ( /X ) Or even a "#X", or "#!X" in the end of the URL. Although, keeping the last one embeded would already be awesome. A quick question would be...would it stay up to date? If a person updates the gist, the embeded gist is supposed to be shown up to date, right?

felipenmoura avatar Jun 10 '14 03:06 felipenmoura

:+1:

avishnyakov avatar Jun 17 '14 01:06 avishnyakov

:+1:

ixtli avatar Jul 03 '14 21:07 ixtli

:+1:

craighooghiem avatar Jul 04 '14 02:07 craighooghiem

:+1:

radkodinev avatar Jul 24 '14 21:07 radkodinev

:+1:

elado avatar Jul 25 '14 05:07 elado

:+1:

SamHatoum avatar Jul 29 '14 19:07 SamHatoum

:+1:

inlikealion avatar Jul 29 '14 21:07 inlikealion

:+1:

phelma avatar Jul 30 '14 08:07 phelma

:+1:

kongchen avatar Aug 15 '14 04:08 kongchen

:+1:

keegoid avatar Aug 19 '14 13:08 keegoid

:thumbsup:

charandas avatar Aug 26 '14 19:08 charandas

:+1:

mderazon avatar Sep 03 '14 09:09 mderazon

:+1:

andrewmallis avatar Sep 05 '14 06:09 andrewmallis

:+1:

mriddle avatar Sep 26 '14 16:09 mriddle

Thanks for the request. This gem only handles markup to HTML conversion, but I've logged this feature request with our internal teams.

bkeepers avatar Sep 26 '14 22:09 bkeepers

This is not a feature that can be implemented by a change to this library, so I closed the issue.

bkeepers avatar Mar 04 '15 05:03 bkeepers