コード例 #1
0
ファイル: parse.go プロジェクト: jmptrader/mdpresent
// parseSections parses Sections from lines for the section level indicated by
// number (a nil number indicates the top level).
func parseMarkdownSections(name string, lines *Lines, number []int, doc *Doc) (r []Section, err error) {
	// log.Println("starting parseMarkdownSections")
	body := lineBytes(lines)

	// set up the HTML renderer
	htmlFlags := 0
	htmlFlags |= blackfriday.HTML_USE_XHTML
	// htmlFlags |= blackfriday.HTML_USE_SMARTYPANTS
	renderer := PresentContentRenderer(htmlFlags)

	// set up the parser
	extensions := 0
	extensions |= blackfriday.EXTENSION_NO_INTRA_EMPHASIS
	// extensions |= blackfriday.EXTENSION_TABLES
	extensions |= blackfriday.EXTENSION_FENCED_CODE
	extensions |= blackfriday.EXTENSION_AUTOLINK
	extensions |= blackfriday.EXTENSION_STRIKETHROUGH
	extensions |= blackfriday.EXTENSION_UNICODE_LIST_ITEM
	extensions |= blackfriday.EXTENSION_NO_LIST_ITEM_BLOCK
	// extensions |= blackfriday.EXTENSION_SPACE_HEADERS  // to make sure that only "#\n\n" with empty titles also generate <h1></h1> works.
	blackfriday.Markdown(body, renderer, extensions)
	r = renderer.Sections()

	return
}
コード例 #2
0
ファイル: page.go プロジェクト: rolpereira/hugo
func markdownRender(content []byte) []byte {
	htmlFlags := 0
	htmlFlags |= blackfriday.HTML_USE_XHTML
	htmlFlags |= blackfriday.HTML_USE_SMARTYPANTS
	htmlFlags |= blackfriday.HTML_SMARTYPANTS_FRACTIONS
	htmlFlags |= blackfriday.HTML_SMARTYPANTS_LATEX_DASHES
	renderer := blackfriday.HtmlRenderer(htmlFlags, "", "")

	extensions := 0
	extensions |= blackfriday.EXTENSION_NO_INTRA_EMPHASIS
	extensions |= blackfriday.EXTENSION_TABLES
	extensions |= blackfriday.EXTENSION_FENCED_CODE
	extensions |= blackfriday.EXTENSION_AUTOLINK
	extensions |= blackfriday.EXTENSION_STRIKETHROUGH
	extensions |= blackfriday.EXTENSION_SPACE_HEADERS

	return blackfriday.Markdown(content, renderer, extensions)
}