Will it ever be possible to embed gist snippets in github flavored markdown?
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..
+1
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.
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.
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?
:+1:
:+1:
:+1:
:+1:
:+1:
:+1:
:+1:
:+1:
:+1:
:+1:
:thumbsup:
:+1:
:+1:
:+1:
Thanks for the request. This gem only handles markup to HTML conversion, but I've logged this feature request with our internal teams.
This is not a feature that can be implemented by a change to this library, so I closed the issue.