summaryrefslogtreecommitdiffstats
path: root/vendor/mdbook/src/preprocess
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /vendor/mdbook/src/preprocess
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/mdbook/src/preprocess')
-rw-r--r--vendor/mdbook/src/preprocess/cmd.rs1
-rw-r--r--vendor/mdbook/src/preprocess/index.rs10
-rw-r--r--vendor/mdbook/src/preprocess/links.rs25
-rw-r--r--vendor/mdbook/src/preprocess/mod.rs3
4 files changed, 21 insertions, 18 deletions
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<P: AsRef<Path>>(readme_path: P, index_path: P) {
}
fn is_readme_file<P: AsRef<Path>>(path: P) -> bool {
- lazy_static! {
- static ref RE: Regex = Regex::new(r"(?i)^readme$").unwrap();
- }
+ static RE: Lazy<Regex> = 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<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))
}
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)]