-
Notifications
You must be signed in to change notification settings - Fork 2
/
shimgo.go
25 lines (21 loc) · 1.04 KB
/
shimgo.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
package shimgo
import (
"fmt"
)
func Cleanup() { serverCache.cleanup() }
func Reset() { serverCache.reset() }
func SupportsRst() bool { return serverCache.hasSupport(RST) }
func SupportsAsciiDoc() bool { return serverCache.hasSupport(ASCIIDOC) }
func SupportsAsciidoctor() bool { return serverCache.hasSupport(ASCIIDOCTOR) }
func ConvertFromRst(content []byte) ([]byte, error) { return convertHelper(RST, content) }
func ConvertFromAsciiDoc(content []byte) ([]byte, error) { return convertHelper(ASCIIDOC, content) }
func ConvertFromAsciidoctor(content []byte) ([]byte, error) {
return convertHelper(ASCIIDOCTOR, content)
}
func convertHelper(f Format, content []byte) ([]byte, error) {
server, err := serverCache.getServer(f)
if err != nil {
return nil, fmt.Errorf("no suitable backend for '%s' was found: %s", f, err.Error())
}
return server.doConversion(f, content)
}