// 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
}
Exemple #2
0
// contents returns a string representation of the selection's contents.
func contents(s *goquery.Selection) string {
	return strings.Join(s.Contents().Map(node), "")
}
Exemple #3
0
func NumberOfChild(s *goquery.Selection) int {
	return s.Contents().Length()
	//return s.Contents().Size()
}