#53 Add (external) highlightjs-rpm-specfile?
Opened 2 years ago by ferdnyc. Modified 2 years ago

highlight.js doesn't have built-in support for RPM spec file highlighting, but there's an external highlightjs-rpm-specfile project that does provide support as an add-on. It seems we're not using that, currently.

Could we? Having our sample specfiles display with syntax highlighting in the Packaging Guidelines, especially, feels like a clear win. Especially if it just requires a couple of extra <script> tags added to the page template(s).

With that add-on support installed, specfile highlighting should be accessible from Asciidoc using any of the following block tags:

[source, rpm-specfile]
[source, rpm]
[source, spec]
[source, rpm-spec]
[source, specfile]
----
# Specfile syntax
# …
----

specfile highlighting should be accessible from Asciidoc using any of the following block tags

Or, maybe would be available under whatever name(s) we choose to register it under. I think I was thrown off by the fact that the highlight.js SUPPORTED_LANGUAGES.md lists all of those names as RPM spec file "aliases", and assumed they were all available by default.

This is now added on staging. Let me know if that works for you and I'll see to get it deployed on prod as well.

@darknao

I have a pending PR to update the packaging guidelines with source tags for all of its specfile code blocks (something like 50 of them), which would give us a test page for this.

That's still waiting to be merged, but @oturpe was kind enough to point out that there is one block in one document that's already tagged. It's in the Packaging Tutorial: GNU Hello doc; the third code block on the page (in the "Inside a Spec File" section) is tagged [source,RPMSpec].

I checked that same page on the staging server, and highlighting still isn't successful — the browser console shows two error messages on page load:

> Falling back to no-highlight mode for this block.
> Could not find the language 'RPMSpec', did you forget to load/include a language module?

It's possible that's happening because RPMSpec isn't one of the configured language tags for the specfile highlighting plugin. I forgot to ask what name(s) it's configured to match on, before opening my PR (where I used rpm-spec throughout).

Or it could be that the plugin still isn't loading on the staging server.

Could you take a look? AdvThanks!ance

It's possible that's happening because RPMSpec isn't one of the configured language tags for the specfile highlighting plugin. I forgot to ask what name(s) it's configured to match on, before opening my PR (where I used rpm-spec throughout).

That, exactly.
I made sure all the tags from your initial comment were included (which are the default ones), and RPMSpec is not one of them.

@darknao Thanks, i'll open another PR to fix the tagging in that file! :laughing:

With that PR merged, that tutorial doc is now syntax-highlighted in staging, and the tagged blocks declare their format as "RPM-SPEC" on hover.

Thanks, @darknao, looks great! From my POV it seems ready to be enabled on production, too.

Actually, now that I say that... I've already discovered one styling bug, and come up with a few other suggested styling tweaks for the highlight.js rpm-specfile mode, all of which I've submitted as PRs to the upstream repo. So, maybe we should hold off a bit for the resolution of those, and import the fixed version instead.

Login to comment on this ticket.

Metadata