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 1 commit
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
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
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" ]
67 changes: 65 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,66 @@
# 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. You'll 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

To provide a deterministic build system we rely on Docker.

### How to build

The build process is rather complicated, take a look at <https://github.com/highlightjs/highlight.js/blob/main/extra/3RD_PARTY_QUICK_START.md>.

The docker container allows to automate the necessary setup.

```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
```

### How to run tests

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

## 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