Skip to content

Commit 4ce084e

Browse files
committed
Update to support TOML v1.0.0
1 parent 927a577 commit 4ce084e

File tree

7 files changed

+1506
-427
lines changed

7 files changed

+1506
-427
lines changed

README.md

+42-31
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,54 @@
11
# clj-toml
22

3-
clj-toml is [TOML](https://github.com/vmfhrmfoaj/clj-toml) for Clojure. TOML is Tom's Obvious, Minimal Language.
3+
`clj-toml` is [TOML](https://toml.io) for Clojure.
4+
TOML is Tom's Obvious, Minimal Language.
45

56
> TOML is like INI, only better (Tom Preston-Werner)
67
7-
clj-toml uses [Instaparse](https://github.com/Engelberg/instaparse) for parsing.
8+
`clj-toml` uses [Instaparse](https://github.com/Engelberg/instaparse) for parsing.
89
Instaparse does all the heavy lifting, we're just sitting pretty.
9-
Currently clj-toml support TOML [v1.0.0](https://toml.io/en/v1.0.0).
10+
`clj-toml` support TOML [v1.0.0](https://toml.io/en/v1.0.0).
11+
1012

1113
## Usage
1214

13-
Work is underway towards a TOML 0.4.0-compliant release. Use the 0.3.1 release (TOML 0.1.0-compliant) in the meantime:
14-
15-
Leiningen:
16-
```clojure
17-
[clj-toml "1.0.0"]
18-
```
19-
20-
Test:
21-
```clojure
22-
lein test
23-
```
24-
25-
Use:
26-
```clojure
27-
(use 'clj-toml.core)
28-
29-
(parse-toml "
30-
title = \"TOML\"
31-
[Foo]
32-
bar=[1,2,3]")
33-
;; {"title" "TOML" "foo" {"bar" [1 2 3]}}
34-
35-
(meta (parse-toml "
36-
title = \"TOML\"
37-
[Foo]
38-
bar=[1,2,3]"))
39-
;; {...}
40-
```
15+
Currently `clj-toml` v1.0.0 has not been released yet.
16+
You can install `clj-toml` locally by using `lein install` command.
17+
18+
```clojure
19+
#_user> (use 'clj-toml.core)
20+
;;=> nil
21+
22+
#_user> (def example "
23+
title = \"TOML\"\n
24+
[Foo]\n
25+
bar=[1,2,3]")
26+
27+
#_user> (parse-toml example)
28+
;;=> {"title" "TOML", "Foo" {"bar" [1 2 3]}}
29+
30+
#_user> (meta (parse-toml example))
31+
;;=> {"title" #:clj-toml.core{:start 1, :end 15},
32+
;; "Foo" {:clj-toml.core/start 17,
33+
;; :clj-toml.core/end 22,
34+
;; "bar" #:clj-toml.core{:start 24, :end 35}}}
35+
36+
#_user> (subs example 1 15)
37+
;;=> "title = \"TOML\""
38+
39+
#_user> (subs example 17 22)
40+
;;=> "[Foo]"
41+
```
42+
43+
44+
### Version
45+
46+
```
47+
x.x.x-z.z < patch number
48+
^^^^^
49+
TOML version
50+
```
51+
4152

4253
## License
4354

dev-resources/example-v0.4.0.toml

-244
This file was deleted.

dev-resources/example.toml

+5-21
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,31 @@
1-
# This is a TOML document. Boom.
2-
31
title = "TOML Example"
42

53
[owner]
64
name = "Tom Preston-Werner"
7-
organization = "GitHub"
8-
bio = "GitHub Cofounder & CEO\nLikes tater tots and beer."
9-
dob = 1979-05-27T07:32:00Z # First class dates? Why not?
5+
dob = 1979-05-27T07:32:00-08:00 # First class dates
106

117
[database]
128
server = "192.168.1.1"
13-
ports = [ 8001, 8001, 8002 ]
9+
ports = [ 8000, 8001, 8002 ]
1410
connection_max = 5000
1511
enabled = true
1612

1713
[servers]
1814

19-
# You can indent as you please. Tabs or spaces. TOML don't care.
15+
# Indentation (tabs and/or spaces) is allowed but not required
2016
[servers.alpha]
2117
ip = "10.0.0.1"
2218
dc = "eqdc10"
2319

2420
[servers.beta]
2521
ip = "10.0.0.2"
2622
dc = "eqdc10"
27-
country = "中国" # This should be parsed as UTF-8
2823

2924
[clients]
30-
data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it
25+
data = [ ["gamma", "delta"], [1, 2] ]
3126

3227
# Line breaks are OK when inside arrays
3328
hosts = [
3429
"alpha",
3530
"omega"
36-
]
37-
38-
# Products
39-
40-
[[products]]
41-
name = "Hammer"
42-
sku = 738594937
43-
44-
[[products]]
45-
name = "Nail"
46-
sku = 284758393
47-
color = "gray"
31+
]

0 commit comments

Comments
 (0)