summaryrefslogtreecommitdiffstats
path: root/publisher/htmlElementsCollector.go
diff options
context:
space:
mode:
Diffstat (limited to 'publisher/htmlElementsCollector.go')
-rw-r--r--publisher/htmlElementsCollector.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/publisher/htmlElementsCollector.go b/publisher/htmlElementsCollector.go
index e033f52d7..7bb2ebf15 100644
--- a/publisher/htmlElementsCollector.go
+++ b/publisher/htmlElementsCollector.go
@@ -116,7 +116,13 @@ func (w *cssClassCollectorWriter) Write(p []byte) (n int, err error) {
w.buff.Reset()
+ if strings.HasPrefix(s, "</") {
+ continue
+ }
+
+ s, tagName := w.insertStandinHTMLElement(s)
el := parseHTMLElement(s)
+ el.Tag = tagName
w.collector.mu.Lock()
w.collector.elementSet[s] = true
@@ -132,6 +138,20 @@ func (w *cssClassCollectorWriter) Write(p []byte) (n int, err error) {
return
}
+// The net/html parser does not handle single table elemnts as input, e.g. tbody.
+// We only care about the element/class/ids, so just store away the original tag name
+// and pretend it's a <div>.
+func (c *cssClassCollectorWriter) insertStandinHTMLElement(el string) (string, string) {
+ tag := el[1:]
+ spacei := strings.Index(tag, " ")
+ if spacei != -1 {
+ tag = tag[:spacei]
+ }
+ newv := strings.Replace(el, tag, "div", 1)
+ return newv, strings.ToLower(tag)
+
+}
+
func (c *cssClassCollectorWriter) endCollecting(drop bool) {
c.isCollecting = false
c.inQuote = false