commit 68e385c4d50b9325fa81102205d491090e2d75b4 Author: Neal Gompa Date: Mon Jul 8 04:43:29 2019 -0400 Initial commit of RPM Specfile syntax definition and demo sample Co-authored-by: Neal Gompa Co-authored-by: Ryan Lerch diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d81758f --- /dev/null +++ b/LICENSE @@ -0,0 +1,28 @@ +Copyright (c) 2019, Neal Gompa, Ryan Lerch, and contributors +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..c9f3b11 --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +`highlight.js` syntax definition for RPM spec files. + +For more about highlight.js, see https://highlightjs.org/ + +For more about RPM, see https://rpm.org/ + +### Usage + +Simply include the `highlight.js` script package in your webpage or node app, load up this module and apply it to `hljs`. + +If you're not using a build system and just want to embed this in your webpage: + +```html + + + +``` + +If you're using webpack / rollup / browserify / node: + +```javascript +var hljs = require('highlightjs'); +var hljsDefineRpmSpecfile = require('highlightjs-rpm-specfile'); + +hljsDefineRpmSpecfile(hljs); +hljs.initHighlightingOnLoad(); +``` + +### Advanced + +This is a pretty simple package, the only thing you might want to do differently is name the language something other than `rpm-specfile`. If you want to do this, simply `import { definer } from 'highlightjs-rpm-specfile';` and use it like: `hljs.registerLanguage('othername', definer);`. diff --git a/default.txt b/default.txt new file mode 100644 index 0000000..a773eb5 --- /dev/null +++ b/default.txt @@ -0,0 +1,56 @@ +Name: hello +Version: 2.10 +Release: 1%{?dist} +Summary: The "Hello World" program from GNU +Group: Unspecified +License: GPLv3+ +URL: https://www.gnu.org/software/hello/ +Source: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.gz + +BuildRequires: gettext + + +%description +The GNU Hello program produces a familiar, friendly greeting. + +Yes, this is another implementation of the classic program that prints +"Hello, world!" when you run it. + +However, unlike the minimal version often seen, GNU Hello processes its +argument list to modify its behavior, supports greetings in many languages, +and so on. + +The primary purpose of GNU Hello is to demonstrate how to write other programs +that do these things; it serves as a model for GNU coding standards and +GNU maintainer practices. + + +%prep +# Unpacks the sources and applies patches... +%autosetup + + +%build +# Configures the source tree and builds it... +%configure +%make_build + + +%install +# Installs to the buildroot to for wrapping in a package... +%make_install +%find_lang %{name} +rm -f %{buildroot}/%{_infodir}/dir + + +%files -f %{name}.lang +%doc ChangeLog NEWS README TODO +%license COPYING AUTHORS THANKS +%{_bindir}/hello +%{_mandir}/man1/hello.1* +%{_infodir}/hello.info* + + +%changelog +* Fri Nov 14 00:00:00 UTC 2014 Ty Coon - 2.10-1 +- Initial version of the package diff --git a/rpm-specfile.js b/rpm-specfile.js new file mode 100644 index 0000000..194917b --- /dev/null +++ b/rpm-specfile.js @@ -0,0 +1,77 @@ +/** + * highlight.js RPM spec file syntax highlighting definition + * + * @see https://github.com/highlightjs/highlight.js + * + * @package highlightjs-rpm-specfile + * @author Ryan Lerch , Neal Gompa + * @since 2019-07-08 + * @license magnet:?xt=urn:btih:c80d50af7d3db9be66a4d0a86db0286e4fd33292&dn=bsd-3-clause.txt BSD-3-Clause + * + * Language: rpm-specfile + * Description: RPM Specfile + * Author: Ryan Lerch + * Contributors: Neal Gompa + * Category: config + * Requires: bash.js + * Website: https://rpm.org/ + **/ + +var module = module ? module : {}; // shim for browser use + +function hljsDefineRpmSpecfile(hljs) { + return { + aliases: ['rpm', 'spec', 'rpm-spec', 'specfile'], + contains: [ + hljs.COMMENT('%dnl'), + hljs.HASH_COMMENT_MODE, + hljs.APOS_STRING_MODE, + hljs.QUOTE_STRING_MODE, + { + className: "type", + begin: /^(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|Recommends|Suggests|Supplements|Enhances|Provides|Conflicts|RemovePathPostfixes|Build[a-z]+|[a-z]+Arch|Auto[a-z]+)(:)/, + }, + { + className: "keyword", + begin: /(%)(?:package|prep|generate_buildrequires|sourcelist|patchlist|build|description|install|verifyscript|clean|changelog|check|pre[a-z]*|post[a-z]*|trigger[a-z]*|files)/, + }, + { + className: "link", + begin: /(%)(if|ifarch|ifnarch|ifos|ifnos|elif|elifarch|elifos|else|endif)/, + }, + { + className: "link", + begin: /%\{_/, + end: /}/, + }, + { + className: "symbol", + begin: /%\{\?/, + end: /}/, + }, + { + className: "link font-weight-bold", + begin: /%\{/, + end: /}/, + }, + { + className: "link font-weight-bold", + begin: /%/, + end: /[ \t\n]/ + }, + { + className: "symbol font-weight-bold", + begin: /^\* (Mon|Tue|Wed|Thu|Fri|Sat|Sun)/, + end: /$/, + }, + ] + }; +} + +module.exports = function(hljs) { + hljs.registerLanguage('rpm-specfile', hljsDefineRpmSpecfile); +}; + +module.exports.definer = hljsDefineRpmSpecfile; + +/* @license-end */