summaryrefslogtreecommitdiffstats
path: root/vendor/mdbook/src/preprocess/links.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/mdbook/src/preprocess/links.rs')
-rw-r--r--vendor/mdbook/src/preprocess/links.rs25
1 files changed, 14 insertions, 11 deletions
diff --git a/vendor/mdbook/src/preprocess/links.rs b/vendor/mdbook/src/preprocess/links.rs
index 7ca6fd345..c2c81f522 100644
--- a/vendor/mdbook/src/preprocess/links.rs
+++ b/vendor/mdbook/src/preprocess/links.rs
@@ -10,6 +10,8 @@ use std::path::{Path, PathBuf};
use super::{Preprocessor, PreprocessorContext};
use crate::book::{Book, BookItem};
+use log::{error, warn};
+use once_cell::sync::Lazy;
const ESCAPE_CHAR: char = '\\';
const MAX_LINK_NESTED_DEPTH: usize = 10;
@@ -408,19 +410,20 @@ impl<'a> Iterator for LinkIter<'a> {
fn find_links(contents: &str) -> LinkIter<'_> {
// lazily compute following regex
// r"\\\{\{#.*\}\}|\{\{#([a-zA-Z0-9]+)\s*([^}]+)\}\}")?;
- lazy_static! {
- static ref RE: Regex = Regex::new(
+ static RE: Lazy<Regex> = Lazy::new(|| {
+ Regex::new(
r"(?x) # insignificant whitespace mode
- \\\{\{\#.*\}\} # match escaped link
- | # or
- \{\{\s* # link opening parens and whitespace
- \#([a-zA-Z0-9_]+) # link type
- \s+ # separating whitespace
- ([^}]+) # link target path and space separated properties
- \}\} # link closing parens"
+ \\\{\{\#.*\}\} # match escaped link
+ | # or
+ \{\{\s* # link opening parens and whitespace
+ \#([a-zA-Z0-9_]+) # link type
+ \s+ # separating whitespace
+ ([^}]+) # link target path and space separated properties
+ \}\} # link closing parens",
)
- .unwrap();
- }
+ .unwrap()
+ });
+
LinkIter(RE.captures_iter(contents))
}