Skip to content

Commit 24ff175

Browse files
committed
Did I forgot to stage this?...
1 parent 90dfd1b commit 24ff175

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

README.md

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,25 @@ var doc = parseKdl("""
3131
title \
3232
"Some title"
3333
34+
// Files must be utf8 encoded!
35+
smile (emoji)"😁" {
36+
upside-down (emoji)"🙃"
37+
}
3438
35-
// Files must be utf8 encoded!
36-
smile (emoji)"😁" {
37-
upside-down (emoji)"🙃"
38-
}
39+
// Instead of anonymous nodes, nodes and properties can be wrapped
40+
// in "" for arbitrary node names.
41+
"!@#$@$%Q#$%~@!40" "1.2.3" "!!!!!"=true
3942
40-
// Instead of anonymous nodes, nodes and properties can be wrapped
41-
// in "" for arbitrary node names.
42-
"!@#$@$%Q#$%~@!40" "1.2.3" "!!!!!"=true
43+
// The following is a legal bare identifier:
44+
foo123~!@#$%^&*.:'|?+ "weeee"
4345
44-
// The following is a legal bare identifier:
45-
foo123~!@#$%^&*.:'|?+ "weeee"
46+
// And you can also use unicode!
47+
ノード お名前="☜(゚ヮ゚☜)"
4648
47-
// And you can also use unicode!
48-
ノード お名前="☜(゚ヮ゚☜)"
49-
50-
// kdl specifically allows properties and values to be
51-
// interspersed with each other, much like CLI commands.
52-
foo bar=true "baz" quux=false 1 2 3
53-
""") # You can also read files using parseKdlFile("file.kdl")
49+
// kdl specifically allows properties and values to be
50+
// interspersed with each other, much like CLI commands.
51+
foo bar=true "baz" quux=false 1 2 3
52+
""") # You can also read files using parseKdlFile("file.kdl")
5453
5554
# Nodes are represented like:
5655
# type KdlNode* = object
@@ -60,28 +59,28 @@ foo bar=true "baz" quux=false 1 2 3
6059
# props*: Table[string, KdlVal]
6160
# children*: seq[KdlNode]
6261
63-
assert doc[0][0].isString() # title "Some title"
62+
assert doc[0].args[0].isString() # title "Some title"
6463
65-
assert doc[1][0] == "😁" # smile node
66-
assert doc[1][0].tag.isSome and doc[1][0].tag.get == "emoji" # Type annotation
67-
assert doc[1].children[0][0] == "🙃" # smile node's upside-down child
64+
assert doc[1].args[0] == "😁" # smile node
65+
assert doc[1].args[0].tag.isSome and doc[1].args[0].tag.get == "emoji" # Type annotation
66+
assert doc[1].children[0].args[0] == "🙃" # smile node's upside-down child
6867
6968
assert doc[2].name == "!@#$@$%Q#$%~@!40"
7069
7170
assert doc[^1]["quux"] == false
7271
73-
doc[0][0].setString("New title")
72+
doc[0].args[0].setString("New title")
7473
7574
# toKdlNode is a macro that facilitates the creation of `KdlNode`s, there's also toKdl (to create documents) and toKdlVal
7675
doc[1].children[0] = toKdlNode: sunglasses("😎"[emoji], 3.14)
7776
7877
assert $doc[1].children[0] == "\"sunglasses\" (\"emoji\")\"😎\" 3.14"
7978
80-
assert doc[1].children[0][1].get(uint8) == 3u8 # Converts 3.14 into an uint8
79+
assert doc[1].children[0].args[1].get(uint8) == 3u8 # Converts 3.14 into an uint8
8180
8281
doc[^1]["bar"].setTo(false) # Same as setBool(false)
8382
84-
doc.writeFile("doc.kdl")
83+
writeFile("doc.kdl", doc)
8584
```
8685

8786
## Docs

0 commit comments

Comments
 (0)