Skip to content

Commit e536e8a

Browse files
committed
rustdoc: Don't escape characters between backticks
1 parent ae5ea85 commit e536e8a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/rustdoc/html_escape_pass.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ fn mk_pass() -> pass {
77
}
88

99
fn escape(s: str) -> str {
10+
let parts = str::split_char(s, '`');
11+
let i = 0;
12+
let parts = vec::map(parts) {|part|
13+
i += 1;
14+
if i % 2 != 0 {
15+
escape_(part)
16+
} else {
17+
part
18+
}
19+
};
20+
ret str::connect(parts, "`");
21+
}
22+
23+
fn escape_(s: str) -> str {
1024
let s = str::replace(s, "&", "&");
1125
let s = str::replace(s, "<", "&lt;");
1226
let s = str::replace(s, ">", "&gt;");
@@ -22,3 +36,9 @@ fn test() {
2236
assert escape("\"") == "&quot;";
2337
assert escape("<>&\"") == "&lt;&gt;&amp;&quot;";
2438
}
39+
40+
#[test]
41+
fn should_not_escape_characters_in_backticks() {
42+
// Markdown will quote things in backticks itself
43+
assert escape("<`<`<`<`<") == "&lt;`<`&lt;`<`&lt;";
44+
}

0 commit comments

Comments
 (0)