Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start rewrite #8

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: ci

permissions:
pull-requests: write
issues: write
repository-projects: write
contents: write

on:
pull_request:
push:
branches: [main, rewrite]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make test-docker
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,30 @@ typings/

# next.js build output
.next

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would all these excludes for root/AFP be necessary? Just curious.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iuse the template from https://marketplace.visualstudio.com/items?itemName=codezombiech.gitignore and they seem to work for me just fine - of course its 90% not relevant for the project but they are good defaults

.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
Expand Down
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM node:alpine

WORKDIR /highlightjs/

RUN apk add git

RUN git clone --depth 1 --branch 11.7.0 https://github.com/highlightjs/highlight.js.git

RUN cd /highlightjs/highlight.js && npm install

COPY package.json /highlightjs/sclang/package.json
COPY package-lock.json /highlightjs/sclang/package-lock.json

RUN cd sclang && npm install

ENV ONLY_EXTRA=true

RUN ln -s /highlightjs/sclang /highlightjs/highlight.js/extra/sclang

RUN cd /highlightjs/highlight.js node ./tools/build.js -t node

WORKDIR "/highlightjs/sclang"

COPY . /highlightjs/sclang

CMD [ "/bin/sh", "-c", "cd /highlightjs/highlight.js && node ./tools/build.js -t cdn" ]
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.PHONY: docker-container
docker-container:
docker build -t sc-highlightjs .

.PHONY: dev
dev:
python3 -m http.server

.PHONY: build-docker
build-docker: docker-container
mkdir -p dist
docker run --volume "`pwd`/dist:/highlightjs/sclang/dist" sc-highlightjs

.PHONY: test-docker
test-docker: docker-container
docker run sc-highlightjs npm run test

.PHONY: clean
clean:
rm -rf dist
73 changes: 71 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,72 @@
# highlightjs-supercollider
# supercollider - a sclang language grammar for highlightjs

SuperCollider module for highlight.js
![license](https://badgen.net/badge/license/MIT/blue)

> sclang is the language of the audio synthesis platform SuperCollider

The implementation details are lent from <https://github.com/highlightjs/highlightjs-cypher> and <https://github.com/highlightjs/highlightjs-robots-txt>.

## Usage

Simply include the Highlight.js library in your webpage or Node app, then load this module.

### Static website or simple usage

Simply load the module after loading Highlight.js.
It is possible to use the minified version found in the `dist` directory. This module is just a CDN build of the language, so it will register itself as the Javascript is loaded.

```html
<script type="text/javascript" src="/path/to/highlight.min.js"></script>
<script type="text/javascript" src="/path/to/sclang.min.js"></script>
<script type="text/javascript">
hljs.highlightAll();
</script>
```

### Using directly from the UNPKG CDN

TODO

### With Node or another build system

If you're using Node / Webpack / Rollup / Browserify, etc, simply require the language module, then register it with Highlight.js.

```javascript
var hljs = require('highlight.js');
var hljsSclang = require('highlightjs-sclang');

hljs.registerLanguage("sclang", hljsSclang);
hljs.highlightAll();
```

## Development

Start a local development server via `python3 -m http.server` and access the `test.html` file on <http://127.0.0.1:8000/test/test.html>.
After this modify the `src/sclang.js` file and reload the browser.

After the adjustments have been made, it is necessary to build a minified version before it can be published.

### How to build

As the build process is rather complex (see <https://github.com/highlightjs/highlight.js/blob/main/extra/3RD_PARTY_QUICK_START.md>) this repository relies on Docker to create deterministic builds on any platform.

```shell
docker build -t sc-highlightjs .
# mount the artifacts dist folder from container to host
docker run --volume "$(pwd)/dist:/highlightjs/sclang/dist" sc-highlightjs
```

Alternatively use `make build-docker`.

### How to run tests

```shell
docker build -t sc-highlightjs .
docker run sc-highlightjs npm run test
```

Alternatively use `make test-docker`.

## License

MIT
16 changes: 16 additions & 0 deletions dist/sclang.es.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*! `sclang` grammar compiled for Highlight.js 11.7.0 */
var hljsGrammar=(()=>{"use strict";return e=>{const a=e.COMMENT("/\\*","\\*/",{
contains:[e.C_BLOCK_COMMENT_MODE]});return{
aliases:["supercollider","sc","sclang"],keywords:{
keyword:"arg classvar|10 const super this var|2",
built_in:"false inf|2 nil|2 true thisFunction|10 thisFunctionDef|10 thisMethod|10 thisProcess|10 thisThread|10 currentEnvironment|10 topEnvironment|10"
},contains:[{className:"type",begin:/\b(Synth|SynthDef)\b/,relevance:10},{
className:"type",begin:"\\b[A-Z]\\w*\\b",relevance:0},{className:"meta",
begin:"_\\w+",relevance:0},{className:"literal",begin:"\\$\\\\?."},{
className:"title",begin:"~\\w+",relevance:2},{className:"number",variants:[{
begin:"\\b\\d+r[0-9a-zA-Z]*(\\.[0-9A-Z]*)?\\b"},{begin:/\b\d+(s+|b+|[sb]\d+)\b/
},{begin:"\\b((\\d+(\\.\\d+)?([eE][-+]?\\d+)?(pi)?)|pi)\\b"},{
begin:"\\b0x[a-fA-F0-9]+\\b"}],relevance:0},{className:"string",variants:[{
begin:"\\\\\\w+",relevance:5},e.APOS_STRING_MODE,{begin:"[A-Za-z_]\\w*\\:",
relevance:0}]},e.QUOTE_STRING_MODE,e.C_LINE_COMMENT_MODE,a],
illegal:/\bclass\s+[A-Z]/}}})();export default hljsGrammar;
16 changes: 16 additions & 0 deletions dist/sclang.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*! `sclang` grammar compiled for Highlight.js 11.7.0 */
(()=>{var e=(()=>{"use strict";return e=>{const n=e.COMMENT("/\\*","\\*/",{
contains:[e.C_BLOCK_COMMENT_MODE]});return{
aliases:["supercollider","sc","sclang"],keywords:{
keyword:"arg classvar|10 const super this var|2",
built_in:"false inf|2 nil|2 true thisFunction|10 thisFunctionDef|10 thisMethod|10 thisProcess|10 thisThread|10 currentEnvironment|10 topEnvironment|10"
},contains:[{className:"type",begin:/\b(Synth|SynthDef)\b/,relevance:10},{
className:"type",begin:"\\b[A-Z]\\w*\\b",relevance:0},{className:"meta",
begin:"_\\w+",relevance:0},{className:"literal",begin:"\\$\\\\?."},{
className:"title",begin:"~\\w+",relevance:2},{className:"number",variants:[{
begin:"\\b\\d+r[0-9a-zA-Z]*(\\.[0-9A-Z]*)?\\b"},{begin:/\b\d+(s+|b+|[sb]\d+)\b/
},{begin:"\\b((\\d+(\\.\\d+)?([eE][-+]?\\d+)?(pi)?)|pi)\\b"},{
begin:"\\b0x[a-fA-F0-9]+\\b"}],relevance:0},{className:"string",variants:[{
begin:"\\\\\\w+",relevance:5},e.APOS_STRING_MODE,{begin:"[A-Za-z_]\\w*\\:",
relevance:0}]},e.QUOTE_STRING_MODE,e.C_LINE_COMMENT_MODE,n],
illegal:/\bclass\s+[A-Z]/}}})();hljs.registerLanguage("sclang",e)})();
Loading