From 59073b1084dcf12cc69239e4278479a23f0a83d4 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 23 Mar 2021 18:36:45 -0700 Subject: [PATCH] Add page title override: {{#title My Title}} (#1381) * Add page title override: {{#title My Title}} * Document {{#title}} in guide --- src/preprocess/links.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/preprocess/links.rs b/src/preprocess/links.rs index 757887f1..4fe06a9d 100644 --- a/src/preprocess/links.rs +++ b/src/preprocess/links.rs @@ -139,6 +139,7 @@ enum LinkType<'a> { RustdocInclude(PathBuf, RangeOrAnchor), Title(&'a str), Template(PathBuf, HashMap), + Title(&'a str), } #[derive(PartialEq, Debug, Clone)] @@ -211,6 +212,7 @@ impl<'a> LinkType<'a> { LinkType::RustdocInclude(p, _) => Some(return_relative_path(base, &p)), LinkType::Title(_) => None, LinkType::Template(p, _) => Some(return_relative_path(base, &p)), + LinkType::Title(_) => None, } } } @@ -401,6 +403,7 @@ impl<'a> Link<'a> { LinkType::Title(title) => { *chapter_title = title.to_owned(); Ok(String::new()) + } LinkType::Template(ref pat, ref dict) => { let target = base.join(pat); fs::read_to_string(&target) @@ -423,6 +426,11 @@ impl<'a> Link<'a> { ) }) } + + LinkType::Title(title) => { + *chapter_title = title.to_owned(); + Ok(String::new()) + } } } }