當前位置: 首頁>>代碼示例>>Golang>>正文


Golang mmark.Parse函數代碼示例

本文整理匯總了Golang中github.com/miekg/mmark.Parse函數的典型用法代碼示例。如果您正苦於以下問題:Golang Parse函數的具體用法?Golang Parse怎麽用?Golang Parse使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Parse函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: CheckMarkdownLinks

func CheckMarkdownLinks(reader *linereader.LineReader, file string) (err error) {
	// mmark.HtmlRendererWithParameters(htmlFlags, "", "", renderParameters)
	htmlFlags := 0
	htmlFlags |= mmark.HTML_FOOTNOTE_RETURN_LINKS

	renderParameters := mmark.HtmlRendererParameters{
	//		FootnoteAnchorPrefix:       viper.GetString("FootnoteAnchorPrefix"),
	//		FootnoteReturnLinkContents: viper.GetString("FootnoteReturnLinkContents"),
	}

	renderer := &TestRenderer{
		LinkFrom: file,
		Renderer: mmark.HtmlRendererWithParameters(htmlFlags, "", "", renderParameters),
	}

	extensions := 0 |
		//mmark.EXTENSION_NO_INTRA_EMPHASIS |
		mmark.EXTENSION_TABLES | mmark.EXTENSION_FENCED_CODE |
		mmark.EXTENSION_AUTOLINK |
		//mmark.EXTENSION_STRIKETHROUGH |
		mmark.EXTENSION_SPACE_HEADERS | mmark.EXTENSION_FOOTNOTES |
		mmark.EXTENSION_HEADER_IDS | mmark.EXTENSION_AUTO_HEADER_IDS //|
	//	mmark.EXTENSION_DEFINITION_LISTS

	//var output []byte
	buf := make([]byte, 1024*1024)
	length, err := reader.Read(buf)
	if length == 0 || err != nil {
		return err
	}
	data.VerboseLog("RUNNING Markdown on %s length(%d) - not counting frontmater\n", file, length)
	_ = mmark.Parse(buf, renderer, extensions)
	data.VerboseLog("FINISHED Markdown on %s\n", file)

	return nil
}
開發者ID:moxiegirl,項目名稱:markdownlint,代碼行數:36,代碼來源:links.go

示例2: main

