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() {