-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
Starting a discussion for an official 3rd party grammar format/spec (directory structure, how modules are exported, etc). I've been working on adding support to the build process for seamlessly building 3rd party grammars. The idea being that you just check them out:
mkdir extra
cd extra
git clone [email protected]:highlightjs/highlightjs-robots-txt.git
git clone [email protected]:highlightjs/highlightjs-tsql.git
And then building "just works":
node ./tools/build.js -t browser :common tsql robots-txt
And high-level grammar testing just works (detect tests, markup tests, etc) in context of the whole test suite. Just run tests like normal. The tests for extra languages are bundled with the extra languages, but magically "just work".
In looking at the existing 3rd party stuff it seems we have two major types of layouts. I think perhaps we could support both.
The slightly flatter npm package:

A more "bundled"/traditional layout:

One alternative to supporting both is to always prefer/require the bundled layout. I prefer this layout slightly as it makes it easier to add multiple languages to a single "package/repo". For example you might bundle Python, Python REPL... bundled layout gives you an easy way to do that (keeping the same directly structure we use internally). Also if we ever again decided to pull a 3rd party into the core library it'd be trivial to do with the bundled layout as it'd just essentially be copying files from one repo to another.
As to how NPM would work with bundled layout I'd suggest an index.js that simply required the individual modules and exported a hash of them by name:
# index.js
const python = require("./src/languages/python")
const pythonREPL = require("./src/languages/python_repl")
module.exports = { python, pythonREPL }Thoughts?