Ejemplo n.º 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
}
Ejemplo n.º 2
0
Archivo: wiki.go Proyecto: 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), "")
}
Ejemplo n.º 3
0
func NumberOfChild(s *goquery.Selection) int {
	return s.Contents().Length()
	//return s.Contents().Size()
}