Skip to content

Latest commit

 

History

History
209 lines (205 loc) · 10.7 KB

examples.md

File metadata and controls

209 lines (205 loc) · 10.7 KB
> 'title "Hello, World"' | from kdl
╭───────┬──────────────╮
│ title │ Hello, World │
╰───────┴──────────────╯

> 'bookmarks 12 15 188 1234' | from kdl
╭───────────┬──────────────╮
│           │ ╭───┬──────╮ │
│ bookmarks │ │ 0 │   12 │ │
│           │ │ 1 │   15 │ │
│           │ │ 2 │  188 │ │
│           │ │ 3 │ 1234 │ │
│           │ ╰───┴──────╯ │
╰───────────┴──────────────╯

> 'author "Alex Monad" email="alex@example.com" active=true' | from kdl
╭────────┬──────────────────────────────────────╮
│        │ ╭───┬──────────────────────────────╮ │
│ author │ │ 0 │ Alex Monad                   │ │
│        │ │ 1 │ ╭───────┬──────────────────╮ │ │
│        │ │   │ │ email │ alex@example.com │ │ │
│        │ │   │ ╰───────┴──────────────────╯ │ │
│        │ │ 2 │ ╭────────┬──────╮            │ │
│        │ │   │ │ active │ true │            │ │
│        │ │   │ ╰────────┴──────╯            │ │
│        │ ╰───┴──────────────────────────────╯ │
╰────────┴──────────────────────────────────────╯

> 'contents {
  section "First section" {
    paragraph "This is the first paragraph"
    paragraph "This is the second paragraph"
  }
}' | from kdl
╭──────────┬───────────────────────────────────────────────────────────────────────────╮
│          │ ╭─────────┬─────────────────────────────────────────────────────────────╮ │
│ contents │ │         │ ╭──────────┬──────────────────────────────────────────────╮ │ │
│          │ │ section │ │ entries  │ First section                                │ │ │
│          │ │         │ │          │ ╭───────────┬──────────────────────────────╮ │ │ │
│          │ │         │ │ children │ │ paragraph │ This is the first paragraph  │ │ │ │
│          │ │         │ │          │ │ paragraph │ This is the second paragraph │ │ │ │
│          │ │         │ │          │ ╰───────────┴──────────────────────────────╯ │ │ │
│          │ │         │ ╰──────────┴──────────────────────────────────────────────╯ │ │
│          │ ╰─────────┴─────────────────────────────────────────────────────────────╯ │
╰──────────┴───────────────────────────────────────────────────────────────────────────╯

> 'node1; node2; node3;' | from kdl
╭───────┬──╮
│ node1 │  │
│ node2 │  │
│ node3 │  │
╰───────┴──╯

> 'node "this\nhas\tescapes"
other r"C:\Users\zkat\"' | from kdl
╭───────┬────────────────╮
│ node  │ this           │
│       │ has    escapes │
│ other │ C:\Users\zkat\ │
╰───────┴────────────────╯

> 'string "my
multiline
value"' | from kdl
╭────────┬───────────╮
│ string │ my        │
│        │ multiline │
│        │ value     │
╰────────┴───────────╯

> 'other-raw r#"hello"world"#' | from kdl
╭───────────┬─────────────╮
│ other-raw │ hello"world │
╰───────────┴─────────────╯

> 'num 1.234e-42' | from kdl
╭─────┬──────╮
│ num │ 0.00 │
╰─────┴──────╯

> 'my-hex 0xdeadbeef
my-octal 0o755
my-binary 0b10101101' | from kdl
╭───────────┬────────────╮
│ my-hex    │ 3735928559 │
│ my-octal  │ 493        │
│ my-binary │ 173        │
╰───────────┴────────────╯

> 'bignum 1_000_000' | from kdl
╭────────┬─────────╮
│ bignum │ 1000000 │
╰────────┴─────────╯

> '// C style

/*
C style multiline
*/

tag /*foo=true*/ bar=false

/*/*
hello
*/*/' | from kdl
╭─────┬─────────────────╮
│     │ ╭─────┬───────╮ │
│ tag │ │ bar │ false │ │
│     │ ╰─────┴───────╯ │
╰─────┴─────────────────╯

> '// This entire node and its children are all commented out.
/-mynode "foo" key=1 {
  a
  b
  c
}

mynode /-"commented" "not commented" /-key="value" /-{
  a
  b
}' | from kdl
╭────────┬───────────────╮
│ mynode │ not commented │
╰────────┴───────────────╯

> 'numbers (u8)10 (i32)20 myfloat=(f32)1.5 {
  strings (uuid)"123e4567-e89b-12d3-a456-426614174000" (date)"2021-02-03" filter=(regex)r"$\d+"
  (author)person name="Alex"
}' | from kdl
╭─────────┬───────────────────────────────────────────────────────────────────────────╮
│         │ ╭──────────┬────────────────────────────────────────────────────────────╮ │
│ numbers │ │          │ ╭───┬────────────────────╮                                 │ │
│         │ │ entries  │ │ 0 │                 10 │                                 │ │
│         │ │          │ │ 1 │                 20 │                                 │ │
│         │ │          │ │ 2 │ ╭─────────┬──────╮ │                                 │ │
│         │ │          │ │   │ │ myfloat │ 1.50 │ │                                 │ │
│         │ │          │ │   │ ╰─────────┴──────╯ │                                 │ │
│         │ │          │ ╰───┴────────────────────╯                                 │ │
│         │ │          │ ╭─────────┬──────────────────────────────────────────────╮ │ │
│         │ │ children │ │         │ ╭───┬──────────────────────────────────────╮ │ │ │
│         │ │          │ │ strings │ │ 0 │ 123e4567-e89b-12d3-a456-426614174000 │ │ │ │
│         │ │          │ │         │ │ 1 │ 2021-02-03                           │ │ │ │
│         │ │          │ │         │ │ 2 │ ╭────────┬──────╮                    │ │ │ │
│         │ │          │ │         │ │   │ │ filter │ $\d+ │                    │ │ │ │
│         │ │          │ │         │ │   │ ╰────────┴──────╯                    │ │ │ │
│         │ │          │ │         │ ╰───┴──────────────────────────────────────╯ │ │ │
│         │ │          │ │         │ ╭──────┬──────╮                              │ │ │
│         │ │          │ │ person  │ │ name │ Alex │                              │ │ │
│         │ │          │ │         │ ╰──────┴──────╯                              │ │ │
│         │ │          │ ╰─────────┴──────────────────────────────────────────────╯ │ │
│         │ ╰──────────┴────────────────────────────────────────────────────────────╯ │
╰─────────┴───────────────────────────────────────────────────────────────────────────╯