Skip to content

Instantly share code, notes, and snippets.

@ericchiang
Created February 5, 2015 03:34
Show Gist options
  • Select an option

  • Save ericchiang/9c74c96473c6cfea50af to your computer and use it in GitHub Desktop.

Select an option

Save ericchiang/9c74c96473c6cfea50af to your computer and use it in GitHub Desktop.
package main
import (
"log"
"os"
"strings"
"golang.org/x/net/html"
)
var data = `<!DOCTYPE html>
<html>
<head></head>
<body>
<pre>
some text
<span>bar</span>
some more oddly spaced text
</pre>
</body>
</html>`
func main() {
node, err := html.Parse(strings.NewReader(data))
if err != nil {
log.Fatal(err)
}
html.Render(os.Stdout, node)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment