File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,20 @@ fn mk_pass() -> pass {
7
7
}
8
8
9
9
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 {
10
24
let s = str:: replace ( s, "&" , "&" ) ;
11
25
let s = str:: replace ( s, "<" , "<" ) ;
12
26
let s = str:: replace ( s, ">" , ">" ) ;
@@ -22,3 +36,9 @@ fn test() {
22
36
assert escape ( "\" " ) == """ ;
23
37
assert escape ( "<>&\" " ) == "<>&"" ;
24
38
}
39
+
40
+ #[ test]
41
+ fn should_not_escape_characters_in_backticks ( ) {
42
+ // Markdown will quote things in backticks itself
43
+ assert escape ( "<`<`<`<`<" ) == "<`<`<`<`<" ;
44
+ }
You can’t perform that action at this time.
0 commit comments