From c6540792ebd0d9a8da02dd55bd319021dae9e428 Mon Sep 17 00:00:00 2001 From: Montana Low Date: Fri, 8 Dec 2023 19:05:05 -0800 Subject: [PATCH] gitbook page link cleanup --- pgml-dashboard/src/utils/markdown.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pgml-dashboard/src/utils/markdown.rs b/pgml-dashboard/src/utils/markdown.rs index aba253366..c5be4fd49 100644 --- a/pgml-dashboard/src/utils/markdown.rs +++ b/pgml-dashboard/src/utils/markdown.rs @@ -917,6 +917,7 @@ pub fn mkdocs<'a>(root: &'a AstNode<'a>, arena: &'a Arena>) -> anyho iter_nodes(root, &mut |node| { match &mut node.data.borrow_mut().value { + // Strip .md extensions that gitbook includes in page link urls &mut NodeValue::Link(ref mut link) => { let path = Path::new(link.url.as_str()); @@ -932,6 +933,21 @@ pub fn mkdocs<'a>(root: &'a AstNode<'a>, arena: &'a Arena>) -> anyho } &mut NodeValue::Text(ref mut text) => { + + // Strip .md extensions that gitbook includes in page link text + if text.ends_with(".md") { + if let Some(parent) = node.parent() { + match parent.data.borrow().value { + NodeValue::Link(ref link) => { + for _ in 0..".md".len() { + text.pop(); + } + } + _ => {} + } + } + } + if text.starts_with("=== \"") { let mut parent = { match node.parent() { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy