arnaucube
arnaucube/padArchiverPublic Self-hosted repository
padArchiver/webServer/files.go
webServer/files.goRaw
 1package main
 2
 3import (
 4	"io/ioutil"
 5
 6	"github.com/fatih/color"
 7	blackfriday "gopkg.in/russross/blackfriday.v2"
 8)
 9
10func readFile(path string) string {
11	dat, err := ioutil.ReadFile(path)
12	if err != nil {
13		color.Red(path)
14	}
15	check(err)
16	return string(dat)
17}
18
19func fileToHTML(path string) (string, error) {
20	mdcontent := readFile(path)
21	htmlcontent := string(blackfriday.Run([]byte(mdcontent)))
22	return htmlcontent, nil
23}