css – CSS related functions
This module contains functions related to the handling of CSS.
- ll.xist.css.replaceurls(stylesheet, replacer)[source]
Replace all URLs appearing in the
CSSStyleSheetstylesheet. For each URL the functionreplacerwill be called and the URL will be replaced with the result.
- ll.xist.css.geturls(stylesheet)[source]
Return a list of all URLs appearing in the
CSSStyleSheetstylesheet.
- ll.xist.css.iterrules(node, base=None, media=None, title=None)[source]
Return an iterator for all CSS rules defined in the HTML tree
node. This will parse the CSS defined in anyhtml.styleorhtml.linkelement (and recursively in those stylesheets imported via the@importrule). The rules will be returned asCSSStyleRuleobjects from thecssutilspackage (so this requirescssutils).The
baseargument will be used as the base URL for parsing the stylesheet references in the tree (soNonemeans the URLs will be used exactly as they appear in the tree). All URLs in the style properties will be resolved.If
mediais given, only rules that apply to this media type will be produced.titlecan be used to specify which stylesheet group should be used. IftitleisNoneonly the persistent and preferred stylesheets will be used. Iftitleis a string only the persistent stylesheets and alternate stylesheets with that style name will be used.For a description of “persistent”, “preferred” and “alternate” stylesheets see <http://www.w3.org/TR/2002/WD-xhtml2-20020805/mod-styleSheet.html#sec_20.1.2.>
- ll.xist.css.applystylesheets(node, base=None, media=None, title=None)[source]
applystylesheets()modifies the XIST treenodeby removing all CSS (fromhtml.linkandhtml.styleelements and their@imported stylesheets) and putting the resulting style properties into thestyleattribute of every affected element instead.For the meaning of
base,mediaandtitleseeiterrules().
- class ll.xist.css.CSSWeightedSelector[source]
Bases:
SelectorBase class for all CSS pseudo-class selectors.
- class ll.xist.css.CSSHasAttributeSelector[source]
Bases:
CSSWeightedSelectorA
CSSHasAttributeSelectorselector selects all element nodes that have an attribute with the specified XML name.
- class ll.xist.css.CSSAttributeListSelector[source]
Bases:
CSSWeightedSelectorA
CSSAttributeListSelectorselector selects all element nodes where an attribute with the specified XML name has the specified word among the white space-separated list of words in the attribute value.
- class ll.xist.css.CSSAttributeLangSelector[source]
Bases:
CSSWeightedSelectorA
CSSAttributeLangSelectorselector selects all element nodes where an attribute with the specified XML name either is exactly the specified value or starts with the specified value followed by"-".
- class ll.xist.css.CSSFirstChildSelector[source]
Bases:
CSSWeightedSelectorA
CSSFirstChildSelectorselector selects all element nodes that are the first child of its parent.
- class ll.xist.css.CSSLastChildSelector[source]
Bases:
CSSWeightedSelectorA
CSSLastChildSelectorselector selects all element nodes that are the last child of its parent.
- class ll.xist.css.CSSFirstOfTypeSelector[source]
Bases:
CSSWeightedSelectorA
CSSLastChildSelectorselector selects all element nodes that are the first of its type among their siblings.
- class ll.xist.css.CSSLastOfTypeSelector[source]
Bases:
CSSWeightedSelectorA
CSSLastChildSelectorselector selects all element nodes that are the last of its type among their siblings.
- class ll.xist.css.CSSOnlyChildSelector[source]
Bases:
CSSWeightedSelectorA
CSSOnlyChildSelectorselector selects all element nodes that are the only element among its siblings.
- class ll.xist.css.CSSOnlyOfTypeSelector[source]
Bases:
CSSWeightedSelectorA
CSSOnlyOfTypeSelectorselector selects all element nodes that are the only element of its type among its siblings.
- class ll.xist.css.CSSEmptySelector[source]
Bases:
CSSWeightedSelectorA
CSSEmptySelectorselector selects all element nodes that are empty (i.e. they contain no elements or non-whitespace text).
- class ll.xist.css.CSSRootSelector[source]
Bases:
CSSWeightedSelectorA
CSSRootSelectorselector selects the root element.
- class ll.xist.css.CSSLinkSelector[source]
Bases:
CSSWeightedSelectorA
CSSLinkSelectorselector selects all HTML links.
- class ll.xist.css.CSSDisabledSelector[source]
Bases:
CSSWeightedSelectorA
CSSDisabledSelectorselector selects all HTML elements where the attributedisabledis set.Note that that is not 100% what the pseudo class :disabled means, but since we have no live DOM this is the best we can do.
- class ll.xist.css.CSSFunctionSelector[source]
Bases:
CSSWeightedSelectorBase class of all CSS selectors that require an argument.
- class ll.xist.css.CSSNthChildSelector[source]
Bases:
CSSFunctionSelectorA
CSSNthChildSelectorselector selects all element nodes that are the n-th element among their siblings.
- class ll.xist.css.CSSNthLastChildSelector[source]
Bases:
CSSFunctionSelectorA
CSSNthLastChildSelectorselector selects all element nodes that are the n-th last element among their siblings.
- class ll.xist.css.CSSNthOfTypeSelector[source]
Bases:
CSSFunctionSelectorA
CSSNthOfTypeSelectorselector selects all element nodes that are the n-th of its type among their siblings.
- class ll.xist.css.CSSNthLastOfTypeSelector[source]
Bases:
CSSFunctionSelectorA
CSSNthOfTypeSelectorselector selects all element nodes that are the n-th last of its type among their siblings.
- class ll.xist.css.CSSAdjacentSiblingCombinator[source]
Bases:
BinaryCombinatorA
CSSAdjacentSiblingCombinatorworks similar to anAdjacentSiblingCombinatorexcept that only preceding elements are considered.
- class ll.xist.css.CSSGeneralSiblingCombinator[source]
Bases:
BinaryCombinatorA
CSSGeneralSiblingCombinatorworks similar to anxfind.GeneralSiblingCombinatorexcept that only preceding elements are considered.
- ll.xist.css.selector(selectors, prefixes=None)[source]
Create a
xfind.Selectorobject that matches all nodes that match the specified CSS selector expression.selectorscan be a string or acssutils.css.selector.Selectorobject.prefixesmay be a mapping mapping namespace prefixes to namespace names.
- ll.xist.css.parsestring(data, base=None, encoding=None)[source]
Parse the string
datainto acssutilsstylesheet.baseis the base URL for the parsing process,encodingcan be used to force the parser to use the specified encoding.
- ll.xist.css.parsestream(stream, base=None, encoding=None)[source]
Parse a
cssutilsstylesheet from the streamstream.baseis the base URL for the parsing process,encodingcan be used to force the parser to use the specified encoding.
- ll.xist.css.parsefile(filename, base=None, encoding=None)[source]
Parse a
cssutilsstylesheet from the file namedfilename.baseis the base URL for the parsing process (defaulting to the filename itself),encodingcan be used to force the parser to use the specified encoding.
- ll.xist.css.parseurl(name, base=None, encoding=None, *args, **kwargs)[source]
Parse a
cssutilsstylesheet from the URLname.baseis the base URL for the parsing process (defaulting to the final URL of the response, i.e. including redirects),encodingcan be used to force the parser to use the specified encoding.argandkwargsare passed on toURL.openread(), so you can pass POST data and request headers.