Update examples/html.go
This commit is contained in:
parent
7fb1b6c6a4
commit
12bdb2f997
@ -37,11 +37,10 @@ func textToHTML(text gemini.Text) string {
|
|||||||
list = false
|
list = false
|
||||||
fmt.Fprint(&b, "</ul>\n")
|
fmt.Fprint(&b, "</ul>\n")
|
||||||
}
|
}
|
||||||
switch l.(type) {
|
switch l := l.(type) {
|
||||||
case gemini.LineLink:
|
case gemini.LineLink:
|
||||||
link := l.(gemini.LineLink)
|
url := html.EscapeString(l.URL)
|
||||||
url := html.EscapeString(link.URL)
|
name := html.EscapeString(l.Name)
|
||||||
name := html.EscapeString(link.Name)
|
|
||||||
if name == "" {
|
if name == "" {
|
||||||
name = url
|
name = url
|
||||||
}
|
}
|
||||||
@ -54,29 +53,22 @@ func textToHTML(text gemini.Text) string {
|
|||||||
fmt.Fprint(&b, "</pre>\n")
|
fmt.Fprint(&b, "</pre>\n")
|
||||||
}
|
}
|
||||||
case gemini.LinePreformattedText:
|
case gemini.LinePreformattedText:
|
||||||
text := string(l.(gemini.LinePreformattedText))
|
fmt.Fprintf(&b, "%s\n", html.EscapeString(string(l)))
|
||||||
fmt.Fprintf(&b, "%s\n", html.EscapeString(text))
|
|
||||||
case gemini.LineHeading1:
|
case gemini.LineHeading1:
|
||||||
text := string(l.(gemini.LineHeading1))
|
fmt.Fprintf(&b, "<h1>%s</h1>\n", html.EscapeString(string(l)))
|
||||||
fmt.Fprintf(&b, "<h1>%s</h1>\n", html.EscapeString(text))
|
|
||||||
case gemini.LineHeading2:
|
case gemini.LineHeading2:
|
||||||
text := string(l.(gemini.LineHeading2))
|
fmt.Fprintf(&b, "<h2>%s</h2>\n", html.EscapeString(string(l)))
|
||||||
fmt.Fprintf(&b, "<h2>%s</h2>\n", html.EscapeString(text))
|
|
||||||
case gemini.LineHeading3:
|
case gemini.LineHeading3:
|
||||||
text := string(l.(gemini.LineHeading3))
|
fmt.Fprintf(&b, "<h3>%s</h3>\n", html.EscapeString(string(l)))
|
||||||
fmt.Fprintf(&b, "<h3>%s</h3>\n", html.EscapeString(text))
|
|
||||||
case gemini.LineListItem:
|
case gemini.LineListItem:
|
||||||
text := string(l.(gemini.LineListItem))
|
fmt.Fprintf(&b, "<li>%s</li>\n", html.EscapeString(string(l)))
|
||||||
fmt.Fprintf(&b, "<li>%s</li>\n", html.EscapeString(text))
|
|
||||||
case gemini.LineQuote:
|
case gemini.LineQuote:
|
||||||
text := string(l.(gemini.LineQuote))
|
fmt.Fprintf(&b, "<blockquote>%s</blockquote>\n", html.EscapeString(string(l)))
|
||||||
fmt.Fprintf(&b, "<blockquote>%s</blockquote>\n", html.EscapeString(text))
|
|
||||||
case gemini.LineText:
|
case gemini.LineText:
|
||||||
text := string(l.(gemini.LineText))
|
if l == "" {
|
||||||
if text == "" {
|
|
||||||
fmt.Fprint(&b, "<br>\n")
|
fmt.Fprint(&b, "<br>\n")
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(&b, "<p>%s</p>\n", html.EscapeString(text))
|
fmt.Fprintf(&b, "<p>%s</p>\n", html.EscapeString(string(l)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user