func main() {
	// parse command-line options
	var page, xml, xml2 bool
	var css, head string

	flag.BoolVar(&page, "page", false, "generate a standalone HTML page")
	flag.BoolVar(&xml, "xml", false, "generate XML2RFC v3 output")
	flag.BoolVar(&xml2, "xml2", false, "generate XML2RFC v2 output")
	flag.StringVar(&css, "css", "", "link to a CSS stylesheet (implies -page)")
	flag.StringVar(&head, "head", "", "link to HTML to be included in head (implies -page)")

	flag.StringVar(&mmark.CitationsID, "bib-id", mmark.CitationsID, "ID bibliography URL")
	flag.StringVar(&mmark.CitationsRFC, "bib-rfc", mmark.CitationsRFC, "RFC bibliography URL")

	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "Mmark Markdown Processor"+
			"\nAvailable at http://github.com/miekg/mmark\n\n"+
			"Copyright © 2014 Miek Gieben <[email protected]>\n"+
			"Copyright © 2011 Russ Ross <[email protected]>\n"+
			"Distributed under the Simplified BSD License\n\n"+
			"Usage:\n"+
			"  %s [options] [inputfile [outputfile]]\n\n"+
			"Options:\n",
			os.Args[0])
		flag.PrintDefaults()
	}
	flag.Parse()

	// enforce implied options
	if css != "" {
		page = true
	}
	if head != "" {
		page = true
	}

	// read the input
	var input []byte
	var err error
	args := flag.Args()
	switch len(args) {
	case 0:
		if input, err = ioutil.ReadAll(os.Stdin); err != nil {
			log.Fatalf("error reading from Stdin:", err)
		}
	case 1, 2:
		if input, err = ioutil.ReadFile(args[0]); err != nil {
			log.Fatalf("error reading from", args[0], ":", err)
		}
	default:
		flag.Usage()
		return
	}

	// set up options
	extensions := 0
	extensions |= mmark.EXTENSION_TABLES
	extensions |= mmark.EXTENSION_FENCED_CODE
	extensions |= mmark.EXTENSION_AUTOLINK
	extensions |= mmark.EXTENSION_SPACE_HEADERS
	extensions |= mmark.EXTENSION_CITATION
	extensions |= mmark.EXTENSION_TITLEBLOCK_TOML
	extensions |= mmark.EXTENSION_HEADER_IDS
	extensions |= mmark.EXTENSION_AUTO_HEADER_IDS
	extensions |= mmark.EXTENSION_UNIQUE_HEADER_IDS
	extensions |= mmark.EXTENSION_FOOTNOTES
	extensions |= mmark.EXTENSION_SHORT_REF
	extensions |= mmark.EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK
	extensions |= mmark.EXTENSION_INCLUDE
	extensions |= mmark.EXTENSION_PARTS

	var renderer mmark.Renderer
	xmlFlags := 0
	switch {
	case xml:
		if page {
			xmlFlags = mmark.XML_STANDALONE
		}
		renderer = mmark.XmlRenderer(xmlFlags)
	case xml2:
		if page {
			xmlFlags = mmark.XML2_STANDALONE
		}
		renderer = mmark.Xml2Renderer(xmlFlags)
	default:
		// render the data into HTML
		htmlFlags := 0
		if page {
			htmlFlags |= mmark.HTML_COMPLETE_PAGE
		}
		renderer = mmark.HtmlRenderer(htmlFlags, css, head)
	}

	// parse and render
	output := mmark.Parse(input, renderer, extensions).Bytes()

	// output the result
	out := os.Stdout
	if len(args) == 2 {
		if out, err = os.Create(args[1]); err != nil {
//.........這裏部分代碼省略.........
開發者ID:jetpax,項目名稱:mmark,代碼行數:101,代碼來源:main.go

示例3: MmarkRenderWithTOC

func MmarkRenderWithTOC(ctx *RenderingContext) []byte {
	return mmark.Parse(ctx.Content,
		GetMmarkHtmlRenderer(0, ctx),
		GetMmarkExtensions(ctx)).Bytes()
}
開發者ID:n2xnot,項目名稱:hugo,代碼行數:5,代碼來源:content.go

示例4: mmarkRender

func mmarkRender(ctx *RenderingContext) []byte {
	return mmark.Parse(ctx.Content, getMmarkHTMLRenderer(0, ctx),
		getMmarkExtensions(ctx)).Bytes()
}
開發者ID:xinzhi,項目名稱:hugo,代碼行數:4,代碼來源:content.go

示例5: main

func main() {
	// parse command-line options
	var page, xml, xml2, commonmark bool
	var css, head, cpuprofile string
	var repeat int
	flag.BoolVar(&page, "page", false, "generate a standalone HTML page")
	flag.BoolVar(&xml, "xml", false, "generate XML2RFC v3 output")
	flag.BoolVar(&xml2, "xml2", false, "generate XML2RFC v2 output")
	flag.BoolVar(&commonmark, "commonmark", false, "input is commonmark")
	flag.StringVar(&css, "css", "", "link to a CSS stylesheet (implies -page)")
	flag.StringVar(&head, "head", "", "link to HTML to be included in head (implies -page)")
	flag.StringVar(&cpuprofile, "cpuprofile", "", "write cpu profile to a file")
	flag.IntVar(&repeat, "repeat", 1, "process the input multiple times (for benchmarking)")
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "Mmark Markdown Processor v"+mmark.VERSION+
			"\nAvailable at http://github.com/miekg/mmark\n\n"+
			"Copyright © 2014 Miek Gieben <[email protected]>\n"+
			"Copyright © 2011 Russ Ross <[email protected]>\n"+
			"Distributed under the Simplified BSD License\n"+
			"See website for details\n\n"+
			"Usage:\n"+
			"  %s [options] [inputfile [outputfile]]\n\n"+
			"Options:\n",
			os.Args[0])
		flag.PrintDefaults()
	}
	flag.Parse()

	// enforce implied options
	if css != "" {
		page = true
	}
	if head != "" {
		page = true
	}

	// turn on profiling?
	if cpuprofile != "" {
		f, err := os.Create(cpuprofile)
		if err != nil {
			fmt.Fprintln(os.Stderr, err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	// read the input
	var input []byte
	var err error
	args := flag.Args()
	switch len(args) {
	case 0:
		if input, err = ioutil.ReadAll(os.Stdin); err != nil {
			fmt.Fprintln(os.Stderr, "error reading from Stdin:", err)
			os.Exit(-1)
		}
	case 1, 2:
		if input, err = ioutil.ReadFile(args[0]); err != nil {
			fmt.Fprintln(os.Stderr, "error reading from", args[0], ":", err)
			os.Exit(-1)
		}
	default:
		flag.Usage()
		os.Exit(-1)
	}

	// set up options
	extensions := 0
	extensions |= mmark.EXTENSION_TABLES
	extensions |= mmark.EXTENSION_FENCED_CODE
	extensions |= mmark.EXTENSION_AUTOLINK
	extensions |= mmark.EXTENSION_SPACE_HEADERS
	extensions |= mmark.EXTENSION_CITATION
	extensions |= mmark.EXTENSION_TITLEBLOCK_TOML
	extensions |= mmark.EXTENSION_HEADER_IDS
	extensions |= mmark.EXTENSION_AUTO_HEADER_IDS
	extensions |= mmark.EXTENSION_UNIQUE_HEADER_IDS
	extensions |= mmark.EXTENSION_FOOTNOTES
	extensions |= mmark.EXTENSION_SHORT_REF
	extensions |= mmark.EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK
	extensions |= mmark.EXTENSION_INCLUDE

	if commonmark {
		extensions &= ^mmark.EXTENSION_AUTO_HEADER_IDS
		extensions &= ^mmark.EXTENSION_AUTOLINK
		extensions |= mmark.EXTENSION_LAX_HTML_BLOCKS
	}

	var renderer mmark.Renderer
	xmlFlags := 0
	switch {
	case xml:
		if page {
			xmlFlags = mmark.XML_STANDALONE
		}
		renderer = mmark.XmlRenderer(xmlFlags)
	case xml2:
		if page {
			xmlFlags = mmark.XML2_STANDALONE
		}
//.........這裏部分代碼省略.........
開發者ID:prodigeni,項目名稱:mmark,代碼行數:101,代碼來源:main.go


注:本文中的github.com/miekg/mmark.Parse函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。