Skip to content

Commit 5eebd54

Browse files
author
PavelK
committed
feat(yaml.lua): Add support comments
feat(yaml.lua): Add support check YAML version tag feat(yaml.lua): dump to yaml (author @snowyu, PR exosite#12) fix(yaml.lua): negative numbers as properties should not parse as a list (author @FreeMasen, PR exosite#11) fix(yaml.lua): timestamp timezone fix(yaml.lua): only parsing first block hash with indent==0 fix(yaml.lua): parsing block after empty row feat(samples): Check comments fix(samples): timezone feat(samples): Check negative numbers as properties
1 parent 009b129 commit 5eebd54

14 files changed

Lines changed: 221 additions & 110 deletions

samples/array-member.lua

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
return {
2+
["arr"] = {
3+
[1] = {
4+
["prop1"] = {
5+
["subprop1"] = "test",
6+
["subprop2"] = {
7+
["test2"] = "test",
8+
["test3"] = {}
9+
}
10+
}
11+
},
12+
[2] = {
13+
["prop2"] = {
14+
["subprop3"] = "test.test"
15+
}
16+
},
17+
[3] = {
18+
["prop3"] = {
19+
["subprop4"] = 5
20+
}
21+
}
22+
}
23+
}

samples/array-member.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
arr:
3+
- prop1:
4+
subprop1: test
5+
subprop2:
6+
test2: test
7+
test3: {}
8+
- prop2:
9+
subprop3: test.test
10+
- prop3:
11+
subprop4: 5

samples/comments.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
return {
2+
["key"] = {"value line 1", "value line 2", "value line 3"},
3+
["key2"] = 30,
4+
["key3"] = "String value",
5+
["key4"] = "#not a comment",
6+
["key5"] = false,
7+
["key6"] = 123,
8+
["key7"] = {
9+
["key8"] = "value",
10+
["key9"] = "not#comments"
11+
}
12+
}

samples/comments.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
key: #comment after id
3+
- value line 1
4+
#comment before list item
5+
- value line 2
6+
#comment
7+
#multi
8+
#line
9+
- value line 3 #Comment after list item
10+
key2: 30 # comment 5
11+
key3: "String value" # comment after string with quotes
12+
key4: "#not a comment"
13+
key5: false # Comment boolean
14+
key6: 123 # Comment number
15+
key7:
16+
key8: value # Comment simple string
17+
key9: not#comments #Comment simple string with # inside and multiple #

samples/dates.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
return {
2-
["date0"] = 1305907200,
3-
["date1"] = 1305907200,
4-
["date2"] = 1293897600,
5-
["date3"] = 1298282160,
6-
["date4"] = 1303335300,
7-
["date5"] = 1307018730
2+
["date0"] = os.time{year=2011, month=5, day=21, hour=0, min=0, sec=0, isdst=false},
3+
["date1"] = os.time{year=2011, month=5, day=21, hour=0, min=0, sec=0, isdst=false},
4+
["date2"] = os.time{year=2011, month=1, day=2, hour=0, min=0, sec=0, isdst=false},
5+
["date3"] = os.time{year=2011, month=2, day=21, hour=17, min=56, sec=0, isdst=false},
6+
["date4"] = os.time{year=2011, month=4, day=21, hour=5, min=35, sec=0, isdst=false},
7+
["date5"] = os.time{year=2011, month=6, day=2, hour=20, min=45, sec=30, isdst=false}
88
}

samples/hash.yaml

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
---
2-
users:
3-
tj:
4-
name: tj
5-
age: 23
6-
email: 'tj@vision-media.ca'
7-
bob:
8-
name: 'bob'
9-
age: 27
10-
ted: { name: ted, age: 32, email: ted@tedtalks.com }
11-
country:
12-
name: Österreich
13-
website: http://en.wikipedia.org/wiki/Austria
14-
space:
15-
description: space, the final frontier
16-
brackets:
17-
square: Square [brackets] can go in the middle of strings
18-
squiggle: Squiggle {brackets} can also go in the middle of strings!
19-
extrasquare: [Scratch that] brackets can go at the beginning as long as they close and have text after.
20-
extrasquiggle: {Scratch that} squigs can go at the beginning also!
2+
users:
3+
tj:
4+
name: tj
5+
age: 23
6+
email: 'tj@vision-media.ca'
7+
bob:
8+
name: 'bob'
9+
age: 27
10+
ted: { name: ted, age: 32, email: ted@tedtalks.com }
11+
12+
13+
14+
country:
15+
name: Österreich
16+
website: http://en.wikipedia.org/wiki/Austria
17+
18+
space:
19+
description: space, the final frontier
20+
21+
brackets:
22+
square: Square [brackets] can go in the middle of strings
23+
24+
25+
squiggle: Squiggle {brackets} can also go in the middle of strings!
26+
27+
extrasquare: [Scratch that] brackets can go at the beginning as long as they close and have text after.
28+
29+
extrasquiggle: {Scratch that} squigs can go at the beginning also!

samples/invoice.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Suite #292",
1010
["family"] = "Dumars",
1111
["given"] = "Chris"
1212
},
13-
["date"] = 980179200,
13+
["date"] = os.time{year=2001, month=1, day=23, hour=0, min=0, sec=0, isdst=false},
1414
["invoice"] = 34843,
1515
["ship-to"] = {
1616
["address"] = {

samples/log.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
return {
2-
["Time"] = 1006498902,
2+
["Time"] = os.time{year=2001, month=11, day=23, hour=10, min=1, sec=42, isdst=false} ,
33
["User"] = "ed",
44
["Warning"] = "This is an error message\
55
for the log file"

samples/log2.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
return {
2-
["Time"] = 1006498951,
2+
["Time"] = os.time{year=2001, month=11, day=23, hour=10, min=2, sec=31, isdst=false},
33
["User"] = "ed",
44
["Warning"] = "A slightly different error\
55
message."

samples/log3.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
return {
2-
["Date"] = 1006498997,
2+
["Date"] = os.time{year=2001, month=11, day=23, hour=10, min=3, sec=17, isdst=false},
33
["Fatal"] = "Unknown variable \"bar\"",
44
["Stack"] = {
55
[1] = {

0 commit comments

Comments
 (0)