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


Golang mmark.HtmlRendererWithParameters函數代碼示例

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


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

示例1: GetMmarkHtmlRenderer

// mmark
func GetMmarkHtmlRenderer(defaultFlags int, ctx *RenderingContext) mmark.Renderer {
	renderParameters := mmark.HtmlRendererParameters{
		FootnoteAnchorPrefix:       viper.GetString("FootnoteAnchorPrefix"),
		FootnoteReturnLinkContents: viper.GetString("FootnoteReturnLinkContents"),
	}

	b := len(ctx.DocumentID) != 0

	if b && !ctx.getConfig().PlainIDAnchors {
		renderParameters.FootnoteAnchorPrefix = ctx.DocumentID + ":" + renderParameters.FootnoteAnchorPrefix
		// renderParameters.HeaderIDSuffix = ":" + ctx.DocumentId
	}

	htmlFlags := defaultFlags
	htmlFlags |= mmark.HTML_FOOTNOTE_RETURN_LINKS

	return mmark.HtmlRendererWithParameters(htmlFlags, "", "", renderParameters)
}
開發者ID:n2xnot,項目名稱:hugo,代碼行數:19,代碼來源:content.go

示例2: TestMarkdownLinks

func TestMarkdownLinks(t *testing.T) {
	file := "test/index.md"
	data.AllFiles = make(map[string]*data.FileDetails)
	data.AddFile(file, file)

	htmlFlags := 0
	renderParameters := mmark.HtmlRendererParameters{}
	renderer := &TestRenderer{
		LinkFrom: file,
		//Html:     mmark.HtmlRenderer(htmlFlags, "", "").(*mmark.Html),
		Renderer: mmark.HtmlRendererWithParameters(htmlFlags, "", "", renderParameters),
	}
	out := bytes.NewBuffer(make([]byte, 1024))

	tests := map[string]string{
		"../first.md":            "first.md",
		"second.md":              "test/second.md",
		"./second.md":            "test/second.md",
		"banana/second.md":       "test/banana/second.md",
		"/test/banana/second.md": "test/banana/second.md",
		"twice.md":               "test/twice.md",
		"banana/twice.md":        "test/banana/twice.md",
	}

	for _, path := range tests {
		data.AddFile(path, path)
	}
	for link, _ := range tests {
		renderer.Link(out, []byte(link), []byte("title"), []byte("content"))
	}

	for link, details := range data.AllLinks {
		data.AllLinks[link].Response = testUrl(link, "", true)
		//fmt.Printf("\t\t(%d) %d links to %s\n", data.AllLinks[link].Response, details.Count, link)
		fmt.Printf("%s links to %s\n", details.ActualLink[0], link)
		if _, ok := data.AllFiles[link]; !ok {
			t.Errorf("ERROR(%d): not found %s links to %s\n", details.Response, details.ActualLink[0], link)
		}
		if tests[details.ActualLink[0]] != link {
			t.Errorf("ERROR(%d): %s links to %s, should link to %s\n", details.Response, details.ActualLink[0], link, tests[details.ActualLink[0]])
		}
	}
}
開發者ID:docker,項目名稱:markdownlint,代碼行數:43,代碼來源:links_test.go

示例3: 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


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