rustdoc: Don't escape characters between backticks

This commit is contained in:
Brian Anderson 2012-03-06 20:16:53 -08:00
parent ae5ea85c36
commit e536e8a933

View File

@ -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, "<", "&lt;");
let s = str::replace(s, ">", "&gt;");
@ -22,3 +36,9 @@ fn test() {
assert escape("\"") == "&quot;";
assert escape("<>&\"") == "&lt;&gt;&amp;&quot;";
}
#[test]
fn should_not_escape_characters_in_backticks() {
// Markdown will quote things in backticks itself
assert escape("<`<`<`<`<") == "&lt;`<`&lt;`<`&lt;";
}