@@ -742,16 +742,24 @@ pub fn mkdocs<'a>(root: &'a AstNode<'a>, arena: &'a Arena<AstNode<'a>>) -> anyho
742
742
_ => "" . to_string ( ) ,
743
743
} ;
744
744
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
+ {
746
752
link. url . pop ( ) ;
747
753
}
748
754
755
+ // Remove file path to make this a relative url.
749
756
if link. url . ends_with ( ".md" ) {
750
757
for _ in 0 ..".md" . len ( ) {
751
758
link. url . pop ( ) ;
752
759
}
753
760
}
754
761
762
+ // Add fragment path that matches toc links.
755
763
let header_id = TocLink :: from_fragment ( fragment) . id ;
756
764
for c in header_id. chars ( ) {
757
765
link. url . push ( c)
@@ -1041,15 +1049,9 @@ pub fn mkdocs<'a>(root: &'a AstNode<'a>, arena: &'a Arena<AstNode<'a>>) -> anyho
1041
1049
info_block_close_items. push ( None ) ;
1042
1050
parent. detach ( ) ;
1043
1051
} else if text. contains ( "{% content-ref url=" ) {
1044
- let url = parser ( text. as_ref ( ) , r#"url=""# ) ;
1045
-
1046
1052
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>"# ,
1051
1054
) ) ) ) ) ) ;
1052
-
1053
1055
let parent = node. parent ( ) . unwrap ( ) ;
1054
1056
1055
1057
info_block_close_items. push ( None ) ;
@@ -1096,14 +1098,8 @@ pub fn mkdocs<'a>(root: &'a AstNode<'a>, arena: &'a Arena<AstNode<'a>>) -> anyho
1096
1098
parent. detach ( ) ;
1097
1099
} else if text. starts_with ( "{% endcontent-ref %}" ) {
1098
1100
let parent = node. parent ( ) . unwrap ( ) ;
1099
-
1100
1101
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 ( ) ,
1107
1103
) ) ) ) ) ;
1108
1104
1109
1105
parent. insert_after ( n) ;
0 commit comments