Skip to content

Commit bd3a13b

Browse files
committed
---
yaml --- r: 14687 b: refs/heads/try c: e536e8a h: refs/heads/master i: 14685: e893af6 14683: a8bf5e3 14679: 7b5e03c 14671: fdc8c37 14655: 98d253c v: v3
1 parent a8e0483 commit bd3a13b

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: ae5ea85c361e2b383b01c1101d731843795ea0cb
5+
refs/heads/try: e536e8a93354cd2b4e5ecc87eb0fdf30b835859c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/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)