diff --git a/examples/classes.d2 b/examples/classes.d2 deleted file mode 100644 index 6ca1dcf..0000000 --- a/examples/classes.d2 +++ /dev/null @@ -1,34 +0,0 @@ -direction: right -classes: { - load balancer { - label: load\nbalancer - width: 100 - height: 200 - style: { - stroke-width: 0 - fill: "#44C7B1" - shadow: true - border-radius: 5 - } - } - unhealthy: { - style: { - fill: "#FE7070" - stroke: "#F69E03" - } - } -} - -web traffic -> web lb -web lb.class: load balancer - -web lb -> api1 -web lb -> api2 -web lb -> api3 - -api2.class: unhealthy - -api1 -> cache lb -api3 -> cache lb - -cache lb.class: load balancer diff --git a/examples/flipt.d2 b/examples/flipt.d2 new file mode 100644 index 0000000..e898f94 --- /dev/null +++ b/examples/flipt.d2 @@ -0,0 +1,94 @@ +classes: { + block: { + style: { + font: mono + stroke-dash: 2 + stroke: black + border-radius: 5 + } + } + grid-block: { + label: "" + style: { + fill: "#6EF759" + border-radius: 5 + } + width: 40 + height: 40 + } +} + +direction: right + +Build: { + class: block + style: { + fill: "#FFEBCD" + } + source -> linked + source -> assets + linked -> artifacts + assets -> artifacts + artifacts: "" { + shape: image + icon: https://icons.terrastruct.com/essentials/220-layers.svg + width: 100 + height: 100 + } +} + +Test: { + class: block + style: { + fill: "#ffc9d6" + } + grid: "" { + grid-columns: 4 + grid-rows: 4 + 1.class: grid-block + 2.class: grid-block + 3.class: grid-block + 4.class: grid-block + 5.class: grid-block + 6.class: grid-block + 7.class: grid-block + 8.class: grid-block + 9.class: grid-block + 10.class: grid-block + 11.class: grid-block + 12.class: grid-block + 13.class: grid-block + 14.class: grid-block + 15.class: grid-block + 16.class: grid-block + + 6.style.fill: red + 12.style.fill: red + } +} + +Release: { + class: block + style: { + fill: "#d5ffcd" + } + + incoming.class: grid-block + incoming -> db1 + incoming -> db2 + + db1: "" { + shape: image + icon: https://icons.terrastruct.com/essentials/117-database.svg + width: 70 + height: 70 + } + db2: "" { + shape: image + icon: https://icons.terrastruct.com/essentials/117-database.svg + width: 70 + height: 70 + } +} + +Build.artifacts -> Test.grid -> Release.incoming diff --git a/grammar.js b/grammar.js index ca8d276..a5aa1ee 100644 --- a/grammar.js +++ b/grammar.js @@ -298,6 +298,7 @@ module.exports = grammar({ "stroke-dash", "border-radius", "double-border", + "font", "font-size", "font-color", "shadow", diff --git a/src/grammar.json b/src/grammar.json index c2299cf..9ba9a9e 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -1461,6 +1461,10 @@ "type": "STRING", "value": "double-border" }, + { + "type": "STRING", + "value": "font" + }, { "type": "STRING", "value": "font-size" diff --git a/src/node-types.json b/src/node-types.json index 45b6b0d..06bca32 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -552,6 +552,10 @@ "type": "float", "named": true }, + { + "type": "font", + "named": false + }, { "type": "font-color", "named": false diff --git a/src/parser.c b/src/parser.c index f80d5ff..b58392a 100644 Binary files a/src/parser.c and b/src/parser.c differ diff --git a/test/corpus/attributes.txt b/test/corpus/attributes.txt index 5e98b4f..542efca 100644 --- a/test/corpus/attributes.txt +++ b/test/corpus/attributes.txt @@ -13,6 +13,8 @@ stroke: red stroke-width: 5 stroke-dash: 4 border-radius: 1 +font: mono +font-size: 20 font-color: red shadow: false multiple: true @@ -36,6 +38,8 @@ near: abc (attribute (attr_key (reserved)) (attr_value (integer))) (attribute (attr_key (reserved)) (attr_value (integer))) (attribute (attr_key (reserved)) (attr_value)) + (attribute (attr_key (reserved)) (attr_value (integer))) + (attribute (attr_key (reserved)) (attr_value)) (attribute (attr_key (reserved)) (attr_value (boolean))) (attribute (attr_key (reserved)) (attr_value (boolean))) (attribute (attr_key (reserved)) (attr_value (boolean))) diff --git a/tree-sitter-d2.wasm b/tree-sitter-d2.wasm index 832a280..b753ef3 100755 Binary files a/tree-sitter-d2.wasm and b/tree-sitter-d2.wasm differ