This repository is a new language template to use as a starting point when creating a language definition for highlightjs. See highlightjs.org for more information about highlight.js.
Before you start:
- Check supported languages to see if your proposed language/syntax/grammar is already supported. If there is an existing implementation, it may be more helpful to contribute to the existing repository.
- Read 3rd party quick start to learn more about the requirements and process to contributing a new syntax.
This is a GitHub repository template for defining a new language for use with highlightjs. It is designed to be the starting point for creating a new repository to define a new language syntax contribution. Follow Language definition guide to learn how to define a new language.
Steps:
- Create a new repository from this template.
- Update
package.json. - Install the dependencies with
npm install. - Rename
src/languages/your-language.jsto your language/syntax/grammar name. Search and replace in this repository all occurrences ofyour-languagewith your language name, including file and folder names. Follow the Language definition guide to learn how to implement it. Typically we start with an existing grammar that is close and alter that JavaScript code to parse your new grammar. - We provided a simple test framework to help you get started quickly.
You can use this and update it to help test your grammar, or remove it and replace it with your preferred testing framework.
Rename and update the unit test
spec/language-spec.jsto test your new syntax. Edittest/markup/your-language/sample.txtto cover specific test cases for your syntax. The code doesn't have to be real working code, but it does have to fully test your grammar constructs and keywords. Edittest/markup/your-language/sample.expect.txtto hold the anticipated correct highlighting HTML. Edittest/detect/your-language/sample.txtto include a validation case for auto-detecting your language. Also change the folder path fromyour-languageto the matching name for your language. - Run the test with
npm test. - Delete
README.mdand then renameBLANK_README.mdtoREADME.md. Complete the placeholder sections to explain how to use your grammar. You can use sample README as a guide. - As a final step, follow the testing procedure in 3RD_PARTY_QUICK_START to test your language against the highlight.js test and detect framework.
Once your syntax is working as expected and your README is complete, create a syntax request issue and indicate the details about your new grammar for the maintainers to review.
This template is released under the MIT License. See LICENSE file for details. You may choose a different license based on your requirements.
This is open source software, all contributions are welcome.