diff --git a/frontend/src/show.css b/frontend/src/show.css index 80c10bd..2e56e4b 100644 --- a/frontend/src/show.css +++ b/frontend/src/show.css @@ -18,3 +18,7 @@ html, body { line-height: 1.7777778; } } + +.gist tbody tr { + border: none !important; +} diff --git a/pkg/converters/embedded_converter.go b/pkg/converters/embedded_converter.go new file mode 100644 index 0000000..5eb8664 --- /dev/null +++ b/pkg/converters/embedded_converter.go @@ -0,0 +1,34 @@ +package converters + +import ( + "fmt" + "net/url" + "strings" + + "github.com/medium.rip/pkg/entities" + log "github.com/sirupsen/logrus" +) + +func ConvertEmbedded(media entities.MediaResource) string { + if media.IframeSrc == "" { + return customEmbed(media) + } else { + return fmt.Sprintf("", media.IframeSrc, media.IframeWidth, media.IframeHeight) + } +} + +func customEmbed(media entities.MediaResource) string { + if strings.HasPrefix(media.Href, "https://gist.github.com") { + return fmt.Sprintf("", media.Href) + } else { + url, err := url.Parse(media.Href) + var caption string + if err != nil { + log.Warnf("Error parsing url %s", media.Href) + caption = media.Href + } else { + caption = fmt.Sprintf("Embedded content at %s", url.Host) + } + return fmt.Sprintf("", media.Href, caption) + } +} \ No newline at end of file diff --git a/pkg/converters/paragraph_converter.go b/pkg/converters/paragraph_converter.go index abf31d1..37eb868 100644 --- a/pkg/converters/paragraph_converter.go +++ b/pkg/converters/paragraph_converter.go @@ -85,7 +85,9 @@ func ConvertParagraphs(paragraphs []entities.Paragraph) string { } else { ps.WriteString(fmt.Sprintf("