Skip to content

Instantly share code, notes, and snippets.

@jxramos
Last active January 21, 2023 00:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jxramos/2a95a5f51c1e0614995df6e6ff738d0b to your computer and use it in GitHub Desktop.
Save jxramos/2a95a5f51c1e0614995df6e6ff738d0b to your computer and use it in GitHub Desktop.
Notes for implementing the starlark syntax support for highlight.js

Highlight.js Notes

Developer Notes for language contributions

have your grammar as a 3rd party language module

Create a language grammar definition file, a file which defines a function accepting a reference to the library and returning a language object.

Main repository

Table of all supported languages

Documentation page

New language request redirect

Python Language in Highlight.js

https://github.com/highlightjs/highlight.js/blob/master/src/languages/python.js

Evolution of commits to python.js https://github.com/highlightjs/highlight.js/commits/122e363f2b257488d67c2fd2202f855e22190280/src/languages/python.js

Starlark Notes

Starlark Language

Starlark Rules & Tools

TODO update the above mark down with the future highlight.js implementation

Starlark Coverage in vscode

https://github.com/bazelbuild/vscode-bazel/blob/12c20773c5bbbdbbd30cc393c414622059c05537/package.json#L193-L221 This direct json file should it be converted to a highlight.js equivalent would solve the missing piece for bazel syntax highlight support needed for Reviewable capabilities.

VS Code's tokenization engine is powered by TextMate grammars. TextMate grammars are a structured collection of regular expressions and are written as a plist (XML) or JSON files. https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide#tokenization

The nitty gritty language definitions, seemingly more nuanced that highlight JS, seems more structured and semantic and actually leans on hierarchical structure by leveraging existing https://github.com/bazelbuild/vscode-bazel/blob/master/syntaxes/starlark.tmLanguage.json https://github.com/bazelbuild/vscode-bazel/blob/master/syntaxes/starlark.configuration.json

Reviewable Support

Reviewable/Reviewable#753

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment