-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New build system (including 3rd party languages) (#2312)
* new build process for brownser/cdn/node * detect 3rd party languages * can run markup tests in 3rd party bundles * can run detect tests for 3rd party bundles * remove gear/bluebird dependencies * add readme and license to CDN build * CDN embeds no languages vs all if no languages are passed in the list * change lib/highlight to lib/core for requiring the lib * (chore)package CDN for NPM * .min now, not .pack Co-authored-by: Eric Prud'hommeaux <eric+github@w3.org>
- Loading branch information
1 parent
608b6fc
commit b64b008
Showing
219 changed files
with
1,336 additions
and
2,852 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ __pycache__ | |
node_modules | ||
.project | ||
yarn.lock | ||
extra/ | ||
|
||
# editors | ||
.idea/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// whole codebase isn't ES8 yet, but our tests and some things are | ||
// whole codebase isn't ES8/9 yet, but our tests and some things are | ||
{ | ||
"esversion": 8 | ||
"esversion": 9, | ||
"node": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Highlight.js CDN Assets | ||
|
||
[](https://packagephobia.now.sh/result?p=highlight.js) | ||
|
||
**This package contains only the CDN build assets of highlight.js.** | ||
|
||
This may be what you want if you'd like to install the pre-built distributable highlight.js client-side assets via NPM. If you're wanting to use highlight.js mainly on the server-side you likely want the [highlight.js][1] package instead. | ||
|
||
To access these files via CDN:<br> | ||
https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@latest/build/ | ||
|
||
**If you just want a single .js file with the common languages built-in: | ||
<https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@latest/build/highlight.min.js>** | ||
|
||
--- | ||
|
||
## Highlight.js | ||
|
||
Highlight.js is a syntax highlighter written in JavaScript. It works in | ||
the browser as well as on the server. It works with pretty much any | ||
markup, doesn’t depend on any framework, and has automatic language | ||
detection. | ||
|
||
If you'd like to read the full README:<br> | ||
<https://github.com/highlightjs/highlight.js/blob/master/README.md> | ||
|
||
## License | ||
|
||
Highlight.js is released under the BSD License. See [LICENSE][7] file | ||
for details. | ||
|
||
## Links | ||
|
||
The official site for the library is at <https://highlightjs.org/>. | ||
|
||
The Github project may be found at: <https://github.com/highlightjs/highlight.js> | ||
|
||
Further in-depth documentation for the API and other topics is at | ||
<http://highlightjs.readthedocs.io/>. | ||
|
||
Authors and contributors are listed in the [AUTHORS.txt][8] file. | ||
|
||
[1]: https://www.npmjs.com/package/highlight.js | ||
[7]: https://github.com/highlightjs/highlight.js/blob/master/LICENSE | ||
[8]: https://github.com/highlightjs/highlight.js/blob/master/AUTHORS.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
*This is a work in progress. PRs to improve these docs (or the process) would be welcome.* | ||
|
||
## Getting Started | ||
|
||
So you'd like to create and share you're own language for Highlight.js. That's awesome. | ||
|
||
Take a look at some of the real-life examples first: | ||
|
||
- https://github.com/highlightjs/highlightjs-cypher | ||
- https://github.com/highlightjs/highlightjs-robots-txt | ||
|
||
Basically: | ||
|
||
- Checkout highlight-js from github... | ||
- 3rd party languages are placed into the `extra` directory | ||
|
||
So if you had a `xzy` language you'd create an `extra/xyz` folder, and that would be your language module. All paths below are relative to that. | ||
|
||
- Put your language file in `src/languages/name.js`. | ||
- Add detect tests in `test/detect/`. | ||
- Add markup tests in `test/markup/`. | ||
- Perhaps add a `package.json` for Node. | ||
- Add a nice `README`. | ||
- Don't forget to add a `LICENSE`. | ||
|
||
|
||
## Testing | ||
|
||
To test (detect and markup tests), just build highlight.js and test it. Your tests should be automatically run with the suite: | ||
|
||
``` | ||
node ./tools/build.js -t node | ||
npm run test | ||
``` | ||
|
||
If you can't get the auto-detect tests passing you should simply turn off auto-detection for your language in it's definition with `disableAutodetect: true`. Auto-detection is hard. | ||
|
||
|
||
## Packaging | ||
|
||
Users will expect your package to include a minified CDN distributable in your `dist` folder. This should allow them to add the module to their website with only a single `<script>` tag. | ||
|
||
Luckily, the highlight.js CDN build process will build this file for you automatically. You can simply commit it to your repo, and done. | ||
|
||
``` | ||
node ./tools/build.js -t cdn | ||
... | ||
Building extra/highlightjs-xyz/dist/xyz.min.js. | ||
... | ||
``` | ||
|
||
|
||
## Publishing | ||
|
||
We're happy to host 3rd party module repos inside the `highlightjs` organization on GitHub. Just file an issue and request a repository. | ||
|
||
Publish it to NPM also if you'd like. This will make it much easier for anyone using Node to use it. | ||
|
||
When your language module is ready create a PR that adds it to the `README.md` file in the list of languages. | ||
|
||
|
||
## The Future | ||
|
||
More work could be done on: | ||
|
||
- Allowing you to ONLY run your own tests, not the whole suite. | ||
- Allowing you to maintain a 3rd party module WITHOUT it being inside of a `highlight-js` checkout (this requires discussion though) | ||
- Simply make some easier tools or scripts to simply the existing process. | ||
- Improving these docs |
Oops, something went wrong.