Ejemplo n.º 1
0
func main() {
	extensions, renderModes, renderer := parseFlags()
	gs := goskirt.Goskirt{extensions, renderModes}

	data, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	switch renderer {
	case goskirt.HTMLRenderer:
		gs.WriteHTML(os.Stdout, data)
	default:
		gs.WriteTOC(os.Stdout, data)
	}
}
Ejemplo n.º 2
0
func rootHandler(w http.ResponseWriter, request *http.Request) {
	files, _ := ioutil.ReadDir("./posts")
	data := ""
	for _, value := range files {
		// Ignore hidden files
		if value.Name()[0] == '.' {
			continue
		}
		data += value.Name() + "\n============="
		file_data, err := ioutil.ReadFile("./posts/" + value.Name())
		if err != nil {
			fmt.Printf("\nGot error!\n%s\n", err)
		}
		fmt.Printf("\nGot data: %s\n", string(file_data[:]))
		data += "\n" + string(file_data[:])
		fmt.Printf("\nOverall data: %s\n", data)
	}
	skirt := goskirt.Goskirt{
		goskirt.EXT_AUTOLINK | goskirt.EXT_STRIKETHROUGH,
		goskirt.HTML_SMARTYPANTS | goskirt.HTML_USE_XHTML,
	}

	skirt.WriteHTML(w, []byte(data))
}