From aa6bdb0649c2f2a63b4deae8c4984a660cd0400a Mon Sep 17 00:00:00 2001 From: tjpcc Date: Sat, 29 Apr 2023 13:45:38 -0600 Subject: include a CSS class in htmlconv output --- gemini/gemtext/htmlconv/convert.go | 27 +++++++++++++++++---------- gemini/gemtext/htmlconv/convert_test.go | 5 +++-- 2 files changed, 20 insertions(+), 12 deletions(-) (limited to 'gemini') 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" }}{{ end }} -{{ define "textline" }}{{ if ne .String "\n" }}

{{ . }}

{{ end }}{{ end }} +{{ define "header" -}} + +{{ end }} +{{ define "textline" -}} + {{ if ne .String "\n" -}} +

{{ . }}

+ {{- end }} +{{- end }} {{ define "linkline" -}} -

=> {{ if eq .Label "" -}} +

=> + {{- if eq .Label "" -}} {{ .URL }} {{- else -}} {{ .Label }} @@ -67,22 +74,22 @@ var baseTmpl = template.Must(template.New("htmlconv").Parse(`

{{- end }} {{ define "preformattedtextlines" -}} -
+	
 	{{- range . -}}
 		{{ . }}
 	{{- end -}}
 	
{{- end }} -{{ define "heading1line" }}

{{ .Body }}

{{ end }} -{{ define "heading2line" }}

{{ .Body }}

{{ end }} -{{ define "heading3line" }}

{{ .Body }}

{{ end }} +{{ define "heading1line" }}

{{ .Body }}

{{ end }} +{{ define "heading2line" }}

{{ .Body }}

{{ end }} +{{ define "heading3line" }}

{{ .Body }}

{{ end }} {{ define "listitemlines" -}} -