From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- vendor/mdbook/src/preprocess/cmd.rs | 1 + vendor/mdbook/src/preprocess/index.rs | 10 +++++----- vendor/mdbook/src/preprocess/links.rs | 25 ++++++++++++++----------- vendor/mdbook/src/preprocess/mod.rs | 3 +-- 4 files changed, 21 insertions(+), 18 deletions(-) (limited to 'vendor/mdbook/src/preprocess') diff --git a/vendor/mdbook/src/preprocess/cmd.rs b/vendor/mdbook/src/preprocess/cmd.rs index c47fd5d22..149dabda5 100644 --- a/vendor/mdbook/src/preprocess/cmd.rs +++ b/vendor/mdbook/src/preprocess/cmd.rs @@ -1,6 +1,7 @@ use super::{Preprocessor, PreprocessorContext}; use crate::book::Book; use crate::errors::*; +use log::{debug, trace, warn}; use shlex::Shlex; use std::io::{self, Read, Write}; use std::process::{Child, Command, Stdio}; diff --git a/vendor/mdbook/src/preprocess/index.rs b/vendor/mdbook/src/preprocess/index.rs index fd60ad4da..004b7eda6 100644 --- a/vendor/mdbook/src/preprocess/index.rs +++ b/vendor/mdbook/src/preprocess/index.rs @@ -1,10 +1,11 @@ use regex::Regex; use std::path::Path; -use crate::errors::*; - use super::{Preprocessor, PreprocessorContext}; use crate::book::{Book, BookItem}; +use crate::errors::*; +use log::warn; +use once_cell::sync::Lazy; /// A preprocessor for converting file name `README.md` to `index.md` since /// `README.md` is the de facto index file in markdown-based documentation. @@ -67,9 +68,8 @@ fn warn_readme_name_conflict>(readme_path: P, index_path: P) { } fn is_readme_file>(path: P) -> bool { - lazy_static! { - static ref RE: Regex = Regex::new(r"(?i)^readme$").unwrap(); - } + static RE: Lazy = Lazy::new(|| Regex::new(r"(?i)^readme$").unwrap()); + RE.is_match( path.as_ref() .file_stem() 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 = 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)) } diff --git a/vendor/mdbook/src/preprocess/mod.rs b/vendor/mdbook/src/preprocess/mod.rs index 894e20035..df01a3dbf 100644 --- a/vendor/mdbook/src/preprocess/mod.rs +++ b/vendor/mdbook/src/preprocess/mod.rs @@ -12,12 +12,11 @@ use crate::book::Book; use crate::config::Config; use crate::errors::*; +use serde::{Deserialize, Serialize}; use std::cell::RefCell; use std::collections::HashMap; use std::path::PathBuf; -use serde::{Deserialize, Serialize}; - /// Extra information for a `Preprocessor` to give them more context when /// processing a book. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -- cgit v1.2.3