rustdoc: Don't escape characters between backticks
This commit is contained in:
parent
ae5ea85c36
commit
e536e8a933
@ -7,6 +7,20 @@ fn mk_pass() -> pass {
|
||||
}
|
||||
|
||||
fn escape(s: str) -> str {
|
||||
let parts = str::split_char(s, '`');
|
||||
let i = 0;
|
||||
let parts = vec::map(parts) {|part|
|
||||
i += 1;
|
||||
if i % 2 != 0 {
|
||||
escape_(part)
|
||||
} else {
|
||||
part
|
||||
}
|
||||
};
|
||||
ret str::connect(parts, "`");
|
||||
}
|
||||
|
||||
fn escape_(s: str) -> str {
|
||||
let s = str::replace(s, "&", "&");
|
||||
let s = str::replace(s, "<", "<");
|
||||
let s = str::replace(s, ">", ">");
|
||||
@ -22,3 +36,9 @@ fn test() {
|
||||
assert escape("\"") == """;
|
||||
assert escape("<>&\"") == "<>&"";
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_not_escape_characters_in_backticks() {
|
||||
// Markdown will quote things in backticks itself
|
||||
assert escape("<`<`<`<`<") == "<`<`<`<`<";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user