From d40eab57ec132a24169641263f1e0c730317bd1a Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 10 Mar 2026 17:52:16 +0200 Subject: [PATCH] fix quote expression --- .../page/content/text/markdown/tags/quote.rs | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/app/browser/window/tab/item/page/content/text/markdown/tags/quote.rs b/src/app/browser/window/tab/item/page/content/text/markdown/tags/quote.rs index 0c932189..3c854a1d 100644 --- a/src/app/browser/window/tab/item/page/content/text/markdown/tags/quote.rs +++ b/src/app/browser/window/tab/item/page/content/text/markdown/tags/quote.rs @@ -6,7 +6,7 @@ use gtk::{ }; use regex::Regex; -const REGEX_QUOTE: &str = r"(?m)^>\s+(?P.*)$"; +const REGEX_QUOTE: &str = r"(?m)>\s*(?P.*)$"; pub struct Quote(TextTag); @@ -50,12 +50,19 @@ impl Quote { #[test] fn test_regex() { - let cap: Vec<_> = Regex::new(REGEX_QUOTE) - .unwrap() - .captures_iter(r"> Some quote with ![img](https://link.com)") - .collect(); - - let first = cap.first().unwrap(); - assert_eq!(&first[0], "> Some quote with ![img](https://link.com)"); - assert_eq!(&first["text"], "Some quote with ![img](https://link.com)"); + let cap: Vec<_> = Regex::new(REGEX_QUOTE).unwrap().captures_iter( + "> Some quote 1 with ![img](https://link.com)\n> Some quote 2 with text\nplain text\n> Some quote 3" + ).collect(); + { + let m = cap.first().unwrap(); + assert_eq!(&m["text"], "Some quote 1 with ![img](https://link.com)"); + } + { + 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"); + } }