github.com/MontFerret/ferret@v0.18.0/pkg/drivers/common/types.go (about) 1 package common 2 3 import ( 4 "golang.org/x/net/html" 5 ) 6 7 func FromHTMLType(nt html.NodeType) int { 8 switch nt { 9 case html.DocumentNode: 10 return 9 11 case html.ElementNode: 12 return 1 13 case html.TextNode: 14 return 3 15 case html.CommentNode: 16 return 8 17 case html.DoctypeNode: 18 return 10 19 } 20 21 return 0 22 } 23 24 func ToHTMLType(input int) html.NodeType { 25 switch input { 26 case 1: 27 return html.ElementNode 28 case 3: 29 return html.TextNode 30 case 8: 31 return html.CommentNode 32 case 9: 33 return html.DocumentNode 34 case 10: 35 return html.DoctypeNode 36 default: 37 return html.ErrorNode 38 } 39 }