Once I've created a Rouge parser, what more is required to highlight a new language with Jekyll?

I lead a team developing a novel language, and we are interested in launching a blog about it using Jekyll. I’m brand-new to Jekyll and reasonably ignorant of Ruby. I understand that:

My question before I get too much further is: once I’ve developed a Rouge parser for my language locally, can I start using it to deploy Jekyll webpages with code in our language highlighted immediately? Or are additional steps required first, such as:

  • getting my parser merged into the Rouge repository as a PR?
  • getting it merged into Rouge and then waiting for a new Rouge release?
  • getting something merged/changed in Jekyll itself? (in my local copy only? in the Jekyll repo?)
  • something else / more?

Thanks very much.

How are you hosting your Jekyll-based blog? I ask because some Jekyll hosting is very restricted (i.e. Github Pages), while others are more open and allow for more customized code (Netlify, traditional web-hosting, Github-Action based builds, etc).

If you’re using a more open hosting scheme, then I don’t think there would an immediate need to have your new Lexer merged into the official Rouge (and then wait for a Rouge release to be picked up by Jekyll, etc). Instead, I believe you could load your new Lexer via a mechanism like a forked Rouge Gem referenced in the Gemfile or maybe a Jekyll plugin to load a local Lexer class. This way you could get started locally and quickly.

@chuckhoupt: Good question, and I can see why that would matter. I’ve been planning to generate html from the Jekyll and host it on our (traditional) website, so it sounds like I should be able to get things rolling by doing the local mods that you suggest (assuming I can sort them out). If you or others have tips (or pointers to existing documentation) on how to do that, I’m sure I would benefit from it.

Great, so you can use custom Gems, plugins, etc. I’ve never run a customized Rouge before, but here one way it might be done (untested educated guess):

Custom Gem from Git fork

Start you’re own fork of Rouge, add new Lexer, and then include the forked Gem in the blog’s Gemfile. Something like:

gem 'rouge', git: 'https://github.com/myuser/my-fork-of-rouge'

After running bundle install, I believe Jekyll will then use the forked Rouge. Here’s the Bundler doc on using Git repos:

2 Likes