mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 08:35:28 +00:00
fix quote expression
This commit is contained in:
parent
9612c988cc
commit
d40eab57ec
1 changed files with 16 additions and 9 deletions
|
|
@ -6,7 +6,7 @@ use gtk::{
|
||||||
};
|
};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
const REGEX_QUOTE: &str = r"(?m)^>\s+(?P<text>.*)$";
|
const REGEX_QUOTE: &str = r"(?m)>\s*(?P<text>.*)$";
|
||||||
|
|
||||||
pub struct Quote(TextTag);
|
pub struct Quote(TextTag);
|
||||||
|
|
||||||
|
|
@ -50,12 +50,19 @@ impl Quote {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_regex() {
|
fn test_regex() {
|
||||||
let cap: Vec<_> = Regex::new(REGEX_QUOTE)
|
let cap: Vec<_> = Regex::new(REGEX_QUOTE).unwrap().captures_iter(
|
||||||
.unwrap()
|
"> Some quote 1 with \n> Some quote 2 with text\nplain text\n> Some quote 3"
|
||||||
.captures_iter(r"> Some quote with ")
|
).collect();
|
||||||
.collect();
|
{
|
||||||
|
let m = cap.first().unwrap();
|
||||||
let first = cap.first().unwrap();
|
assert_eq!(&m["text"], "Some quote 1 with ");
|
||||||
assert_eq!(&first[0], "> Some quote with ");
|
}
|
||||||
assert_eq!(&first["text"], "Some quote with ");
|
{
|
||||||
|
let m = cap.get(1).unwrap();
|
||||||
|
assert_eq!(&m["text"], "Some quote 2 with text");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
let m = cap.get(2).unwrap();
|
||||||
|
assert_eq!(&m["text"], "Some quote 3");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue