Add pre word wrap css
alex wennerberg alex@alexwennerberg.com
Tue, 24 Nov 2020 11:17:08 -0800
3 files changed,
13 insertions(+),
8 deletions(-)
M
gmi2html.go
→
gmi2html.go
@@ -30,7 +30,7 @@ name := html.EscapeString(link.Name)
if name == "" { name = url } - fmt.Fprintf(&b, "<p><a href='%s'>%s</a></p>\n", url, name) + fmt.Fprintf(&b, "<a href='%s'>%s</a>\n", url, name) case gemini.LinePreformattingToggle: pre = !pre if pre {@@ -49,25 +49,25 @@ text := string(l.(gemini.LinePreformattedText))
fmt.Fprintf(&b, "%s\n", html.EscapeString(text)) case gemini.LineHeading1: text := string(l.(gemini.LineHeading1)) - fmt.Fprintf(&b, "<h1>%s</h1>\n", html.EscapeString(text)) + fmt.Fprintf(&b, "<h1>%s</h1>", html.EscapeString(text)) case gemini.LineHeading2: text := string(l.(gemini.LineHeading2)) - fmt.Fprintf(&b, "<h2>%s</h2>\n", html.EscapeString(text)) + fmt.Fprintf(&b, "<h2>%s</h2>", html.EscapeString(text)) case gemini.LineHeading3: text := string(l.(gemini.LineHeading3)) - fmt.Fprintf(&b, "<h3>%s</h3>\n", html.EscapeString(text)) + fmt.Fprintf(&b, "<h3>%s</h3>", html.EscapeString(text)) case gemini.LineListItem: text := string(l.(gemini.LineListItem)) - fmt.Fprintf(&b, "<li>%s</li>\n", html.EscapeString(text)) + fmt.Fprintf(&b, "<li>%s</li>", html.EscapeString(text)) case gemini.LineQuote: text := string(l.(gemini.LineQuote)) - fmt.Fprintf(&b, "<blockquote>%s</blockquote>\n", html.EscapeString(text)) + fmt.Fprintf(&b, "<blockquote>%s</blockquote>", html.EscapeString(text)) case gemini.LineText: text := string(l.(gemini.LineText)) if text == "" { - fmt.Fprint(&b, "<br>\n") + fmt.Fprint(&b, "\n") } else { - fmt.Fprintf(&b, "<p>%s</p>\n", html.EscapeString(text)) + fmt.Fprintf(&b, "%s\n", html.EscapeString(text)) } } }
M
templates/static/style.css
→
templates/static/style.css
@@ -13,6 +13,9 @@ margin-top:0;
margin-bottom:.2em; } +.gemini { +white-space: pre-wrap; +} body { }
M
templates/user_page.html
→
templates/user_page.html
@@ -9,7 +9,9 @@ <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>{{.Favicon}}</text></svg>">
</head> <body> <main> + <div class="gemini"> {{.SiteBody}} + </div> </main> </body> </html>