css3-selectors

changeset 68:18d0c408131f

Handle the ^=, $=, and *= string matchers
author Emanuele Aina <em@nerd.ocracy.org>
date Tue Dec 30 17:44:48 2008 +0100 (19 months ago)
parents cc0eaffb6660
children fe189fede98d
files Css3SelectorExperiment.cs
line diff
     1.1 --- a/Css3SelectorExperiment.cs	Mon Nov 10 23:02:24 2008 +0100
     1.2 +++ b/Css3SelectorExperiment.cs	Tue Dec 30 17:44:48 2008 +0100
     1.3 @@ -90,6 +90,10 @@
     1.4                  case "=" : return "[@" + Attribute + "='" + Value + "']";
     1.5                  case "|=": return String.Format("[@{0}='{1}' or starts-with(@{0},'{1}-')]", Attribute, Value);
     1.6                  case "~=": return String.Format("[contains(concat(' ',@{0},' '),' {1} ')]", Attribute, Value);
     1.7 +                case "^=": return String.Format("[starts-with(@{0},'{1}')]", Attribute, Value);
     1.8 +                // TODO: add the ends-with() XPath function
     1.9 +                case "$=": return String.Format("[ends-with(@{0},'{1}')]", Attribute, Value);
    1.10 +                case "*=": return String.Format("[contains(@{0},'{1}')]", Attribute, Value);
    1.11              }
    1.12              throw new Exception();
    1.13          }
    1.14 @@ -202,7 +206,7 @@
    1.15              // pseudo classes
    1.16              new[]{@"^:([a-z0-9_-]+)(\((.*)\))?", "Pseudo" },
    1.17              // attribute value match
    1.18 -            new[]{@"^\[\s*([^~\|=\s]+)\s*(([~\|]?=)\s*(.+))?\]", "Attr"},
    1.19 +            new[]{@"^\[\s*([^~\|^$*=\s]+)\s*(([~\|^$*]?=)\s*(.+))?\]", "Attr"},
    1.20              // adjacency/direct descendance
    1.21              new[]{@"^\s*([>+\~\s])\s*", "Combinator"},
    1.22              // rules union 

To download these repositories, get Mercurial and then type something like:

hg clone http://techn.ocracy.org/repository-name/

You can also click the "zip" or "gz" links to get an archive of the latest revision without installing anything.

The change logs of the repositories are aggregated at techn.ocracy.org/planet.

We have also some darcs repositories at techn.ocracy.org/darcs.