Need help updating the highlight.js mode for Elm

I noticed that the highlight.js mode for Elm does some weird stuff on the main website. The current version lives here.

I started trying to trim it down and ended up with:

function(hljs) {
  return {
    keywords:
      'let in if then else case of where module import exposing ' +
      'type alias as port effect',
    contains: [
      hljs.COMMENT('--', '$'),
      hljs.COMMENT('{-', '-}', { contains: ['self'] }),
      {
        className: 'string',
        begin: '"""', end: '"""'
      },
      hljs.APOS_STRING_MODE
      hljs.QUOTE_STRING_MODE,
      hljs.C_NUMBER_MODE,
      {
        className: 'upper',
        begin: '\\b[A-Z][\\w]*',
        relevance: 0
      },
      {begin: '->|<-'} // No markup, relevance booster
    ],
    illegal: /;/
  };
}

I think it’d be cool to try to match what some of the editors do a bit more. E.g. List in types is a different color than Nothing in expressions.

Can someone try to go the rest of the way with this? Don’t worry about coordinating. Just do it if it seems fun.

Note: Please share your progress on discourse before sending a PR to the maintainers of highlight.js. They have limited time, and we should not flood them with more work when we can do the filtering more efficiently within Elm world first.

5 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.