Skip to content

Commit aa5f868

Browse files
fix link block html (#1282)
1 parent b987f83 commit aa5f868

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

pgml-dashboard/src/utils/markdown.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -742,16 +742,24 @@ pub fn mkdocs<'a>(root: &'a AstNode<'a>, arena: &'a Arena<AstNode<'a>>) -> anyho
742742
_ => "".to_string(),
743743
};
744744

745-
for _ in 0..fragment.len() + 1 {
745+
// Remove fragment and the fragment identifier #.
746+
for _ in 0..fragment.len()
747+
+ match fragment.len() {
748+
0 => 0,
749+
_ => 1,
750+
}
751+
{
746752
link.url.pop();
747753
}
748754

755+
// Remove file path to make this a relative url.
749756
if link.url.ends_with(".md") {
750757
for _ in 0..".md".len() {
751758
link.url.pop();
752759
}
753760
}
754761

762+
// Add fragment path that matches toc links.
755763
let header_id = TocLink::from_fragment(fragment).id;
756764
for c in header_id.chars() {
757765
link.url.push(c)
@@ -1041,15 +1049,9 @@ pub fn mkdocs<'a>(root: &'a AstNode<'a>, arena: &'a Arena<AstNode<'a>>) -> anyho
10411049
info_block_close_items.push(None);
10421050
parent.detach();
10431051
} else if text.contains("{% content-ref url=") {
1044-
let url = parser(text.as_ref(), r#"url=""#);
1045-
10461052
let n = arena.alloc(Node::new(RefCell::new(Ast::new(NodeValue::HtmlInline(format!(
1047-
r#"<div>
1048-
<a href="{}">
1049-
<div>"#,
1050-
url.unwrap(),
1053+
r#"<div>"#,
10511054
))))));
1052-
10531055
let parent = node.parent().unwrap();
10541056

10551057
info_block_close_items.push(None);
@@ -1096,14 +1098,8 @@ pub fn mkdocs<'a>(root: &'a AstNode<'a>, arena: &'a Arena<AstNode<'a>>) -> anyho
10961098
parent.detach();
10971099
} else if text.starts_with("{% endcontent-ref %}") {
10981100
let parent = node.parent().unwrap();
1099-
11001101
let n = arena.alloc(Node::new(RefCell::new(Ast::new(NodeValue::HtmlInline(
1101-
r#"
1102-
</div>
1103-
</a>
1104-
</div>
1105-
"#
1106-
.to_string(),
1102+
r#"</div>"#.to_string(),
11071103
)))));
11081104

11091105
parent.insert_after(n);

0 commit comments

Comments
 (0)
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