示例#1
0
// return the comment within the sentence
func getComment(sel *goquery.Selection) (string, map[int]string) {
	var contentBuffer bytes.Buffer
	var linksMap map[int]string = make(map[int]string)
	//	fmt.Println(sel.Contents().Length())
	sel.Contents().Each(func(i int, x *goquery.Selection) {
		href, exists := x.Attr("href")
		if exists {
			// this is a comment link
			link := getLink(href)
			commentNo, _ := strconv.Atoi(x.Text())
			linksMap[commentNo] = link
			//fmt.Println(commentNo + ": " + link)
		} else {
			contentBuffer.WriteString(x.Text())
			//fmt.Println(x.Text())
		}

	})

	return contentBuffer.String(), linksMap
}
示例#2
0
文件: wiki.go 项目: mnpk/apex
// contents returns a string representation of the selection's contents.
func contents(s *goquery.Selection) string {
	return strings.Join(s.Contents().Map(node), "")
}
示例#3
0
func NumberOfChild(s *goquery.Selection) int {
	return s.Contents().Length()
	//return s.Contents().Size()
}