/
main.go
58 lines (43 loc) · 1.15 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// gmnhg converts Hugo posts to gemini content.
//
// TODO: it is yet to actually do that.
package main
import (
"fmt"
"git.tdem.in/tdemin/gmnhg/internal/gemini"
"github.com/davecgh/go-spew/spew"
"github.com/gomarkdown/markdown"
"github.com/gomarkdown/markdown/parser"
)
var text = `
# Some document
This is some markdown [text](https://tdem.in). This is some more text.
![This is some image](https://tdem.in/favicon.ico)
[This is some full-blown link.](https://tdem.in/nyaa)
This is some more plain text. More of it!
+ Unordered list item
+ Another list item
* Indented list item.
* Another one.
+ Third.
1. Ordered list item.
2. Another one.
* and another inset list.
* text.
3. Yay.
` + "```" + `
some preformatted text
another line of preformatted text
more lines of preformatted text
` + "```" + `
## Subheading 2
More text!
> Some weird blockquote. More text.
> More quote text.
`
func main() {
ast := markdown.Parse([]byte(text), parser.NewWithExtensions(parser.CommonExtensions))
spew.Dump(ast)
geminiContent := markdown.Render(ast, gemini.NewRenderer())
fmt.Printf("---\noriginal:\n---\n%s---\ngemini:\n---\n%s", text, geminiContent)
}