File tree 5 files changed +25
-5
lines changed
5 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,8 @@ struct PageLayout<'a> {
71
71
display_krate_version_extra : & ' a str ,
72
72
}
73
73
74
+ pub ( crate ) use crate :: html:: render:: sidebar:: filters;
75
+
74
76
pub ( crate ) fn render < T : Print , S : Print > (
75
77
layout : & Layout ,
76
78
page : & Page < ' _ > ,
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ mod tests;
30
30
31
31
mod context;
32
32
mod print_item;
33
- mod sidebar;
33
+ pub ( crate ) mod sidebar;
34
34
mod span_map;
35
35
mod type_layout;
36
36
mod write_shared;
Original file line number Diff line number Diff line change @@ -76,6 +76,22 @@ impl<'a> Link<'a> {
76
76
}
77
77
}
78
78
79
+ pub ( crate ) mod filters {
80
+ use crate :: { html:: escape:: EscapeBodyTextWithWbr , html:: render:: display_fn} ;
81
+ use askama:: { Html , MarkupDisplay } ;
82
+ use std:: fmt:: Display ;
83
+ pub ( crate ) fn wrapped < T > ( v : T ) -> askama:: Result < MarkupDisplay < Html , impl Display > >
84
+ where
85
+ T : Display ,
86
+ {
87
+ let string = v. to_string ( ) ;
88
+ Ok ( MarkupDisplay :: new_safe (
89
+ display_fn ( move |f| EscapeBodyTextWithWbr ( & string) . fmt ( f) ) ,
90
+ Html ,
91
+ ) )
92
+ }
93
+ }
94
+
79
95
pub ( super ) fn print_sidebar ( cx : & Context < ' _ > , it : & clean:: Item , buffer : & mut Buffer ) {
80
96
let blocks: Vec < LinkBlock < ' _ > > = match * it. kind {
81
97
clean:: StructItem ( ref s) => sidebar_struct ( cx, it, s) ,
Original file line number Diff line number Diff line change 98
98
</ a > {# #}
99
99
{% endif %}
100
100
< h2 > {# #}
101
- < a href ="{{page.root_path|safe}}{{display_krate_with_trailing_slash|safe}}index.html "> {{display_krate}}</ a > {# #}
101
+ < a href ="{{page.root_path|safe}}{{display_krate_with_trailing_slash|safe}}index.html "> {{display_krate|wrapped|safe }}</ a > {# #}
102
102
{% if !display_krate_version_number.is_empty() %}
103
103
< span class ="version "> {{+ display_krate_version_number}}</ span >
104
104
{% endif %}
Original file line number Diff line number Diff line change 1
1
{% if !title.is_empty() %}
2
2
< h2 class ="location "> {# #}
3
- < a href ="# "> {{title_prefix}}{{title}}</ a > {# #}
3
+ < a href ="# "> {{title_prefix}}{{title|wrapped|safe }}</ a > {# #}
4
4
</ h2 >
5
5
{% endif %}
6
6
< div class ="sidebar-elems ">
@@ -15,12 +15,14 @@ <h2 class="location"> {# #}
15
15
{% for block in blocks %}
16
16
{% if block.should_render() %}
17
17
{% if !block.heading.name.is_empty() %}
18
- < h3 > < a href ="#{{block.heading.href|safe}} "> {{block.heading.name}}</ a > </ h3 >
18
+ < h3 > < a href ="#{{block.heading.href|safe}} "> {# #}
19
+ {{block.heading.name|wrapped|safe}} {# #}
20
+ </ a > </ h3 > {# #}
19
21
{% endif %}
20
22
{% if !block.links.is_empty() %}
21
23
< ul class ="block{% if !block.class.is_empty() +%} {{+block.class}}{% endif %} ">
22
24
{% for link in block.links %}
23
- < li > < a href ="#{{link.href|safe}} "> {{link.name}}</ a > </ li >
25
+ < li > < a href ="#{{link.href|safe}} "> {{link.name|wrapped|safe }}</ a > </ li >
24
26
{% endfor %}
25
27
</ ul >
26
28
{% endif %}
You can’t perform that action at this time.
0 commit comments