Add rpm module to highlightjs?

Apparently highlightjs, due to lack of core maintainers, is asking for new language support to be added via separate repositories. (See

One such separate repo is GitHub - highlightjs/highlightjs-rpm-specfile, for highlighting the RPM specfile syntax. Could you please add that to Discourse? It would be hugely helpful for Fedora!

1 Like

We’ve been adding non default languages as theme-component, even added a dedicated API hook for this.


Okay, cool — is there an example I can crib from?


I packaged one quickly for you, can you try it out?


Thank you!!! And, yep — right after lunch. :slight_smile:


Yes, seems to work!

From what I can see, it seems to auto-detect and work. If I want


to work, I seem to need to put rpm-specfile in the “highlighted languages” site setting. Is that correct?

Also, if I put rpm there, that also works. Is this expected, or is it one of those things where I want to happen is happening for the wrong reason? :slight_smile:

1 Like

Hmm, but it doesn’t seem to be complete… I’m getting bold for sections like %description and %prep, purple for macros like %{?dist}, and # comments get grey italics. So far so good.

But looking at discourse-highlightjs-rpm/rpm-highlightjs.js at main · discourse/discourse-highlightjs-rpm · GitHub, I would expect Name:, Release: etc, to be highlighted in some way too, as well as %if and %endif — but those aren’t.

1 Like

Are those comments directed to the Discourse integration or to the quality of the highlighter itself?

I only copy and pasted the definition from the link you provided in the OP into a Discourse-compatible theme-component, so the capabilities of it are still the original ones.

1 Like

I’m seeing those things in the code in your[1] repo, so I expect that they’d work, but they do not appear to be highlighted in DIscourse. I don’t know if that’s a problem with the highlighter module, the Discourse implementation of that, or the theme component.

  1. this is not meant to be a blame statement, like “it’s your repo”… just to be clear :slight_smile: ↩︎

(For the record have bookmarked this to check what should work when I get a chance.)

1 Like

@falco — I had some time to look at this. Using Firefox’s built-in inspector, I can see that it properly add spans with classes hljs-type, hljs-keyword, etc. But if I look over on the styles side, I see a .hljs but not .hljs-type — only .hljs-keyword and .hljs-comment (the ones that work) seem to be there.

Oh, and .hljs-string also works. But I see some of the others in css … any idea what’s going on?

FWIW, this still does not work. (Sad face emoji)

1 Like

Looks like core was missing styling for the .hljs-type class. I’ve cleaned things up in this PR.

Exact colours will depend on your theme, but here’s an example RPM file:


Yep, works now. Thank you!

1 Like

This topic was automatically closed after 3 days. New replies are no longer allowed.