Skip to content

Commit

Permalink
Support raw strings in Rust lexer
Browse files Browse the repository at this point in the history
Fixes #1398
  • Loading branch information
KamilaBorowska committed Jan 20, 2020
1 parent a821e3f commit d521376
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rouge/lexers/rust.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def macro_closed?
)x, Str::Char

rule %r/"/, Str, :string
rule %r/r(#*)".*?"\1/m, Str

# numbers
dot = /[.][0-9_]+/
Expand Down
8 changes: 8 additions & 0 deletions spec/visual/samples/rust
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ println!("a\\");
println!("a\n");
println!("a\"b");
println!("a\'");
println!(r"");
println!(r"\n\");
println!(r#"a"b\"#);
println!(r##"r#""#"##);
println!(r###"r##"r#""#"##"###);
println!(r#"
"New line in a raw string"
"#);

debug!("test %?", a.b);
debug!("test %u", a.c);
Expand Down

0 comments on commit d521376

Please sign in to comment.