File tree Expand file tree Collapse file tree 1 file changed +26
-24
lines changed
src/renderer/html_handlebars/helpers Expand file tree Collapse file tree 1 file changed +26
-24
lines changed Original file line number Diff line number Diff line change @@ -108,32 +108,32 @@ impl HelperDef for RenderToc {
108
108
}
109
109
110
110
// Link
111
- let path_exists = if let Some ( path) = item. get ( "path" ) {
112
- if !path. is_empty ( ) {
113
- out. write ( "<a href=\" " ) ?;
114
-
115
- let tmp = Path :: new ( item. get ( "path" ) . expect ( "Error: path should be Some(_)" ) )
116
- . with_extension ( "html" )
117
- . to_str ( )
118
- . unwrap ( )
119
- // Hack for windows who tends to use `\` as separator instead of `/`
120
- . replace ( "\\ " , "/" ) ;
121
-
122
- // Add link
123
- out. write ( & utils:: fs:: path_to_root ( & current_path) ) ?;
124
- out. write ( & tmp) ?;
125
- out. write ( "\" " ) ?;
126
-
127
- if path == & current_path {
128
- out. write ( " class=\" active\" " ) ?;
129
- }
130
-
131
- out. write ( ">" ) ?;
132
- true
133
- } else {
134
- false
111
+ let path_exists = if let Some ( path) =
112
+ item. get ( "path" )
113
+ . and_then ( |p| if p. is_empty ( ) { None } else { Some ( p) } )
114
+ {
115
+ out. write ( "<a href=\" " ) ?;
116
+
117
+ let tmp = Path :: new ( item. get ( "path" ) . expect ( "Error: path should be Some(_)" ) )
118
+ . with_extension ( "html" )
119
+ . to_str ( )
120
+ . unwrap ( )
121
+ // Hack for windows who tends to use `\` as separator instead of `/`
122
+ . replace ( "\\ " , "/" ) ;
123
+
124
+ // Add link
125
+ out. write ( & utils:: fs:: path_to_root ( & current_path) ) ?;
126
+ out. write ( & tmp) ?;
127
+ out. write ( "\" " ) ?;
128
+
129
+ if path == & current_path {
130
+ out. write ( " class=\" active\" " ) ?;
135
131
}
132
+
133
+ out. write ( ">" ) ?;
134
+ true
136
135
} else {
136
+ out. write ( "<div>" ) ?;
137
137
false
138
138
} ;
139
139
@@ -165,6 +165,8 @@ impl HelperDef for RenderToc {
165
165
166
166
if path_exists {
167
167
out. write ( "</a>" ) ?;
168
+ } else {
169
+ out. write ( "</div>" ) ?;
168
170
}
169
171
170
172
// Render expand/collapse toggle
You can’t perform that action at this time.
0 commit comments