// Generate generates HTML output from Markdown input func Generate(inputFn, outputFn, templateFn string) error { // Get the template string tmpl, err := readTemplate(templateFn) if err != nil { return err } // Set the iglo template iglo.Tmpl = string(tmpl) // Open the input file input, err := openFile(inputFn) if err != nil { return err } // Make sure the input file is closed later. defer input.Close() // Create the output file output, err := os.Create(outputFn) if err != nil { return err } // Make sure the output file is closed later. defer output.Close() // Convert the API Blueprint Markdown to HTML return iglo.MarkdownToHTML(output, input) }
func serveRoot(w http.ResponseWriter, r *http.Request) { f, err := os.Open("./README.md") if err != nil { httpError(w, err) return } defer f.Close() err = iglo.MarkdownToHTML(w, f) if err != nil { httpError(w, err) return } }
func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { f, err := os.Open("API.md") if err != nil { httpError(w, err) return } err = iglo.MarkdownToHTML(w, f) if err != nil { httpError(w, err) return } }) log.Fatal(http.ListenAndServe(":8080", nil)) }
func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { f, err := os.Open("output/Example.md") if err != nil { httpError(w, err) return } defer f.Close() err = iglo.MarkdownToHTML(w, f) if err != nil { httpError(w, err) return } }) err := http.ListenAndServe(":8080", nil) if err != nil { log.Fatal(err) } }
func main() { flag.Parse() f, err := os.Open("../API.md") if err != nil { log.Fatal(err) } defer f.Close() w, err := os.Create(*fname) if err != nil { log.Fatal(err) } defer w.Close() err = iglo.MarkdownToHTML(w, f) if err != nil { log.Fatal(err) } }