From 10a3fbd174fc1a3f95937c9120d478c8e94c277d Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 1 Apr 2023 19:34:49 +0200 Subject: [PATCH] Documentation for regex from raw element Fixes #266. --- library/src/compute/construct.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/src/compute/construct.rs b/library/src/compute/construct.rs index 04195f421..e7e05eeea 100644 --- a/library/src/compute/construct.rs +++ b/library/src/compute/construct.rs @@ -383,6 +383,10 @@ pub fn regex( /// escape sequences. To produce regex escape sequences that are also valid in /// Typst (e.g. `[\\]`), you need to escape twice. Thus, to match a verbatim /// backslash, you would need to write `{regex("\\\\")}`. + /// + /// If you need many escape sequences, you can also create a raw element + /// and extract its text to use it for your regular expressions: + /// ```{regex(`\d+\.\d+\.\d+`.text)}```. regex: Spanned, ) -> Value { Regex::new(®ex.v).at(regex.span)?.into()