From 45183697de84b3c9d82133e848f3005b66d0df98 Mon Sep 17 00:00:00 2001
From: kirbylife <gabriel13m@gmail.com>
Date: Sun, 7 Mar 2021 19:48:08 -0600
Subject: [PATCH] add readme file

---
 README.md  | 26 ++++++++++++++++++++++++++
 src/lib.rs |  2 +-
 2 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 README.md

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<String> {
+pub fn cssifier(xpath: &'static str) -> Option<String> {
     // Ultra magic regex to parse XPath selectors
     let reg = Regex::new(r#"(?P<node>(^id\(["']?(?P<idvalue>\s*[\w/:][-/\w\s,:;.]*)["']?\)|(?P<nav>//?)(?P<tag>([a-zA-Z][a-zA-Z0-9]{0,10}|\*))(\[((?P<matched>(?P<mattr>@?[.a-zA-Z_:][-\w:.]*(\(\))?)=["'](?P<mvalue>\s*[\w/:][-/\w\s,:;.]*))["']|(?P<contained>contains\((?P<cattr>@?[.a-zA-Z_:][-\w:.]*(\(\))?),\s*["'](?P<cvalue>\s*[\w/:][-/\w\s,:;.]*)["']\)))\])?(\[(?P<nth>\d)\])?))"#).unwrap();
     let mut css = String::new();