summaryrefslogtreecommitdiff
path: root/gemtext
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-01-15 22:29:08 -0700
committertjpcc <tjp@ctrl-c.club>2023-01-15 22:36:02 -0700
commit30e21f8513d49661cb6e1583d301e34e898d48a9 (patch)
treed9e0f4c1761399386613a96fd484203adf1ca50a /gemtext
parent9579f021ff5e2d5cc314884ef1829f43d1ac8523 (diff)
fix gmi->md templates and regenerate the README
Diffstat (limited to 'gemtext')
-rw-r--r--gemtext/mdconv/convert.go24
-rw-r--r--gemtext/mdconv/convert_test.go4
2 files changed, 18 insertions, 10 deletions
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 }}
`))
diff --git a/gemtext/mdconv/convert_test.go b/gemtext/mdconv/convert_test.go
index 010ddce..ad4cda4 100644
--- a/gemtext/mdconv/convert_test.go
+++ b/gemtext/mdconv/convert_test.go
@@ -44,12 +44,14 @@ This is some non-blank regular text.
* list
=> [as if](gemini://google.com/)
+
=> [https://google.com/](https://google.com/)
> this is a quote
+
> -tjp
-`[1:] + "```\ndoc := gemtext.Parse(req.Body)\n```\n"
+` + "```\ndoc := gemtext.Parse(req.Body)\n```\n"
doc, err := gemtext.Parse(bytes.NewBufferString(gmiDoc))
require.Nil(t, err)