From 7ba5b155327c49fee1a264bad2cdb9da75276124 Mon Sep 17 00:00:00 2001 From: Modestas Valauskas Date: Fri, 26 Dec 2025 23:04:40 +0100 Subject: [PATCH] Add support for triple-quoted raw strings in Dart lexer Dart supports multi-line raw strings using triple quotes: - r'''...''' - r"""...""" The existing rules only handled single-quoted raw strings, causing triple-quoted variants to be incorrectly tokenized. The new rules must come before the single-quoted rules because Rouge matches the first matching rule, and we need to match the longer triple-quote pattern before the shorter one. --- lib/rouge/lexers/dart.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/rouge/lexers/dart.rb b/lib/rouge/lexers/dart.rb index 7b4123bc5a..7dcffc474a 100644 --- a/lib/rouge/lexers/dart.rb +++ b/lib/rouge/lexers/dart.rb @@ -45,6 +45,8 @@ class Dart < RegexLexer rule %r(/\*.*?\*/)m, Comment::Multiline rule %r/"/, Str, :dqs rule %r/'/, Str, :sqs + rule %r/r""".*?"""/m, Str::Other + rule %r/r'''.*?'''/m, Str::Other rule %r/r"[^"]*"/, Str::Other rule %r/r'[^']*'/, Str::Other rule %r/##{id}*/i, Str::Symbol