Add images and binary content on gist preview (#615)
هذا الالتزام موجود في:
@@ -27,8 +27,9 @@ func (r HighlightedFile) InternalType() string {
|
||||
|
||||
type RenderedGist struct {
|
||||
*db.Gist
|
||||
Lines []string
|
||||
HTML string
|
||||
Lines []string
|
||||
HTML string
|
||||
PreviewMimeType *git.MimeType
|
||||
}
|
||||
|
||||
func highlightFile(file *git.File) (HighlightedFile, error) {
|
||||
@@ -76,6 +77,18 @@ func HighlightGistPreview(gist *db.Gist) (RenderedGist, error) {
|
||||
Gist: gist,
|
||||
}
|
||||
|
||||
if gist.PreviewMimeType != "" {
|
||||
mt := &git.MimeType{ContentType: gist.PreviewMimeType}
|
||||
if mt.CanBeEmbedded() {
|
||||
rendered.PreviewMimeType = mt
|
||||
return rendered, nil
|
||||
}
|
||||
}
|
||||
|
||||
if gist.Preview == "" {
|
||||
return rendered, nil
|
||||
}
|
||||
|
||||
style := newStyle()
|
||||
lexer := newLexer(gist.PreviewFilename)
|
||||
if lexer.Config().Name == "markdown" {
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم