summaryrefslogtreecommitdiff
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
parent9579f021ff5e2d5cc314884ef1829f43d1ac8523 (diff)
fix gmi->md templates and regenerate the README
-rw-r--r--README.md9
-rw-r--r--gemtext/mdconv/convert.go24
-rw-r--r--gemtext/mdconv/convert_test.go4
3 files changed, 26 insertions, 11 deletions
diff --git a/README.md b/README.md
index 859f547..7eac9b8 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,4 @@
+
# Gus: The small web server toolkit
Gus is the toolkit for working with the small web in Go.
@@ -9,6 +10,7 @@ Think of it as a net/http for small web protocols. You still have to write your
Gus is determined to be structured as composable building blocks, and the gemini package mainly just defines the structure that holds the blocks together.
The package contains:
+
* a request type
* a response type
* a "Handler" abstraction
@@ -26,6 +28,7 @@ The gemtext package today provides a parser for gemtext documents. In the future
This is where useful building blocks themselves start to come in. Sub-packages of contrib include Handler and Middleware implementations which accomplish the things your servers actually need to do.
So far there are at least 3 packages:
+
* log contains a simple request-logging middleware
* fs has handlers that make file servers possible: serve files, build directory listings, etc
* cgi includes handlers which can execute CGI programs
@@ -36,6 +39,7 @@ So far there are at least 3 packages:
### Using gus in your project
To add it to your own go project:
+
```
$ go get tildegit.org/tjp/gus
```
@@ -43,6 +47,7 @@ $ go get tildegit.org/tjp/gus
### Straight to the code please
=> [The code is hosted here on tildegit.](https://tildegit.org/tjp/gus)
+
=> [The generated documentation is on the go package index.](https://pkg.go.dev/tildegit.org/tjp/gus)
## Contribute
@@ -50,13 +55,15 @@ $ go get tildegit.org/tjp/gus
There's lots still to do, and contributions are very welcome!
=> [submit an issue or pull request on the tildegit repository,](https://tildegit.org/tjp/gus)
+
=> [send me an email directly,](mailto:tjp@ctrl-c.club)
-or poke me on IRC: I'm @tjp on irc.tilde.chat, and you'll find me in #gemini
+or poke me on IRC: I'm @tjp on irc.tilde.chat, and you'll find me in #gemini
------------------------
> Step 2: draw the rest of the owl
+
```
;;;;;:::::::::::::::::::::::;;;;;;;,,,,,,,''''''''''',,,,,,,,,,,;;;;;;;;;;,,,,,,,,,,,,,,,,,,;;;;:::::::::::::;;
;;;;;;:::::::::::::::;;;;;;;;;;;,,,,,,,,'''''''''''''',,,,,,,,;;;;;;;;;;;;;;;;;;;,,,,,,,,,,,,,;;;;::::::::::::;
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)