1
1
# The KDL Document Language
2
2
3
- > [ !WARNING]
4
- > The main branch of this repository shows the latest v2.0.0 draft, which is a
5
- > work in progress and not considered the "mainline" KDL yet. Most KDL
6
- > implementations in the wild are based on the [ v1.0.0
7
- > spec] ( https://github.com/kdl-org/kdl/tree/1.0.0 ) instead, so you may want to
8
- > refer to that if you're using KDL today.
9
-
10
3
KDL is a small, pleasant document language with XML-like node semantics that
11
4
looks like you're invoking a bunch of CLI commands! It's meant to be used both
12
- as a serialization format and a configuration language, much like JSON, YAML,
13
- or XML. It looks like this:
5
+ as a serialization format and a configuration language, much like JSON, YAML, or
6
+ XML. It looks like this:
14
7
15
8
``` kdl
16
9
package {
@@ -51,27 +44,37 @@ package {
51
44
}
52
45
```
53
46
47
+ For more details, see the [ overview below] ( #overview ) .
48
+
54
49
There's a living [ specification] ( SPEC.md ) , as well as various
55
50
[ implementations] ( #implementations ) . You can also check out the [ FAQ] ( #faq ) to
56
51
answer all your burning questions!
57
52
58
- The current version of the KDL spec is ` 2.0.0-draft.8 ` .
53
+ The current version of the KDL spec is
54
+ [ KDL 2.0.0] ( https://github.com/kdl-org/kdl/blob/2.0.0/SPEC.md ) . For legacy KDL,
55
+ please refer to the [ KDL 1.0.0
56
+ spec] ( https://github.com/kdl-org/kdl/blob/2.0.0/SPEC_v1.md ) . All users are
57
+ encouraged to migrate. [ Migration is forward-and-backward-compatible and
58
+ safe] ( https://github.com/kdl-org/kdl/blob/2.0.0/SPEC.md#compatibility ) , and can
59
+ be automated.
59
60
60
- In addition to a spec for KDL itself, there are also standard specs for [ a KDL
61
- Query Language] ( QUERY-SPEC.md ) based on CSS selectors, and [ a KDL Schema
61
+ In addition to a spec for KDL itself, there are specifications for [ a KDL Query
62
+ Language] ( QUERY-SPEC.md ) based on CSS selectors, and [ a KDL Schema
62
63
Language] ( SCHEMA-SPEC.md ) loosely based on JSON Schema.
63
64
64
65
The language is based on [ SDLang] ( https://sdlang.org ) , with a [ number of
65
66
modifications and clarifications on its syntax and behavior] ( #why-not-sdlang ) .
67
+ We are grateful for their work as an inspiration to ours.
66
68
67
- [ Play with it in your browser!] ( https://kdl-play.danini.dev/ )
69
+ [ Play with it in your browser (currently v1 only) !] ( https://kdl-play.danini.dev/ )
68
70
69
71
## Design and Discussion
70
72
71
- KDL 2.0 design is still in progress. Discussions and questions about the format
72
- should happen over on the [ discussions
73
- page] ( https://github.com/kdl-org/kdl/discussions ) . Feel free to jump in and give
74
- us your 2 cents!
73
+ KDL 2.0.0 has been finalized, and no further changes are expected. For questions
74
+ about KDL and discussions, please see the [ discussions
75
+ page] ( https://github.com/kdl-org/kdl/discussions ) . For minor editorial fixes or
76
+ critical spec errata, please feel free to [ file an
77
+ issue] ( https://github.com/kdl-org/kdl/issues ) .
75
78
76
79
## Used By
77
80
@@ -92,26 +95,38 @@ of some examples of KDL in the wild (either v1, v2, or both):
92
95
93
96
## Implementations
94
97
95
- * Rust: [ kdl-rs] ( https://github.com/kdl-org/kdl-rs ) , [ knuffel] ( https://crates.io/crates/knuffel/ ) (latter includes derive macro), and [ kaydle] ( https://github.com/Lucretiel/kaydle ) (serde-based)
96
- * JavaScript: [ kdljs] ( https://github.com/kdl-org/kdljs ) , [ @virtualstate/kdl ] ( https://github.com/virtualstate/kdl ) (query only, JSX based)
97
- * Ruby: [ kdl-rb] ( https://github.com/danini-the-panini/kdl-rb )
98
- * Dart: [ kdl-dart] ( https://github.com/danini-the-panini/kdl-dart )
99
- * Java: [ kdl4j] ( https://github.com/hkolbeck/kdl4j )
100
- * PHP: [ kdl-php] ( https://github.com/kdl-org/kdl-php )
101
- * Python: [ kdl-py] ( https://github.com/tabatkins/kdlpy ) , [ cuddle] ( https://github.com/djmattyg007/python-cuddle ) , [ ckdl] ( https://github.com/tjol/ckdl )
102
- * Elixir: [ kuddle] ( https://github.com/IceDragon200/kuddle )
103
- * XSLT: [ xml2kdl] ( https://github.com/Devasta/XML2KDL )
104
- * Haskell: [ Hustle] ( https://github.com/fuzzypixelz/Hustle )
105
- * .NET: [ Kadlet] ( https://github.com/oledfish/Kadlet )
106
- * C: [ ckdl] ( https://github.com/tjol/ckdl )
107
- * C++: [ kdlpp] ( https://github.com/tjol/ckdl ) (part of ckdl, requires C++20)
108
- * OCaml: [ ocaml-kdl] ( https://github.com/Bannerets/ocaml-kdl )
109
- * Nim: [ kdl-nim] ( https://github.com/Patitotective/kdl-nim )
110
- * Common Lisp: [ kdlcl] ( https://github.com/chee/kdlcl )
111
- * Go: [ gokdl] ( https://github.com/lunjon/gokdl ) , [ kdl-go] ( https://github.com/sblinch/kdl-go )
112
- * Swift: [ kdl-swift] ( https://github.com/danini-the-panini/kdl-swift )
113
- * Crystal: [ kdl-cr] ( https://github.com/danini-the-panini/kdl-cr )
114
- * Lua: [ kdlua] ( https://github.com/danini-the-panini/kdlua )
98
+ > [ !INFO] There are two major versions of KDL. Different libraries may support one or the
99
+ > other, or even provide a "hybrid" mode where both versions are attempted, since
100
+ > there's no data ambiguity between v1 and v2 documents.
101
+
102
+ | Language | Implementation | v1 | v2 | Notes |
103
+ | ---| ---| ---| ---| ---|
104
+ | C | [ ckdl] ( https://github.com/tjol/ckdl ) | ✅ | ✅ | |
105
+ | C#/.NET | [ Kadlet] ( https://github.com/oledfish/Kadlet ) | ✅ | ✖️ | |
106
+ | C++ | [ kdlpp] ( https://github.com/tjol/ckdl ) | ✅ | ✅ | part of ckdl, requires C++20 |
107
+ | Common Lisp | [ kdlcl] ( https://github.com/chee/kdlcl ) | ✅ | ✖️ | |
108
+ | Crystal | [ kdl-cr] ( https://github.com/danini-the-panini/kdl-cr ) | ✅ | ✖️ | |
109
+ | Dart | [ kdl-dart] ( https://github.com/danini-the-panini/kdl-dart ) | ✅ | ✖️ | |
110
+ | Elixir | [ kuddle] ( https://github.com/IceDragon200/kuddle ) | ✅ | ✅ | |
111
+ | Go | [ gokdl] ( https://github.com/lunjon/gokdl ) | ✅ | ✖️ | |
112
+ | Go | [ kdl-go] ( https://github.com/sblinch/kdl-go ) | ✅ | ✖️ | |
113
+ | Haskell | [ Hustle] ( https://github.com/fuzzypixelz/Hustle ) | ✅ | ✖️ | |
114
+ | Java | [ kdl4j] ( https://github.com/hkolbeck/kdl4j ) | ✅ | ✖️ | |
115
+ | JavaScript | [ @bgotink/kdl ] ( https://github.com/bgotink/kdl ) | ✅ | ✅ | Format/comment-preserving parser |
116
+ | JavaScript | [ @virtualstate/kdl ] ( https://github.com/virtualstate/kdl ) | ✅ | ✖️ | query only, JSX based |
117
+ | JavaScript | [ kdljs] ( https://github.com/kdl-org/kdljs ) | ✅ | ✖️ | |
118
+ | Lua | [ kdlua] ( https://github.com/danini-the-panini/kdlua ) | ✅ | ✖️ | |
119
+ | Nim | [ kdl-nim] ( https://github.com/Patitotective/kdl-nim ) | ✅ | ✖️ | |
120
+ | OCaml | [ ocaml-kdl] ( https://github.com/Bannerets/ocaml-kdl ) | ✅ | ✖️ | |
121
+ | PHP | [ kdl-php] ( https://github.com/kdl-org/kdl-php ) | ✅ | ✖️ | |
122
+ | Python | [ ckdl] ( https://github.com/tjol/ckdl ) | ✅ | ✅ | |
123
+ | Python | [ cuddle] ( https://github.com/djmattyg007/python-cuddle ) | ✅ | ✖️ | |
124
+ | Python | [ kdl-py] ( https://github.com/tabatkins/kdlpy ) | ✅ | ✅ | |
125
+ | Ruby | [ kdl-rb] ( https://github.com/danini-the-panini/kdl-rb ) | ✅ | ✖️ | |
126
+ | Rust | [ kdl-rs] ( https://github.com/kdl-org/kdl-rs ) | ✅ | ✅ | Format/comment-preserving parser |
127
+ | Rust | [ knus] ( https://crates.io/crates/knus/ ) | ✅ | ✖️ | Serde-_ style_ derive macros (not actual Serde) |
128
+ | Swift | [ kdl-swift] ( https://github.com/danini-the-panini/kdl-swift ) | ✅ | ✖️ | |
129
+ | XSLT | [ xml2kdl] ( https://github.com/Devasta/XML2KDL ) | ✅ | ✖️ | |
115
130
116
131
## Compatibility Test Suite
117
132
@@ -123,11 +138,13 @@ entirety, but in the future, may be required to in order to be included here.
123
138
124
139
## Editor Support
125
140
126
- * [ VS Code ] ( https://marketplace.visualstudio .com/items?itemName=kdl-org. kdl&ssr=false#review-details )
141
+ * [ Intellij IDEA ] ( https://plugins.jetbrains .com/plugin/20136- kdl-document-language )
127
142
* [ Sublime Text] ( https://packagecontrol.io/packages/KDL )
143
+ * [ TreeSitter] ( https://github.com/tree-sitter-grammars/tree-sitter-kdl ) (neovim, among others)
144
+ * [ VS Code] ( https://marketplace.visualstudio.com/items?itemName=kdl-org.kdl&ssr=false#review-details ) \*
128
145
* [ vim] ( https://github.com/imsnif/kdl.vim )
129
- * [ neovim ] ( https://github.com/tree-sitter-grammars/tree-sitter-kdl )
130
- * [ Intellij IDEA ] ( https://plugins.jetbrains.com/plugin/20136-kdl-document-language )
146
+
147
+ \* Supports KDL 2.0.0
131
148
132
149
## Overview
133
150
@@ -167,21 +184,21 @@ Nodes without children are terminated by a newline, a semicolon, or the end of
167
184
a file stream:
168
185
169
186
``` kdl
170
- node1; node2; node3;
187
+ node1; node2; node3
171
188
```
172
189
173
190
### Values
174
191
175
192
KDL supports 4 data types:
176
193
177
194
* Strings: ` unquoted ` , ` "hello world" ` , or ` #"hello world"# `
178
- * Numbers: ` 123.45 `
195
+ * Numbers: ` 123.45 ` , ` 0xdeadbeef ` , ` #inf ` , ` #-inf ` , ` #nan `
179
196
* Booleans: ` #true ` and ` #false `
180
197
* Null: ` #null `
181
198
182
199
#### Strings
183
200
184
- It supports three different formats for string input: identifiers , quoted, and raw.
201
+ It supports three different formats for string input: unquoted , quoted, and raw.
185
202
186
203
``` kdl
187
204
node1 this-is-a-string
@@ -234,10 +251,10 @@ other-raw ##"hello#"world"##
234
251
235
252
#### Numbers
236
253
237
- There are 4 ways to represent numbers in KDL. KDL does not prescribe any
238
- representation for these numbers, and it's entirely up to individual
239
- implementations whether to represent all numbers with a single type, or to
240
- have different representations for different forms.
254
+ There are 4 ways to represent numbers in KDL, plus 3 float keywords. KDL does
255
+ not prescribe any representation for these numbers, and it's entirely up to
256
+ individual implementations whether to represent all numbers with a single type,
257
+ or to have different representations for different forms.
241
258
242
259
KDL has regular decimal-radix numbers, with optional decimal part, as well as
243
260
an optional exponent.
@@ -255,6 +272,13 @@ my-octal 0o755
255
272
my-binary 0b10101101
256
273
```
257
274
275
+ If you're intending to represent IEEE 754 floats, there are three special
276
+ keywords you can use:
277
+
278
+ ``` kdl
279
+ special-floats #inf #-inf #nan
280
+ ```
281
+
258
282
Finally, all numbers can have underscores to help readability:
259
283
260
284
``` kdl
0 commit comments