From 97c35f7a556a2b0debd4d66d65af8ba2fc916ce8 Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Jul 27 2018 08:12:07 +0000 Subject: [PATCH 1/2] add basic specfile syntax highlighting in the new commit view --- diff --git a/pagure/static/vendor/highlight.js/spec.js b/pagure/static/vendor/highlight.js/spec.js new file mode 100644 index 0000000..7cb6144 --- /dev/null +++ b/pagure/static/vendor/highlight.js/spec.js @@ -0,0 +1,58 @@ +/* +Language: specfile +Description: RPM Specfile +Author: Ryan Lerch +*/ + +/* + The built version of highlight.js truncates a bunch of these + variables. see https://github.com/isagalaev/highlight.js/blob/905119aad47d4bb3d4fbaa14df7598034dccb6a3/tools/utility.js + for the list of things it replaces +*/ +hljs.registerLanguage("specfile", function(e) { + return { + aliases: ['spec'], + c:[ + hljs.HCM, + hljs.ASM, + hljs.QSM, + { + cN: "type", + b: /^(Name|BuildRequires|Version|Release|Epoch|Summary|Group|License|Packager|Vendor|Icon|URL|Distribution|Prefix|Patch[0-9]*|Source[0-9]*|Requires\(?[a-z]*\)?|[a-z]+Req|Obsoletes|Suggests|Provides|Conflicts|Build[a-z]+|[a-z]+Arch|Auto[a-z]+)(:)/, + }, + { + cN: "keyword", + b: /(%)(?:package|prep|build|description|install|clean|changelog|check|pre[a-z]*|post[a-z]*|trigger[a-z]*|files)/, + }, + { + cN: "link", + b: /(%)(if|else|endif)/, + }, + { + cN: "link", + b: /%\{_/, + e: /}/, + }, + { + cN: "symbol", + b: /%\{\?/, + e: /}/, + }, + { + cN: "link font-weight-bold", + b: /%\{/, + e: /}/, + }, + { + cN: "link font-weight-bold", + b: /%/, + e: /[ \t\n]/ + }, + { + cN: "symbol font-weight-bold", + b: /^\* (Mon|Tue|Wed|Thu|Fri|Sat|Sun)/, + e: /$/, + }, + ] +}; +}); diff --git a/pagure/templates/commit.html b/pagure/templates/commit.html index 5817da2..ddf311e 100644 --- a/pagure/templates/commit.html +++ b/pagure/templates/commit.html @@ -488,6 +488,9 @@ src="{{ url_for('static', filename='vendor/highlight.js/highlight.pack.js') }}"> + From ab33562d54db644cac2f1de902663b7f7f1e4722 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 27 2018 08:12:07 +0000 Subject: [PATCH 2/2] Small tweaks to the spec highlighting file based on the review Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/static/vendor/highlight.js/spec.js b/pagure/static/vendor/highlight.js/spec.js index 7cb6144..8cece2b 100644 --- a/pagure/static/vendor/highlight.js/spec.js +++ b/pagure/static/vendor/highlight.js/spec.js @@ -1,5 +1,5 @@ /* -Language: specfile +Language: rpm-specfile Description: RPM Specfile Author: Ryan Lerch */ @@ -18,7 +18,7 @@ hljs.registerLanguage("specfile", function(e) { hljs.QSM, { cN: "type", - b: /^(Name|BuildRequires|Version|Release|Epoch|Summary|Group|License|Packager|Vendor|Icon|URL|Distribution|Prefix|Patch[0-9]*|Source[0-9]*|Requires\(?[a-z]*\)?|[a-z]+Req|Obsoletes|Suggests|Provides|Conflicts|Build[a-z]+|[a-z]+Arch|Auto[a-z]+)(:)/, + b: /^(Name|BuildRequires|Version|Release|Epoch|Summary|Group|License|Packager|Vendor|Icon|URL|Distribution|Prefix|Patch[0-9]*|Source[0-9]*|Requires\(?[a-z]*\)?|[a-z]+Req|Obsoletes|Suggests|Provides|Conflicts|RemovePathPostfixes|Build[a-z]+|[a-z]+Arch|Auto[a-z]+)(:)/, }, { cN: "keyword",