Example #1
0
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))
}
Example #2
0
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))
}
Example #3
0
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())
}