From 6586db782ea6dcb5f2eb191a690ec7e7df51161f Mon Sep 17 00:00:00 2001 From: tjpcc Date: Tue, 17 Jan 2023 16:41:04 -0700 Subject: Updates * update README * move "gemtext" to within "gemini" --- gemini/gemtext/htmlconv/convert_test.go | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 gemini/gemtext/htmlconv/convert_test.go (limited to 'gemini/gemtext/htmlconv/convert_test.go') diff --git a/gemini/gemtext/htmlconv/convert_test.go b/gemini/gemtext/htmlconv/convert_test.go new file mode 100644 index 0000000..641ffb8 --- /dev/null +++ b/gemini/gemtext/htmlconv/convert_test.go @@ -0,0 +1,46 @@ +package htmlconv_test + +import ( + "bytes" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "tildegit.org/tjp/gus/gemini/gemtext" + "tildegit.org/tjp/gus/gemini/gemtext/htmlconv" +) + +var gmiDoc = ` +# top-level header line + +## subtitle + +This is some non-blank regular text. + +* an +* unordered +* list + +=> gemini://google.com/ as if +=> https://google.com/ + +> this is a quote +> -tjp + +`[1:] + "```pre-formatted code\ndoc := gemtext.Parse(req.Body)\n```ignored closing alt-text\n" + +func TestConvert(t *testing.T) { + htmlDoc := ` +

top-level header line

subtitle

This is some non-blank regular text. +

=> as if

=> https://google.com/

this is a quote
-tjp
doc := gemtext.Parse(req.Body)
+
`[1:] + + doc, err := gemtext.Parse(bytes.NewBufferString(gmiDoc)) + require.Nil(t, err) + + buf := &bytes.Buffer{} + require.Nil(t, htmlconv.Convert(buf, doc, nil)) + + assert.Equal(t, htmlDoc, buf.String()) +} -- cgit v1.2.3