Skip to content

Commit

Permalink
feat: better labels & code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ravsii committed Nov 4, 2024
1 parent 86009f0 commit fdf4c4d
Show file tree
Hide file tree
Showing 9 changed files with 1,541 additions and 1,210 deletions.
10 changes: 6 additions & 4 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,18 @@ module.exports = grammar({

block: $ => seq("{", repeat($.declaration), "}"),
label: $ => choice(
$._label_codeblock,
repeat1($._label_base),
token(seq('"', /.*/, '"')),
),

_label_codeblock: _ => choice(
seq(repeat1("|"), /[^\|]+/, repeat1("|")),
),

_label_base: $ => choice(
$._ident_base,
"\\",
":",
".",
"-"
token(prec(PREC.label, /[\\\:\.\-\%\_#&]+/)) // idk how to make it better
),

connection_refference: $ => seq(
Expand Down
25 changes: 8 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,6 @@
"prebuildify": "^6.0.1"
},
"repository": "https://github.com/ravsii/tree-sitter-d2",
"tree-sitter": [
{
"scope": "source.d2",
"file-types": [
"d2"
],
"injection-regex": "d2"
}
],
"scripts": {
"install": "node-gyp-build",
"prestart": "tree-sitter build --wasm",
"start": "tree-sitter playground",
"test": "node --test bindings/node/*_test.js"
},
"files": [
"grammar.js",
"binding.gyp",
Expand All @@ -44,5 +29,11 @@
"queries/*",
"src/**",
"*.wasm"
]
}
],
"scripts": {
"install": "node-gyp-build",
"prestart": "tree-sitter build --wasm",
"start": "tree-sitter playground",
"test": "node --test bindings/node/*_test.js"
}
}
56 changes: 42 additions & 14 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fdf4c4d

Please sign in to comment.