Esempio n. 1
0
// ParsePostContent parses the HeadMatter and HTML from a raw post.
func ParsePostContent(contents []byte, t string) template.HTML {
	var c []byte

	switch t {
	case "md", "mdown", "markdown":
		c = util.Markdown(contents)
	}

	return template.HTML(string(c))
}
Esempio n. 2
0
// Markdown renders a POST request into HTML.
func (ap ApiRender) Markdown(r render.Render, req *http.Request) {
	if err := req.ParseForm(); err != nil {
		r.Data(500, []byte(err.Error()))
		return
	}

	if _, ok := req.Form["raw"]; !ok {
		r.Data(500, []byte("No Data"))
		return
	}

	raw := req.Form["raw"][0]
	data := util.Markdown([]byte(raw))

	r.JSON(200, apiRenderResponse{Data: string(data)})
}