";
- prev_line_hidden = true;
- }
- result += &caps[1];
- if &caps[2] != " " {
+ if &caps[2] == "#" {
+ result += &caps[1];
result += &caps[2];
- }
- result += &caps[3];
- } else {
- if prev_line_hidden {
+ result += &caps[3];
+ result += "\n";
+ continue;
+ } else if &caps[2] != "!" && &caps[2] != "[" {
+ result += "";
+ result += &caps[1];
+ if &caps[2] != " " {
+ result += &caps[2];
+ }
+ result += &caps[3];
+ result += "\n";
result += "";
- prev_line_hidden = false;
+ continue;
}
- result += line;
}
+ result += line;
result += "\n";
}
result
@@ -749,7 +751,7 @@ mod tests {
fn add_playpen() {
let inputs = [
("x()
",
- "\n#![allow(unused_variables)]\nfn main() {\nx()\n}\n
"),
+ "\n#![allow(unused_variables)]\nfn main() {\nx()\n}\n
"),
("fn main() {}
",
"fn main() {}\n
"),
("let s = \"foo\n # bar\n\";
",
@@ -757,9 +759,11 @@ mod tests {
("let s = \"foo\n ## bar\n\";
",
"let s = \"foo\n # bar\n\";\n
"),
("let s = \"foo\n # bar\n#\n\";
",
- "let s = \"foo\n bar\n\n\";\n
"),
- ("let s = \"foo\n # bar\n#\n\";
",
- "let s = \"foo\n bar\n\n\";\n
"),
+ "let s = \"foo\n bar\n\n\";\n
"),
+ ("let s = \"foo\n # bar\n\";
",
+ "let s = \"foo\n bar\n\";\n
"),
+ ("#![no_std]\nlet s = \"foo\";\n #[some_attr]
",
+ "#![no_std]\nlet s = \"foo\";\n #[some_attr]\n
"),
];
for (src, should_be) in &inputs {
let got = add_playpen_pre(