Compare commits

...

5 Commits

7 changed files with 241 additions and 97 deletions

View File

@ -3,7 +3,7 @@ package main
import emoji "github.com/tmdvs/Go-Emoji-Utils" import emoji "github.com/tmdvs/Go-Emoji-Utils"
var charWidths = map[string]float64{ var charWidths = map[string]float64{
" ": 4.9, " ": 6,
"0": 14.333328247070312, "0": 14.333328247070312,
"1": 10.583328247070312, "1": 10.583328247070312,
"2": 13.433334350585938, "2": 13.433334350585938,
@ -74,8 +74,8 @@ var charWidths = map[string]float64{
"%": 18.416671752929688, "%": 18.416671752929688,
"^": 9.683334350585938, "^": 9.683334350585938,
"*": 9.683334350585938, "*": 9.683334350585938,
"(": 7.883331298828125, "(": 7,
")": 7.883331298828125, ")": 7,
"-": 10.300003051757812, "-": 10.300003051757812,
"_": 9.73333740234375, "_": 9.73333740234375,
"=": 14.333328247070312, "=": 14.333328247070312,
@ -89,10 +89,11 @@ var charWidths = map[string]float64{
"'": 5.26666259765625, "'": 5.26666259765625,
"\"": 9.5, "\"": 9.5,
",": 6.26666259765625, ",": 6.26666259765625,
".": 6.26666259765625, ".": 5,
"/": 7.76666259765625, "/": 7.76666259765625,
"?": 11.649993896484375, "?": 11.649993896484375,
"`": 11.833328247070312, "`": 11.833328247070312,
"”": 9,
} }
func getCharWidth(char string) float64 { func getCharWidth(char string) float64 {

1
go.mod
View File

@ -11,6 +11,7 @@ require (
github.com/garyburd/go-oauth v0.0.0-20180319155456-bca2e7f09a17 // indirect github.com/garyburd/go-oauth v0.0.0-20180319155456-bca2e7f09a17 // indirect
github.com/grokify/html-strip-tags-go v0.0.1 github.com/grokify/html-strip-tags-go v0.0.1
github.com/joho/godotenv v1.3.0 github.com/joho/godotenv v1.3.0
github.com/rivo/uniseg v0.2.0
github.com/tmdvs/Go-Emoji-Utils v1.1.0 github.com/tmdvs/Go-Emoji-Utils v1.1.0
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect
) )

2
go.sum
View File

@ -14,6 +14,8 @@ github.com/grokify/html-strip-tags-go v0.0.1 h1:0fThFwLbW7P/kOiTBs03FsJSV9RM2M/Q
github.com/grokify/html-strip-tags-go v0.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78= github.com/grokify/html-strip-tags-go v0.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/tmdvs/Go-Emoji-Utils v1.1.0 h1:gtPix7HZPrd49+MNDcuRLvv4xVNxCE5wgjqyuvmbyYg= github.com/tmdvs/Go-Emoji-Utils v1.1.0 h1:gtPix7HZPrd49+MNDcuRLvv4xVNxCE5wgjqyuvmbyYg=
github.com/tmdvs/Go-Emoji-Utils v1.1.0/go.mod h1:J82i2WeGn+Kz+T3s5v9+i/OJlvevIVfGZ6qXgqiNWBc= github.com/tmdvs/Go-Emoji-Utils v1.1.0/go.mod h1:J82i2WeGn+Kz+T3s5v9+i/OJlvevIVfGZ6qXgqiNWBc=
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 h1:003p0dJM77cxMSyCPFphvZf/Y5/NXf5fzg6ufd1/Oew= golang.org/x/net v0.0.0-20210119194325-5f4716e94777 h1:003p0dJM77cxMSyCPFphvZf/Y5/NXf5fzg6ufd1/Oew=

View File

@ -34,6 +34,19 @@
textarea { textarea {
height: 200px; height: 200px;
} }
#examples {
align-items: start;
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
#examples figure {
margin: 2px;
margin-bottom: 50px;
}
figcaption {
text-align: center;
}
</style> </style>
</head> </head>
<body> <body>
@ -77,6 +90,44 @@
</form> </form>
</div> </div>
<div>
<h3>Example Tweets</h3>
<div id="examples">
<figure>
<img src="/1285788484280545280" />
<figcaption>Text with Emoji</figcaption>
</figure>
<figure>
<img src="/1417089885647761409" />
<figcaption>Tweet with 1 image</figcaption>
</figure>
<figure>
<img src="/1400358030869372928" />
<figcaption>Tweet with 2 images</figcaption>
</figure>
<figure>
<img src="/1401103668267556868" />
<figcaption>Tweet with 3 images</figcaption>
</figure>
<figure>
<img src="/1396802436052836360" />
<figcaption>Tweet with 4 images</figcaption>
</figure>
<figure>
<img src="/1370521139684970496" />
<figcaption>Tweet with quoted Tweet</figcaption>
</figure>
<figure>
<img src="/1281166762394791937" />
<figcaption>Tweet with link</figcaption>
</figure>
<figure>
<img src="/1396979104944201741" />
<figcaption>Reply Tweet</figcaption>
</figure>
</div>
</div>
<div> <div>
Source code available on <a href="https://github.com/AverageMarcus/tweetsvg" target="_blank" rel="noopener noreferrer">GitHub</a>, <a href="https://gitlab.com/AverageMarcus/tweetsvg" target="_blank" rel="noopener noreferrer">GitLab</a>, <a href="https://bitbucket.org/AverageMarcus/tweetsvg/" target="_blank" rel="noopener noreferrer">Bitbucket</a> & <a href="https://git.cluster.fun/AverageMarcus/tweetsvg" target="_blank" rel="noopener noreferrer">my own Gitea server</a>. Source code available on <a href="https://github.com/AverageMarcus/tweetsvg" target="_blank" rel="noopener noreferrer">GitHub</a>, <a href="https://gitlab.com/AverageMarcus/tweetsvg" target="_blank" rel="noopener noreferrer">GitLab</a>, <a href="https://bitbucket.org/AverageMarcus/tweetsvg/" target="_blank" rel="noopener noreferrer">Bitbucket</a> & <a href="https://git.cluster.fun/AverageMarcus/tweetsvg" target="_blank" rel="noopener noreferrer">my own Gitea server</a>.
</div> </div>
@ -106,9 +157,11 @@
} }
document.getElementById('tweetURL').addEventListener('change', function(e) { document.getElementById('tweetURL').addEventListener('change', function(e) {
let parts = e.target.value.split("/"); if (e.target.value.trim() != "") {
let tweetID = parts[parts.length-1]; let parts = e.target.value.split("/");
loadTweet(tweetID); let tweetID = parts[parts.length-1];
loadTweet(tweetID);
}
}); });
document.getElementById('imageTagExample').addEventListener('click', function(e) { document.getElementById('imageTagExample').addEventListener('click', function(e) {

211
main.go
View File

@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"html/template" "html/template"
"log" "log"
"math"
"net/http" "net/http"
"os" "os"
"regexp" "regexp"
@ -17,9 +18,11 @@ import (
"github.com/ChimeraCoder/anaconda" "github.com/ChimeraCoder/anaconda"
strip "github.com/grokify/html-strip-tags-go" strip "github.com/grokify/html-strip-tags-go"
"github.com/joho/godotenv" "github.com/joho/godotenv"
"github.com/rivo/uniseg"
emoji "github.com/tmdvs/Go-Emoji-Utils"
) )
//go:embed index.html tweet.svg.tmpl //go:embed index.html tweet.svg.tmpl suspendedTweet.svg
var content embed.FS var content embed.FS
@ -77,24 +80,48 @@ func getTweet(w http.ResponseWriter, r *http.Request) {
} }
tweet, err := api.GetTweet(i, nil) tweet, err := api.GetTweet(i, nil)
if err != nil { if err != nil {
switch err := err.(type) {
case *anaconda.ApiError:
switch err.Decoded.Errors[0].Code {
case 63:
fmt.Printf("Generating suspended tweet image for %s\n", id)
suspendedTweet(w)
return
}
}
fmt.Println(err)
w.WriteHeader(404) w.WriteHeader(404)
return return
} }
re := regexp.MustCompile(`[\x{1F300}-\x{1F6FF}]`) processTweet(&tweet)
emojis := re.FindAllString(tweet.FullText, -1)
emojiCount := 0 w.Header().Set("Content-type", "image/svg+xml")
for _, emoji := range emojis { _, err = w.Write(renderTemplate(tweet, false))
emojiCount += len([]byte(emoji)) - 1 if err != nil {
fmt.Println(err)
w.WriteHeader(500)
return
} }
tweet.FullText = tweet.FullText[tweet.DisplayTextRange[0] : tweet.DisplayTextRange[1]+emojiCount] }
func processTweet(tweet *anaconda.Tweet) {
gr := uniseg.NewGraphemes(tweet.FullText)
count := 0
displayText := ""
for gr.Next() {
if count >= tweet.DisplayTextRange[0] && count < tweet.DisplayTextRange[1] {
displayText += gr.Str()
}
count += 1
}
tweet.FullText = displayText
for _, user := range tweet.Entities.User_mentions { for _, user := range tweet.Entities.User_mentions {
tweet.FullText = strings.ReplaceAll(tweet.FullText, "@"+user.Screen_name, fmt.Sprintf("<a rel=\"noopener\" target=\"_blank\" href=\"https://twitter.com/%s/\">@%s</a>", user.Screen_name, user.Screen_name)) tweet.FullText = strings.ReplaceAll(tweet.FullText, "@"+user.Screen_name, fmt.Sprintf("<a rel=\"noopener\" target=\"_blank\" href=\"https://twitter.com/%s/\">@%s</a>", user.Screen_name, user.Screen_name))
} }
for _, url := range tweet.Entities.Urls { for _, url := range tweet.Entities.Urls {
tweet.FullText = strings.ReplaceAll(tweet.FullText, url.Url, fmt.Sprintf("<a rel=\"noopener\" target=\"_blank\" href=\"https://twitter.com/%s/\">%s</a>", url.Expanded_url, url.Display_url)) tweet.FullText = strings.ReplaceAll(tweet.FullText, url.Url, fmt.Sprintf("<a rel=\"noopener\" target=\"_blank\" href=\"%s\">%s</a>", url.Expanded_url, url.Display_url))
} }
for _, hashtag := range tweet.Entities.Hashtags { for _, hashtag := range tweet.Entities.Hashtags {
tweet.FullText = strings.ReplaceAll(tweet.FullText, "#"+hashtag.Text, fmt.Sprintf("<a rel=\"noopener\" target=\"_blank\" href=\"https://twitter.com/hashtag/%s\">#%s</a>", hashtag.Text, hashtag.Text)) tweet.FullText = strings.ReplaceAll(tweet.FullText, "#"+hashtag.Text, fmt.Sprintf("<a rel=\"noopener\" target=\"_blank\" href=\"https://twitter.com/hashtag/%s\">#%s</a>", hashtag.Text, hashtag.Text))
@ -102,6 +129,13 @@ func getTweet(w http.ResponseWriter, r *http.Request) {
tweet.FullText = strings.ReplaceAll(tweet.FullText, "\n", "<br />") tweet.FullText = strings.ReplaceAll(tweet.FullText, "\n", "<br />")
if tweet.QuotedStatus != nil {
processTweet(tweet.QuotedStatus)
}
}
func renderTemplate(tweet anaconda.Tweet, isQuoted bool) []byte {
templateFuncs := template.FuncMap{ templateFuncs := template.FuncMap{
"base64": func(url string) string { "base64": func(url string) string {
res, err := http.Get(url) res, err := http.Get(url)
@ -124,58 +158,22 @@ func getTweet(w http.ResponseWriter, r *http.Request) {
return template.HTML(in) return template.HTML(in)
}, },
"calculateHeight": func(tweet anaconda.Tweet) string { "calculateHeight": func(tweet anaconda.Tweet) string {
height := 64.0 /* Avatar */ + 20 /* footer */ + 46 /* test margin */ + 32 /* margin */ return fmt.Sprintf("%dpx", calculateHeight(tweet))
},
lineWidth := 0.0 "renderTweet": func(tweet anaconda.Tweet) template.HTML {
tweetText := strings.ReplaceAll(tweet.FullText, "<br /><br />", " \n ") return template.HTML(string(renderTemplate(tweet, true)))
tweetText = strip.StripTags(tweetText) },
words := strings.Split(tweetText, " ") "tweetWidth": func() string {
for _, word := range words { if isQuoted {
if strings.Contains(word, "\n") { return "450px"
height += 28
lineWidth = 0
continue
}
chars := strings.Split(word, "")
wordWidth := 0.0
for _, char := range chars {
wordWidth += getCharWidth(char)
}
if lineWidth+wordWidth > 443 {
height += 28
lineWidth = wordWidth
} else {
lineWidth += wordWidth
}
} }
if lineWidth > 0 { return "499px"
height += 28 },
"className": func() string {
if isQuoted {
return "subtweet"
} }
return "tweetsvg"
if tweet.InReplyToScreenName != "" {
height += 34
}
height += float64(strings.Count(tweet.FullText, "<br /><br />") * 28)
if len(tweet.ExtendedEntities.Media) >= 1 {
ratio := float64(tweet.ExtendedEntities.Media[0].Sizes.Small.W) / 464
if len(tweet.ExtendedEntities.Media) == 2 {
height += ((float64(tweet.ExtendedEntities.Media[0].Sizes.Small.H) / ratio) + 5) / 2
} else {
height += (float64(tweet.ExtendedEntities.Media[0].Sizes.Small.H) / ratio) + 5
}
}
if len(tweet.ExtendedEntities.Media) > 1 {
for i := range tweet.ExtendedEntities.Media {
tweet.ExtendedEntities.Media[i].Sizes.Small.W = 225
}
}
return fmt.Sprintf("%dpx", int64(height))
}, },
} }
@ -184,11 +182,94 @@ func getTweet(w http.ResponseWriter, r *http.Request) {
Funcs(templateFuncs). Funcs(templateFuncs).
ParseFS(content, "tweet.svg.tmpl")) ParseFS(content, "tweet.svg.tmpl"))
w.Header().Set("Content-type", "image/svg+xml") var buf bytes.Buffer
err = t.Execute(w, tweet) t.Execute(&buf, tweet)
if err != nil {
fmt.Println(err) return buf.Bytes()
w.WriteHeader(500) }
return
} func calculateHeight(tweet anaconda.Tweet) int64 {
height := 64.0 /* Avatar */ + 20 /* footer */ + 46 /* text margin */ + 22 /* margin */
lineWidth := 0.0
lineHeight := 28.0
tweetText := strings.ReplaceAll(tweet.FullText, "<br />", " \n")
tweetText = strip.StripTags(tweetText)
words := regexp.MustCompile(`[ |-]`).Split(tweetText, -1)
for _, word := range words {
if len(emoji.FindAll(word)) > 0 {
lineHeight = 32.0
}
if strings.Contains(word, "\n") {
height += lineHeight
lineHeight = 28.0
lineWidth = 0
continue
}
chars := strings.Split(word, "")
wordWidth := 0.0
for _, char := range chars {
wordWidth += getCharWidth(char)
}
if wordWidth > 435 {
height += (lineHeight * (math.Ceil(wordWidth/435) + 1))
lineHeight = 28.0
lineWidth = 0
} else if lineWidth+getCharWidth(" ")+wordWidth > 435 {
height += lineHeight
lineHeight = 28.0
lineWidth = wordWidth
} else {
lineWidth += wordWidth
}
}
if lineWidth > 0 {
height += lineHeight
}
if tweet.InReplyToScreenName != "" {
height += 42
}
for i, img := range tweet.ExtendedEntities.Media {
ratio := float64(img.Sizes.Small.W) / 468
tweet.ExtendedEntities.Media[i].Sizes.Small.W = 468
tweet.ExtendedEntities.Media[i].Sizes.Small.H = int((float64(img.Sizes.Small.H) / ratio) + 5.0)
}
if len(tweet.ExtendedEntities.Media) > 1 {
for i, img := range tweet.ExtendedEntities.Media {
tweet.ExtendedEntities.Media[i].Sizes.Small.W = (img.Sizes.Small.W / 2) - 20
tweet.ExtendedEntities.Media[i].Sizes.Small.H = (img.Sizes.Small.H / 2) - 20
}
}
switch len(tweet.ExtendedEntities.Media) {
case 1:
height += float64(tweet.ExtendedEntities.Media[0].Sizes.Small.H)
case 2:
height += math.Max(float64(tweet.ExtendedEntities.Media[0].Sizes.Small.H), float64(tweet.ExtendedEntities.Media[1].Sizes.Small.H)) + 5
case 3:
height += math.Max(float64(tweet.ExtendedEntities.Media[0].Sizes.Small.H), float64(tweet.ExtendedEntities.Media[1].Sizes.Small.H)) + 5
height += float64(tweet.ExtendedEntities.Media[2].Sizes.Small.H) + 35
case 4:
height += math.Max(float64(tweet.ExtendedEntities.Media[0].Sizes.Small.H), float64(tweet.ExtendedEntities.Media[1].Sizes.Small.H)) + 10
height += math.Max(float64(tweet.ExtendedEntities.Media[2].Sizes.Small.H), float64(tweet.ExtendedEntities.Media[3].Sizes.Small.H)) + 10
height += 7
}
if tweet.QuotedStatus != nil {
height += float64(calculateHeight(*tweet.QuotedStatus)) + 9
}
return int64(height)
}
func suspendedTweet(w http.ResponseWriter) {
w.Header().Set("Content-type", "image/svg+xml")
tweet, _ := content.ReadFile("suspendedTweet.svg")
w.Write(tweet)
} }

1
suspendedTweet.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="566" height="46" viewBox="0 0 566 46"><rect width="100%" height="100%" fill="rgba(0, 0, 0, 0)"/><path vector-effect="non-scaling-stroke" stroke="#f7f9f9" stroke-width="20" stroke-linejoin="round" fill="#f7f9f9" d="M-50-50V50H50V-50z" transform="matrix(5.46 0 0 .26 283 23.17)"/><g><text font-family="'Open Sans', sans-serif" font-size="15" style="white-space:pre" stroke-width="0" fill="#536471" transform="translate(221.5 21.91)"><tspan x="-202.5" y="5.34" style="white-space:pre" font-size="17">This Tweet is from a suspended account.</tspan></text></g></svg>

After

Width:  |  Height:  |  Size: 652 B

View File

@ -1,44 +1,49 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="499px" height="{{ calculateHeight . }}"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="{{ tweetWidth }}" height="{{ calculateHeight . }}">
<foreignObject x="0" y="0" width="499px" height="100%" fill="#eade52"> <foreignObject x="0" y="0" width="{{ tweetWidth }}" height="100%" fill="#eade52">
<style> <style>
.tweetsvg{clear:none;font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;} .{{ className }}{clear:none;font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;}
.tweetsvg.text{font-size: 23px;} .{{ className }}.text{font-size: 23px;}
a.tweetsvg{color: rgb(27, 149, 224); text-decoration:none;} a.{{ className }}{color: rgb(27, 149, 224); text-decoration:none;}
.tweetsvg a { color: #1da1f2; } .{{ className }} a { color: #1da1f2; }
blockquote.tweetsvg{margin:1px; background-color:#fefefe; border-radius:2%; border-style:solid; border-width:.1em; border-color:#ddd; padding:1em; font-family:sans; width:29rem} blockquote.{{ className }}{margin:1px; background-color:#fefefe; border-radius:2%; border-style:solid; border-width:.1em; border-color:#ddd; padding:1em; font-family:sans; width:29rem}
.avatar-tweetsvg{float:left; width:4rem; height:4rem; border-radius:50%;margin-right:.5rem;;margin-bottom:.5rem;border-style: solid; border-width:.1em; border-color:#ddd;} blockquote.subtweet{width:26rem; padding:0.8em;}
h1.tweetsvg{margin:0;font-size:15px;text-decoration:none;color:#000;} .avatar-{{ className }}{float:left; width:4rem; height:4rem; border-radius:50%;margin-right:.5rem;;margin-bottom:.5rem;border-style: solid; border-width:.1em; border-color:#ddd;}
h2.tweetsvg{margin:0;font-size:15px;font-weight:normal;text-decoration:none;color:rgb(101, 119, 134);} h1.{{ className }}{margin:0;font-size:15px;text-decoration:none;color:#000;}
p.tweetsvg{font-size:1rem; clear:both;} h2.{{ className }}{margin:0;font-size:15px;font-weight:normal;text-decoration:none;color:rgb(101, 119, 134);}
hr.tweetsvg{color:#ddd;} p.{{ className }}{font-size:1rem; clear:both;}
.media-tweetsvg{border-radius:2%; max-width:100%;border-radius: 2%; border-style: solid; border-width: .1em; border-color: #ddd;} hr.{{ className }}{color:#ddd;}
time.tweetsvg{font-size:15px;margin:0;margin-left: 2px;padding-bottom:1rem;color:rgb(101, 119, 134);text-decoration:none;} .media-{{ className }}{border-radius:2%; max-width:100%;border-radius: 2%; border-style: solid; border-width: .1em; border-color: #ddd;}
.tweetsvg.reply{font-size:15px;color:rgb(110, 118, 125);} time.{{ className }}{font-size:15px;margin:0;margin-left: 2px;padding-bottom:1rem;color:rgb(101, 119, 134);text-decoration:none;}
.tweetsvg.footer{display:block;} .{{ className }}.reply{font-size:15px;color:rgb(110, 118, 125);}
.{{ className }}.footer{display:block;}
</style> </style>
<blockquote class="tweetsvg" xmlns="http://www.w3.org/1999/xhtml"> <blockquote class="{{ className }}" xmlns="http://www.w3.org/1999/xhtml">
<a rel="noopener" target="_blank" class="tweetsvg" href="https://twitter.com/{{ .User.ScreenName }}/"><img class="avatar-tweetsvg" alt="" src="data:image/jpeg;base64,{{ base64 .User.ProfileImageUrlHttps }}" /></a> <a rel="noopener" target="_blank" class="{{ className }}" href="https://twitter.com/{{ .User.ScreenName }}/"><img class="avatar-{{ className }}" alt="" src="data:image/jpeg;base64,{{ base64 .User.ProfileImageUrlHttps }}" /></a>
<a rel="noopener" target="_blank" class="tweetsvg" href="https://twitter.com/{{ .User.ScreenName }}/"><h1 class="tweetsvg">{{ .User.Name }}</h1></a> <a rel="noopener" target="_blank" class="{{ className }}" href="https://twitter.com/{{ .User.ScreenName }}/"><h1 class="{{ className }}">{{ .User.Name }}</h1></a>
<a rel="noopener" target="_blank" class="tweetsvg" href="https://twitter.com/{{ .User.ScreenName }}/"><h2 class="tweetsvg">@{{ .User.ScreenName }}</h2></a> <a rel="noopener" target="_blank" class="{{ className }}" href="https://twitter.com/{{ .User.ScreenName }}/"><h2 class="{{ className }}">@{{ .User.ScreenName }}</h2></a>
{{ if .InReplyToScreenName }} {{ if .InReplyToScreenName }}
<p class="tweetsvg reply">Replying to <a rel="noopener" target="_blank" href="https://twitter.com/{{ .InReplyToScreenName }}/">@{{ .InReplyToScreenName }}</a></p> <p class="{{ className }} reply">Replying to <a rel="noopener" target="_blank" href="https://twitter.com/{{ .InReplyToScreenName }}/">@{{ .InReplyToScreenName }}</a></p>
{{ end }} {{ end }}
<p class="tweetsvg text">{{ html .FullText }}</p> <p class="{{ className }} text">{{ html .FullText }}</p>
{{ if .QuotedStatus }}
{{ renderTweet .QuotedStatus }}
{{ end }}
{{ if .ExtendedEntities }} {{ if .ExtendedEntities }}
{{ range .ExtendedEntities.Media }} {{ range .ExtendedEntities.Media }}
<a rel="noopener" target="_blank" href="{{ .Media_url_https }}"><img class="media-tweetsvg" width="{{ .Sizes.Small.W }}" src="data:image/jpeg;base64,{{ base64 .Media_url }}" alt="{{ .ExtAltText }}"/></a> <a rel="noopener" target="_blank" href="{{ .Media_url_https }}"><img class="media-{{ className }}" width="{{ .Sizes.Small.W }}" src="data:image/jpeg;base64,{{ base64 .Media_url }}" alt="{{ .ExtAltText }}"/></a>
{{ end }} {{ end }}
{{ end }} {{ end }}
<a rel="noopener" target="_blank" class="tweetsvg footer" href="https://twitter.com/{{ .User.ScreenName }}/status/{{ .Id }}"> <a rel="noopener" target="_blank" class="{{ className }} footer" href="https://twitter.com/{{ .User.ScreenName }}/status/{{ .Id }}">
<time class="tweetsvg" datetime="{{ isoDate .CreatedAt }}">{{ humanDate .CreatedAt }}</time> <time class="{{ className }}" datetime="{{ isoDate .CreatedAt }}">{{ humanDate .CreatedAt }}</time>
</a> </a>
</blockquote> </blockquote>
</foreignObject> </foreignObject>

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB