本文整理汇总了Golang中github.com/PuerkitoBio/goquery.Selection.ReplaceWithHtml方法的典型用法代码示例。如果您正苦于以下问题:Golang Selection.ReplaceWithHtml方法的具体用法?Golang Selection.ReplaceWithHtml怎么用?Golang Selection.ReplaceWithHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/PuerkitoBio/goquery.Selection
的用法示例。
在下文中一共展示了Selection.ReplaceWithHtml方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: convertOrderedListSelection
func convertOrderedListSelection(sel *goquery.Selection) {
handleNestedList(sel)
setCounter := getListStartCounter(sel)
indentBeginEnd := strings.Repeat("\t", NEST_DEPTH-1)
text, _ := sel.Html()
left := indentBeginEnd + "\\begin{enumerate}\n" + setCounter + "\t\\itemsep0em"
right := indentBeginEnd + "\\end{enumerate}"
sel.ReplaceWithHtml(wrap(text, left, right))
}
示例2: convertUnorderedListSelection
func convertUnorderedListSelection(sel *goquery.Selection) {
handleNestedList(sel)
setCounter := getListStartCounter(sel)
// indentItems := strings.Repeat("\t", NEST_DEPTH)
indentBeginEnd := strings.Repeat("\t", NEST_DEPTH-1)
text, _ := sel.Html()
//text = strdel.LeadingSpaces(text)
left := indentBeginEnd + "\\begin{itemize}\n" + setCounter + "\t\\itemsep0em"
right := indentBeginEnd + "\\end{itemize}"
sel.ReplaceWithHtml(wrap(text, left, right))
}
示例3: processUl
func processUl(ul *goquery.Selection, depth int) {
ul.Find("li").Each(func(_ int, li *goquery.Selection) {
li.Find("ul").Each(func(_ int, childUl *goquery.Selection) {
processUl(childUl, depth+1)
})
lines := StringToLines(li.Text())
var indentedLines []string
for i, line := range lines {
if i == 0 {
liMarkIndex := depth % 2
mark := liMark[liMarkIndex]
indentedLines = append(indentedLines, "\n"+mark+" "+line)
} else {
indentedLines = append(indentedLines, " "+line)
}
}
li.ReplaceWithHtml(strings.Join(indentedLines, "\n"))
})
ul.ReplaceWithHtml(ul.Text())
}