Contributing

discord open issues help welcome issues good first issue

Contents

Welcome

Hello and welcome to Highlight.js. We're a code-highlighting engine, but you probably knew that already. If you are considering contributing to Highlight.js this document will be hopefully be a helpful resource.

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

You do not have to be a programmer. There are many ways to contribute::

Our Philosophy

Highlight.js makes an effort to keep the core engine small, simple, and easy to use. Our goal with core is to support the highlighting "happy path" and let plug-ins handle edge cases.

Prerequisites

Requesting Features

Feature requests are always welcome. If the feature doesn't belong in the core library then we're always happy to suggest how you might go about developing a plug-in.

If you're thinking of contributing a feature first open an issue to discuss whether the feature belongs in core vs a plug-in. Often this is a great way to get implementation tips or links to prior discussions on the topic often with additional context, etc.

Language Requests

If you wish we supported a language we don't, first read On requesting new languages. TL;DR The core team generally doesn't implement new languages - so there is no point opening requests. Please consider trying to contribute the language yourself or enlisting the help of a friend.

Reporting Issues

If you find a bug or think of an improvement, feel free to open an issue.

Fixing Issues (PRs)

If you feel comfortable with the prerequisites, you can grab any issue marked "good first issue". Or feel free to jump in with thoughts or comments on any of the more complex issues.

In a nutshell

If you're new to contributing to open-source, have a look at this GitHub Guide. It explains the general process of GitHub collaboration.

Highlight.js is developed in JavaScript, so you'll need the usual suspects: Node.js, npm (or yarn), git, etc. You'll likely start by forking the repository on GitHub and then cloning it locally.

  1. Fork this project on GitHub.
  2. Clone it locally git clone git@github.com:username/highlight.js.git.
  3. Create a work branch (git checkout -b my-branch).
  4. Commit your changes (git commit -m 'my changes').
  5. Build and Test
  6. Push the branch (git push origin my-branch).
  7. Open a Pull Request from your fork back to this repository.

Keep in Mind

Please open a new issue before your PR (or join the discussion on the existing issue), so we can explore and discuss the topic at hand. Your time is important, and we need to be sure it's well-spent.

Before you start coding, keep these tips in mind:

After you make your changes, we have some housekeeping tasks for you - like updating the changelog. The PR template will be your guide.

Build and Test

When contributing a PR (that doesn't make any specific changes to browser features) it's usually sufficient to build and test only the Node.js build. Our CI process will guarantee that the browser build is still green.

Testing the Node.js build:

npm run build
npm run test

The browser library is built and tested separately:

npm run build-browser
npm run test-browser

There's a developer tool (tools/developer.html) for visually testing and debugging language definitions. It requires a browser build to be present. (ie npm run build-browser first)

For more details, see Building and Testing in our docs.