2021-08-28 13:31:58 +02:00
|
|
|
From be348f64eda257ae0af1f89552548d3e8eca3688 Mon Sep 17 00:00:00 2001
|
2020-07-03 00:28:39 +02:00
|
|
|
From: Luke Granger-Brown <git@lukegb.com>
|
|
|
|
Date: Thu, 2 Jul 2020 23:02:43 +0100
|
2021-04-06 11:27:20 +02:00
|
|
|
Subject: [PATCH 3/7] Syntax highlight rules.pl
|
2020-07-03 00:28:39 +02:00
|
|
|
|
|
|
|
---
|
2020-11-27 18:39:35 +01:00
|
|
|
.../diff/gr-syntax-layer/gr-syntax-layer.ts | 13 ++++++++++++-
|
|
|
|
1 file changed, 12 insertions(+), 1 deletion(-)
|
2020-07-03 00:28:39 +02:00
|
|
|
|
2020-11-27 18:39:35 +01:00
|
|
|
diff --git a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts
|
2021-08-28 13:31:58 +02:00
|
|
|
index 2762ccc625..598e14589f 100644
|
2020-11-27 18:39:35 +01:00
|
|
|
--- a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts
|
|
|
|
+++ b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts
|
2021-04-06 11:27:20 +02:00
|
|
|
@@ -103,6 +103,10 @@ const LANGUAGE_MAP = new Map<string, string>([
|
2020-11-27 18:39:35 +01:00
|
|
|
]);
|
2020-06-14 13:37:23 +02:00
|
|
|
const ASYNC_DELAY = 10;
|
|
|
|
|
2020-11-27 18:39:35 +01:00
|
|
|
+const FILENAME_OVERRIDES = new Map<string, string>([
|
|
|
|
+ ['rules.pl', 'prolog'],
|
|
|
|
+]);
|
2020-06-14 13:37:23 +02:00
|
|
|
+
|
2020-11-27 18:39:35 +01:00
|
|
|
const CLASS_SAFELIST = new Set<string>([
|
|
|
|
'gr-diff gr-syntax gr-syntax-attr',
|
|
|
|
'gr-diff gr-syntax gr-syntax-attribute',
|
2021-04-06 11:27:20 +02:00
|
|
|
@@ -241,10 +245,17 @@ export class GrSyntaxLayer implements DiffLayer {
|
2020-06-14 13:37:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-27 18:39:35 +01:00
|
|
|
+ _basename(filename: string): string {
|
2020-06-14 13:37:23 +02:00
|
|
|
+ const pieces = filename.split(/\//);
|
|
|
|
+ return pieces[pieces.length-1];
|
|
|
|
+ }
|
|
|
|
+
|
2020-11-27 18:39:35 +01:00
|
|
|
_getLanguage(metaInfo: DiffFileMetaInfo) {
|
2020-06-14 13:37:23 +02:00
|
|
|
// The Gerrit API provides only content-type, but for other users of
|
|
|
|
// gr-diff it may be more convenient to specify the language directly.
|
2020-11-27 18:39:35 +01:00
|
|
|
- return metaInfo.language ?? LANGUAGE_MAP.get(metaInfo.content_type);
|
2021-08-28 13:31:58 +02:00
|
|
|
+ return metaInfo.language ??
|
2020-11-27 18:39:35 +01:00
|
|
|
+ FILENAME_OVERRIDES.get(this._basename(metaInfo.name)) ??
|
|
|
|
+ LANGUAGE_MAP.get(metaInfo.content_type);
|
2020-06-14 13:37:23 +02:00
|
|
|
}
|
|
|
|
|
2020-11-27 18:39:35 +01:00
|
|
|
/**
|
2020-07-03 00:28:39 +02:00
|
|
|
--
|
2021-08-28 13:31:58 +02:00
|
|
|
2.32.0
|
2020-07-03 00:28:39 +02:00
|
|
|
|