commit | 10ecad59238e91742abefb2fa0e21ee73658f653 | [log] [tgz] |
---|---|---|
author | Aymerick <aymerick@jehanne.org> | Wed Apr 15 11:22:20 2015 |
committer | Aymerick <aymerick@jehanne.org> | Wed Apr 15 11:22:20 2015 |
tree | 3d7b543eb8e590fabf196860701dfc1e6047a6a9 | |
parent | 8d7d8293a2f242536459959c3c311dea1be7e37c [diff] |
inliner: insert raw CSS rules
A simple CSS parser and inliner in Go.
Parser uses Gorilla CSS3 tokenizer. It is vaguely inspired by CSS Syntax Module Level 3 and corresponding JS parser.
Inliner uses goquery to parse HTML.
Install tool:
$ go install github.com/aymerick/douceur
Parse a CSS file and display result:
$ douceur parse inputfile.css
Inline CSS in an HTML document and display result:
$ douceur inline inputfile.html
Fetch package:
$ go get github.com/aymerick/douceur
package main
import (
"fmt"
"github.com/aymerick/douceur/parser"
)
func main() {
input := `body {
/* D4rK s1T3 */
background-color: black;
}
p {
/* Try to read that ! HAHA! */
color: red; /* L O L */
}
`
stylesheet, err := parser.Parse(input)
if err != nil {
panic("OMG ! SO BUGGY !")
}
fmt.Print(stylesheet.String())
}
Displays:
body { background-color: black; } p { color: red; }
@todo !!!
go test ./... -v