From b06d22f389941d5cc647f02099f6535a2cae62df Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Aug 09 2019 03:21:51 +0000 Subject: Sync improvements to syntax highlighting from highlightjs-rpm-specfile This file was upstreamed in a different form as highlightjs-rpm-specfile, and that version was improved to cover many of the new features in RPM 4.14 and RPM 4.15. This change syncs those improvements back into our version. In addition, the default syntax highlight override now uses the upstream name for the rpm specfile syntax highlighter. Signed-off-by: Neal Gompa --- diff --git a/pagure/static/vendor/highlight.js/spec.js b/pagure/static/vendor/highlight.js/spec.js index 8cece2b..2e60c0d 100644 --- a/pagure/static/vendor/highlight.js/spec.js +++ b/pagure/static/vendor/highlight.js/spec.js @@ -2,6 +2,7 @@ Language: rpm-specfile Description: RPM Specfile Author: Ryan Lerch +Contributors: Neal Gompa */ /* @@ -9,24 +10,24 @@ Author: Ryan Lerch 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) { +hljs.registerLanguage("rpm-specfile", function(e) { return { - aliases: ['spec'], + aliases: ['rpm', 'spec', 'rpm-spec', 'specfile'], 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|RemovePathPostfixes|Build[a-z]+|[a-z]+Arch|Auto[a-z]+)(:)/, + b: /^(Name|BuildRequires|BuildConflicts|Version|Release|Epoch|Summary|Group|License|Packager|Vendor|Icon|URL|Distribution|Prefix|Patch[0-9]*|Source[0-9]*|Requires\(?[a-z]*\)?|[a-zA-Z]+Req|Obsoletes|Recommends|Suggests|Supplements|Enhances|Provides|Conflicts|RemovePathPostfixes|Build[a-zA-Z]+|[a-zA-Z]+Arch|Auto[a-zA-Z]+)(:)/, }, { cN: "keyword", - b: /(%)(?:package|prep|build|description|install|clean|changelog|check|pre[a-z]*|post[a-z]*|trigger[a-z]*|files)/, + b: /(%)(?:package|prep|generate_buildrequires|sourcelist|patchlist|build|description|install|verifyscript|clean|changelog|check|pre[a-z]*|post[a-z]*|trigger[a-z]*|files)/, }, { cN: "link", - b: /(%)(if|else|endif)/, + b: /(%)(if|ifarch|ifnarch|ifos|ifnos|elif|elifarch|elifos|else|endif)/, }, { cN: "link", diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index 632e987..faf08c9 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -97,7 +97,7 @@ def get_syntax_alias(filename): """ override_rules = pagure_config.get( - "SYNTAX_ALIAS_OVERRIDES", {".spec": "specfile", ".patch": "diff"} + "SYNTAX_ALIAS_OVERRIDES", {".spec": "rpm-specfile", ".patch": "diff"} ) fn, fn_ext = splitext(filename)