Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

34 lines (29 sloc) 0.511 kb
package main
import (
"exp/html"
"log"
"os"
)
func main() {
root, err := html.Parse(os.Stdin)
if err != nil {
log.Fatal(err)
}
body := Tag("body").Find(root)[0]
collapseSpans(body)
cleanClasses(body)
html.Render(os.Stdout, body)
}
func collapseSpans(n *html.Node) {
Tag("span").Walk(n, func(n *html.Node) {
if len(n.Child) > 0 {
InsertBefore(n, n.Child...)
}
n.Parent.Remove(n)
})
}
func cleanClasses(n *html.Node) {
All().Walk(n, func(n *html.Node) {
RemoveAttr(n, "class")
})
}
Jump to Line
Something went wrong with that request. Please try again.