Skip to content

web search done right

crlf linebreaks

Mikkel Denker398e041d16cd
diff --git a/.gitmodules b/.gitmodules
index 7e9313b7..e9ef195d 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,3 @@
[submodule "optics/testcases"]
- path = optics/testcases
+ path = optics/testcases/samples
url = https://github.com/StractOrg/sample-optics
diff --git a/core/src/query/optic.rs b/core/src/query/optic.rs
index 260d74fc..337512a5 100644
--- a/core/src/query/optic.rs
+++ b/core/src/query/optic.rs
@@ -448,8 +448,10 @@ mod tests {
.search(&SearchQuery {
query: "website".to_string(),
optic: Some(
- Optic::parse(include_str!("../../../optics/testcases/quickstart.optic"))
- .unwrap(),
+ Optic::parse(include_str!(
+ "../../../optics/testcases/samples/quickstart.optic"
+ ))
+ .unwrap(),
),
..Default::default()
})
@@ -460,8 +462,10 @@ mod tests {
.search(&SearchQuery {
query: "website".to_string(),
optic: Some(
- Optic::parse(include_str!("../../../optics/testcases/hacker_news.optic"))
- .unwrap(),
+ Optic::parse(include_str!(
+ "../../../optics/testcases/samples/hacker_news.optic"
+ ))
+ .unwrap(),
),
..Default::default()
})
@@ -473,7 +477,7 @@ mod tests {
query: "website".to_string(),
optic: Some(
Optic::parse(include_str!(
- "../../../optics/testcases/copycats_removal.optic"
+ "../../../optics/testcases/samples/copycats_removal.optic"
))
.unwrap(),
),
diff --git a/optics-lsp/package.json b/optics-lsp/package.json
index 98c2b50f..6d958981 100644
--- a/optics-lsp/package.json
+++ b/optics-lsp/package.json
@@ -1,6 +1,6 @@
{
"name": "Optics",
- "version": "0.0.8",
+ "version": "0.0.9",
"engines": {
"vscode": "^1.73.0"
},
@@ -20,9 +20,9 @@
"vscode-languageserver": "^7.0.0"
},
"devDependencies": {
+ "typescript": "^4.9.5",
"@types/node": "^17.0.35",
"@types/vscode": "^1.63.0",
- "typescript": "^4.7.2",
"vsce": "^2.14.0"
},
"repository": {
@@ -57,4 +57,4 @@
}
]
}
-}
\ No newline at end of file
+}
diff --git a/optics/src/ast.rs b/optics/src/ast.rs
index 44a4f786..a9253528 100644
--- a/optics/src/ast.rs
+++ b/optics/src/ast.rs
@@ -312,36 +312,41 @@ mod tests {
#[test]
fn quickstart_parse() {
- assert!(parse(include_str!("../testcases/quickstart.optic")).is_ok());
+ assert!(parse(include_str!("../testcases/samples/quickstart.optic")).is_ok());
}
#[test]
fn hacker_news_parse() {
- assert!(parse(include_str!("../testcases/hacker_news.optic")).is_ok());
+ assert!(parse(include_str!("../testcases/samples/hacker_news.optic")).is_ok());
}
#[test]
fn copycats_parse() {
- assert!(parse(include_str!("../testcases/copycats_removal.optic")).is_ok());
+ assert!(parse(include_str!("../testcases/samples/copycats_removal.optic")).is_ok());
}
#[test]
fn optics_10kshort_parse() {
- assert!(parse(include_str!("../testcases/10k_short.optic")).is_ok());
+ assert!(parse(include_str!("../testcases/samples/10k_short.optic")).is_ok());
}
#[test]
fn blogroll_parse() {
- assert!(parse(include_str!("../testcases/indieweb_blogroll.optic")).is_ok());
+ assert!(parse(include_str!("../testcases/samples/indieweb_blogroll.optic")).is_ok());
}
#[test]
fn devdocs_parse() {
- assert!(parse(include_str!("../testcases/devdocs.optic")).is_ok());
+ assert!(parse(include_str!("../testcases/samples/devdocs.optic")).is_ok());
}
#[test]
fn academic_parse() {
- assert!(parse(include_str!("../testcases/academic.optic")).is_ok());
+ assert!(parse(include_str!("../testcases/samples/academic.optic")).is_ok());
+ }
+
+ #[test]
+ fn crlf_linebreaks() {
+ assert!(parse(include_str!("../testcases/crlf.optic")).is_ok());
}
}
diff --git a/optics/src/lexer.rs b/optics/src/lexer.rs
index 2cbfe227..6d6521e7 100644
--- a/optics/src/lexer.rs
+++ b/optics/src/lexer.rs
@@ -94,7 +94,7 @@ impl<'a> ToString for Token<'a> {
#[derive(Logos, Debug, PartialEq, Clone)]
enum Outer<'a> {
#[error]
- #[regex(r"[ \t\n\f]+", logos::skip)]
+ #[regex(r"[ \t\r\n\f]+", logos::skip)]
Error,
#[token("\"")]
diff --git a/optics/testcases/crlf.optic b/optics/testcases/crlf.optic
new file mode 100644
index 00000000..36ad84bf
--- /dev/null
+++ b/optics/testcases/crlf.optic
@@ -0,0 +1,6 @@
+DiscardNonMatching;
+Rule{
+ Matches{
+ Url("example.com")
+ }
+}
\ No newline at end of file
diff --git a/optics/testcases b/optics/testcases/samples
similarity index 100%
rename from optics/testcases
rename to optics/testcases/samples