Documentation
¶
Overview ¶
Package css extracts colours from HTML and CSS files.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CML ¶
type CML struct {
// URL where the colors are from
URL *url.URL
Mentions []*ColorMention
}
CML ColorMention List
type ColorMention ¶
type ColorMention struct {
Color *colorful.Color
// color, background-color
Property string
// .class, nav > a
// Selectors for inline CSS are based on Context structs.
// Otherwise the typical CSS selector is used.
Selector string
}
ColorMention is a single occurrence of a color in a certain context.
func New ¶
func New(c *colorful.Color, property, selector string) *ColorMention
New ColorMention of a color for a property at a certain selector.
func ParseHTML ¶
func ParseHTML(s string) ([]*ColorMention, error)
ParseHTML extract colors from "style" attributes and elements.
Example ¶
cms, _ := ParseHTML(`<style>body{color:#001122}</style>
<div id="some-div" class="some-class">
<span style="background-color:red"></span>
</div>
`)
for _, cm := range cms {
fmt.Printf("%s %s = %s\n", cm.Selector, cm.Property, cm.Color.Hex())
}
Output: body color = #001122 html > body > div#some-div.some-class > span background-color = #ff0000
func ParseStylesheet ¶
func ParseStylesheet(sheet string) []*ColorMention
ParseStylesheet extracts colors from a full CSS stylesheet.
Click to show internal directories.
Click to hide internal directories.