diff --git a/README.md b/README.md new file mode 100644 index 0000000..b0be6c6 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# CSSIFIER_RS + +## Simple crate to convert XPath selectors to CSS selectors + +based on [cssify](https://github.com/santiycr/cssify) but rewrited in Rust (RiiR f4w). + +### dependencies: +- [Regex](https://crates.io/crates/regex) + +### Usage +The usage is simple: +``` +cssifier("//a/b") +// Some("a b") + +cssifier("//a/b[@id='hello']") +// Some(a b#hello) + +cssifier("//a/b[contains(text(), 'hello')]") +// Some(a b:contains(hello)) +``` + +### Known issues +[ ] invalid XPath selectors panic + +Contributors are welcome :). diff --git a/src/lib.rs b/src/lib.rs index 7514fa9..3f2fb7b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ use regex::Regex; -fn cssifier(xpath: &'static str) -> Option { +pub fn cssifier(xpath: &'static str) -> Option { // Ultra magic regex to parse XPath selectors let reg = Regex::new(r#"(?P(^id\(["']?(?P\s*[\w/:][-/\w\s,:;.]*)["']?\)|(?P