aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2020-11-01 00:58:34 -0400
committerAdnan Maolood <[email protected]>2020-11-01 00:58:34 -0400
commit12bdb2f99796de176b66cd766b863b8f82de6732 (patch)
tree1d39d40be5e979bfbf006652863006f8dfb9c4dd /examples
parentUpdate documentation (diff)
downloadgo-gemini-12bdb2f99796de176b66cd766b863b8f82de6732.tar.xz
go-gemini-12bdb2f99796de176b66cd766b863b8f82de6732.zip
Update examples/html.go
Diffstat (limited to 'examples')
-rw-r--r--examples/html.go30
1 files changed, 11 insertions, 19 deletions
diff --git a/examples/html.go b/examples/html.go
index fe59c87..bb99c56 100644
--- a/examples/html.go
+++ b/examples/html.go
@@ -37,11 +37,10 @@ func textToHTML(text gemini.Text) string {
list = false
fmt.Fprint(&b, "</ul>\n")
}
- switch l.(type) {
+ switch l := l.(type) {
case gemini.LineLink:
- link := l.(gemini.LineLink)
- url := html.EscapeString(link.URL)
- name := html.EscapeString(link.Name)
+ url := html.EscapeString(l.URL)
+ name := html.EscapeString(l.Name)
if name == "" {
name = url
}
@@ -54,29 +53,22 @@ func textToHTML(text gemini.Text) string {
fmt.Fprint(&b, "</pre>\n")
}
case gemini.LinePreformattedText:
- text := string(l.(gemini.LinePreformattedText))
- fmt.Fprintf(&b, "%s\n", html.EscapeString(text))
+ fmt.Fprintf(&b, "%s\n", html.EscapeString(string(l)))
case gemini.LineHeading1:
- text := string(l.(gemini.LineHeading1))
- fmt.Fprintf(&b, "<h1>%s</h1>\n", html.EscapeString(text))
+ fmt.Fprintf(&b, "<h1>%s</h1>\n", html.EscapeString(string(l)))
case gemini.LineHeading2:
- text := string(l.(gemini.LineHeading2))
- fmt.Fprintf(&b, "<h2>%s</h2>\n", html.EscapeString(text))
+ fmt.Fprintf(&b, "<h2>%s</h2>\n", html.EscapeString(string(l)))
case gemini.LineHeading3:
- text := string(l.(gemini.LineHeading3))
- fmt.Fprintf(&b, "<h3>%s</h3>\n", html.EscapeString(text))
+ fmt.Fprintf(&b, "<h3>%s</h3>\n", html.EscapeString(string(l)))
case gemini.LineListItem:
- text := string(l.(gemini.LineListItem))
- fmt.Fprintf(&b, "<li>%s</li>\n", html.EscapeString(text))
+ fmt.Fprintf(&b, "<li>%s</li>\n", html.EscapeString(string(l)))
case gemini.LineQuote:
- text := string(l.(gemini.LineQuote))
- fmt.Fprintf(&b, "<blockquote>%s</blockquote>\n", html.EscapeString(text))
+ fmt.Fprintf(&b, "<blockquote>%s</blockquote>\n", html.EscapeString(string(l)))
case gemini.LineText:
- text := string(l.(gemini.LineText))
- if text == "" {
+ if l == "" {
fmt.Fprint(&b, "<br>\n")
} else {
- fmt.Fprintf(&b, "<p>%s</p>\n", html.EscapeString(text))
+ fmt.Fprintf(&b, "<p>%s</p>\n", html.EscapeString(string(l)))
}
}
}