summaryrefslogtreecommitdiff
path: root/gemini/gemtext/htmlconv/convert.go
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-04-29 13:45:38 -0600
committertjpcc <tjp@ctrl-c.club>2023-04-29 13:45:38 -0600
commitaa6bdb0649c2f2a63b4deae8c4984a660cd0400a (patch)
treebe5d7b3cf21115199b9127050a8ca459a287a9b5 /gemini/gemtext/htmlconv/convert.go
parent46ad450327111b9d28b592658d75ef57da498298 (diff)
include a CSS class in htmlconv output
Diffstat (limited to 'gemini/gemtext/htmlconv/convert.go')
-rw-r--r--gemini/gemtext/htmlconv/convert.go27
1 files changed, 17 insertions, 10 deletions
diff --git a/gemini/gemtext/htmlconv/convert.go b/gemini/gemtext/htmlconv/convert.go
index 2af4eea..407eb43 100644
--- a/gemini/gemtext/htmlconv/convert.go
+++ b/gemini/gemtext/htmlconv/convert.go
@@ -56,10 +56,17 @@ func Convert(wr io.Writer, doc gemtext.Document, overrides *template.Template) e
}
var baseTmpl = template.Must(template.New("htmlconv").Parse(`
-{{ define "header" }}<html><body>{{ end }}
-{{ define "textline" }}{{ if ne .String "\n" }}<p>{{ . }}</p>{{ end }}{{ end }}
+{{ define "header" -}}
+<!DOCTYPE html>
+<html><body class="gemtext">{{ end }}
+{{ define "textline" -}}
+ {{ if ne .String "\n" -}}
+<p class="gemtext">{{ . }}</p>
+ {{- end }}
+{{- end }}
{{ define "linkline" -}}
- <p>=> <a href="{{ .ValidatedURL }}">{{ if eq .Label "" -}}
+ <p class="gemtext">=> <a class="gemtext" href="{{ .ValidatedURL }}">
+ {{- if eq .Label "" -}}
{{ .URL }}
{{- else -}}
{{ .Label }}
@@ -67,22 +74,22 @@ var baseTmpl = template.Must(template.New("htmlconv").Parse(`
</a></p>
{{- end }}
{{ define "preformattedtextlines" -}}
- <pre>
+ <pre class="gemtext">
{{- range . -}}
{{ . }}
{{- end -}}
</pre>
{{- end }}
-{{ define "heading1line" }}<h1>{{ .Body }}</h1>{{ end }}
-{{ define "heading2line" }}<h2>{{ .Body }}</h2>{{ end }}
-{{ define "heading3line" }}<h3>{{ .Body }}</h3>{{ end }}
+{{ define "heading1line" }}<h1 class="gemtext">{{ .Body }}</h1>{{ end }}
+{{ define "heading2line" }}<h2 class="gemtext">{{ .Body }}</h2>{{ end }}
+{{ define "heading3line" }}<h3 class="gemtext">{{ .Body }}</h3>{{ end }}
{{ define "listitemlines" -}}
- <ul>
+ <ul class="gemtext">
{{- range . -}}
- <li>{{ .Body }}</li>
+ <li class="gemtext">{{ .Body }}</li>
{{- end -}}
</ul>
{{- end }}
-{{ define "quoteline" }}<blockquote>{{ .Body }}</blockquote>{{ end }}
+{{ define "quoteline" }}<blockquote class="gemtext">{{ .Body }}</blockquote>{{ end }}
{{ define "footer" }}</body></html>{{ end }}
`))