Webrexp csscompat - Twinside/Webrexp GitHub Wiki

Home

CSS selector compatibility

The webrexp language is mostly a superset of the css selector. But there is some differences which you may now to help you avoid some problem when copy/pasting selectors.

Element selectors

You can select any element just like in CSS, but unlike CSS, you can't just use an id or a class in the wild. The following snippet :

    #myId .class

while absolutely valid in CSS, is invalid in webrexp, you must insert a wildcard to make it valid :

    _#myId _.class

More complex selector are valids :

    div#myId p.class span.foo#bar

Tree walking

We support the following selection operator :

  • + to select the next sibling
  • ~ to select the previous sibling
  • > to restrict the search to the current node's children only.
  • Additionally, we support the < operator to select the parent of the current node.

Unions

Unions are supported in webrexp, most of the time, you will want to put them in parenthesis like in the following example :

    "myDoc.html" >> (h1, h2, h3, h4) [.]

It will display, all the headings from level 1, 2, 3 or 4.

Attribute predicate

The attribute predicates of CSS3 are embeded in the actions of the webrexp, with the following operators :

  • ~= find the right part in the whitespace separated left part.
  • ^= find if the right part is the prefix of the left part.
  • $= find if the right part is the suffix of the left part.
  • *= Find if the right part is a substring of the left part.
  • |= Like ~= but use hypens (-) instead of whitespace and just check for the first. Ok, not quite like.

Pseudo-classes

Webrexp don't support any of the :something selectors