home ~ socials ~ projects ~ rss

Make A New Prism Syntax Highlighting Langage Definition

April 2023

This is what I did to make a starting point for the Neopolitan syntax highlighter for the example page.

  1. Fork prism from it's repo
  2. Clone a local copy
  3. Run npm install in the cloned directory
  4. Make a new file for your language at

the content below here isn't working prolerly in the praser

components/prism-alfa.js

With contents like:

Prism.languages['some-language'] = {
  'token-name': {
    pattern: /regex/
  },
};

Edit the components.json file in the root of the projct to add your language like:

"some-language": {
  "title": "Some Language",
  "owner": "Your GitHub name"
}

If you're going to try to submit it, make sure it's sorted properly in the alphabetical section below the defaults

  • Build the project with

    npm run build

  • Start the server with

    npm start

  • Open the test page on your local machine

    http://127.0.0.1:8080/test.html

  • Figure your language and click on it. There won't be any highlights yet
  • Update the components/prism-some-language.js file you created above using >this page> https://prismjs.com/extending.html> for guidance

    Note that you don't need to restart the server if all your doing is editing that file. Reloading the page in the browser is all that's necessary.

  • When you have the highlights the way you like them you can pull down a customize version of prism with them in it by going to your local copy of the download page and getting them from there:

http://localhost:8080/download.html

end of line
Share link:
https://www.alanwsmith.com/en/2o/wf/ij/yb/?make-a-new-prism-syntax-highlighting-langage-definition