From 30e21f8513d49661cb6e1583d301e34e898d48a9 Mon Sep 17 00:00:00 2001 From: tjpcc Date: Sun, 15 Jan 2023 22:29:08 -0700 Subject: fix gmi->md templates and regenerate the README --- gemtext/mdconv/convert.go | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'gemtext/mdconv/convert.go') diff --git a/gemtext/mdconv/convert.go b/gemtext/mdconv/convert.go index 9371d92..57e106f 100644 --- a/gemtext/mdconv/convert.go +++ b/gemtext/mdconv/convert.go @@ -53,20 +53,26 @@ func Convert(wr io.Writer, doc gemtext.Document, overrides *template.Template) e var baseTmpl = template.Must(template.New("mdconv").Parse(` {{ define "header" }}{{ end }} -{{ define "textline" }}{{ . }}{{ end }} -{{ define "linkline" -}} - => [{{ if eq .Label "" }}{{ .URL }}{{ else }}{{ .Label }}{{ end }}]({{ .URL }}) +{{ define "textline" }}{{ if ne .String "\n" }} +{{ . }}{{ end }}{{ end }} +{{ define "linkline" }} +=> [{{ if eq .Label "" }}{{ .URL }}{{ else }}{{ .Label }}{{ end }}]({{ .URL }}) {{ end }} -{{ define "preformattedtextlines" }}` + "```\n" + `{{ range . }}{{ . }}{{ end }}` + "```\n" + `{{ end }} -{{ define "heading1line" }}# {{ .Body }} +{{ define "preformattedtextlines" }}` + "\n```\n" + `{{ range . }}{{ . }}{{ end }}` + "```\n" + `{{ end }} +{{ define "heading1line" }} +# {{ .Body }} {{ end }} -{{ define "heading2line" }}## {{ .Body }} +{{ define "heading2line" }} +## {{ .Body }} {{ end }} -{{ define "heading3line" }}### {{ .Body }} +{{ define "heading3line" }} +### {{ .Body }} {{ end }} -{{ define "listitemlines" }}{{ range . }}* {{ .Body }} +{{ define "listitemlines" }} +{{ range . }}* {{ .Body }} {{ end }}{{ end }} -{{ define "quoteline" }}> {{ .Body }} +{{ define "quoteline" }} +> {{ .Body }} {{ end }} {{ define "footer" }}{{ end }} `)) -- cgit v1.2.3