diff options
Diffstat (limited to 'parser.go')
| -rw-r--r-- | parser.go | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/parser.go b/parser.go deleted file mode 100644 index 8a66e6f..0000000 --- a/parser.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2020, Shulhan <m.shulhan@gmail.com>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package kbbi - -import ( - "strings" - - "golang.org/x/net/html" -) - -func getAttrValue(attrs []html.Attribute) string { - for _, attr := range attrs { - if attr.Key == attrNameValue { - return attr.Val - } - } - return "" -} - -// -// getFirstChild get the first non-empty child. -// -func getFirstChild(node *html.Node) *html.Node { - el := node.FirstChild - for el != nil { - if el.Type == html.TextNode { - if len(strings.TrimSpace(el.Data)) == 0 { - el = el.NextSibling - continue - } - } - break - } - return el -} - -func getNextSibling(node *html.Node) *html.Node { - el := node.NextSibling - for el != nil { - if el.Type == html.TextNode { - if len(strings.TrimSpace(el.Data)) == 0 { - el = el.NextSibling - continue - } - } - break - } - return el -} |
