[Golang] reStructuredText Package


Packages of reStructuredText (to HTML) implementation in Golang. After some googling, I found [3] and [4], it seems only [3] provides rst-to-HTML conversion, so I tried [3] only.

Install the package:

$ go get -u github.com/hhatto/gorst

Test Code

Test program:

hhatto.go | repository | view raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
package main

import (
	"bufio"
	"bytes"
	"github.com/hhatto/gorst"
	"io/ioutil"
	"os"
)

func main() {
	p := rst.NewParser(nil)

	w := bufio.NewWriter(os.Stdout)
	d, _ := ioutil.ReadFile("test.rst")
	p.ReStructuredText(bytes.NewReader(d), rst.ToHTML(w))
	w.Flush()
}

Test rst file:

test.rst | repository | view raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
`my blog <https://siongui.github.io>`_

----

*italic*

**bold**

``hello``

Heading
=======