Documentation ¶
Index ¶
- Variables
- func PapersizeWidthHeight(spec string) (string, string)
- func ResolveAttributes(attrs []html.Attribute) (resolved map[string]string, attributes map[string]string, ...)
- type CSS
- func (c *CSS) AddCSSText(fragment string) error
- func (c *CSS) ApplyCSS(doc *goquery.Document) (*goquery.Document, error)
- func (c *CSS) FindFile(filename string) (string, error)
- func (c *CSS) ParseHTMLFragment(htmltext string) (*goquery.Document, error)
- func (c *CSS) ParseHTMLFragmentWithCSS(htmltext, csstext string) (*goquery.Document, error)
- func (c *CSS) PopDir()
- func (c *CSS) PushDir(dir string)
- func (c *CSS) ReadHTMLChunk(htmltext string) (*goquery.Document, error)
- func (c *CSS) ReadHTMLWithStyles(filename string) (*goquery.Document, error)
- func (c *CSS) Show() string
- type Page
Constants ¶
This section is empty.
Variables ¶
var CSSdefaults = `` /* 2021-byte string literal not displayed */
CSSdefaults contains browser-like styling of some elements.
Functions ¶
func PapersizeWidthHeight ¶
PapersizeWidthHeight converts the spec to the width and height. The parameter can be a known paper size (such as A4 or letter) or a one or two parameter string such as 20cm 20cm.
func ResolveAttributes ¶
func ResolveAttributes(attrs []html.Attribute) (resolved map[string]string, attributes map[string]string, newAttributes []html.Attribute)
ResolveAttributes returns the resolved styles and the attributes of the node. It changes "margin: 1cm;" into "margin-left: 1cm; margin-right: 1cm; ...".
Types ¶
type CSS ¶
type CSS struct { FrontendDocument *frontend.Document Stylesheet []sBlock Pages map[string]Page FileFinder func(string) (string, error) // contains filtered or unexported fields }
CSS wraps multiple stylesheets.
func NewCSSParserWithDefaults ¶
func NewCSSParserWithDefaults() *CSS
NewCSSParserWithDefaults returns a new CSS object with the default stylesheet included.
func (*CSS) AddCSSText ¶
AddCSSText parses CSS text and appends the rules to the previously read rules.
func (*CSS) ApplyCSS ¶
ApplyCSS resolves CSS rules in the DOM. Each CSS rule is added to the selection as an attribute (prefixed with a !). Pseudo elements are prefixed with ::.
func (*CSS) FindFile ¶
FindFile returns the absolute path of the file. If the requested file is found with the FileFinder then this value is returned instead.
func (*CSS) ParseHTMLFragment ¶
ParseHTMLFragment takes the HTML text and the CSS text and returns goquery selection.
func (*CSS) ParseHTMLFragmentWithCSS ¶
ParseHTMLFragmentWithCSS takes the HTML text and the CSS text and returns goquery selection.
func (*CSS) PushDir ¶
PushDir adds a directory to the dir stack. When a file is opened, all new Open calls are relative to this directory.
func (*CSS) ReadHTMLChunk ¶
ReadHTMLChunk reads the HTML text. If there are linked style sheets (<link href=...) these are also read. After reading the HTML and CSS the HTML is stored in c.document.
func (*CSS) ReadHTMLWithStyles ¶
ReadHTMLWithStyles opens an HTML file and read linked stylesheets.