Ignore multiline literals when detecting code language
This commit is contained in:
1 parent
6ea6bf20a8
commit
34b71c040e
2 files changed
+8
-1
No files matched your search
@@ -66,7 +66,9 @@ QString detectCodeLanguage(QStringView source) {
|
||||
return language;
|
||||
}
|
||||
// Убираем строки и комментарии перед поиском конструкций, сохраняя границы строк.
|
||||
static const QRegularExpression ignored(R"re(/\*[\s\S]*?(?:\*/|$)|<!--[\s\S]*?(?:-->|$)|//[^\n]*|"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*')re");
|
||||
static const QRegularExpression ignored(
|
||||
R"re(/\*[\s\S]*?(?:\*/|$)|<!--[\s\S]*?(?:-->|$)|//[^\n]*|"""[\s\S]*?(?:"""|$))re"
|
||||
R"re(|`(?:\\[\s\S]|[^`\\])*(?:`|$)|"(?:\\.|[^"\\\n])*(?:"|$)|'(?:\\.|[^'\\\n])*(?:'|$))re");
|
||||
QString code = sample;
|
||||
auto matches = ignored.globalMatch(sample);
|
||||
while (matches.hasNext()) {
|
||||
|
||||
Reference in new issue
Block a user