Skip to content

Commit

Permalink
Ignore new document symbol --- (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwbh authored Oct 31, 2024
1 parent 2b4e071 commit 09b0279
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion resources/yaml-test-suite/98YD-mixed.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
elemennts:
- name: Spec Example 5.5. Comment Indicator
from: http://www.yaml.org/spec/1.2/spec.html#id2773032
Expand All @@ -11,4 +12,4 @@ elemennts:
dump: ""
bool_val: true
bool_val_b2: false
bool_val_with_spaces: true
bool_val_with_spaces: true
3 changes: 2 additions & 1 deletion resources/yaml-test-suite/98YD.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
elemennts:
- name: Spec Example 5.5. Comment Indicator
from: http://www.yaml.org/spec/1.2/spec.html#id2773032
Expand All @@ -8,4 +9,4 @@ elemennts:
+STR
-STR
json: ""
dump: ""
dump: ""
1 change: 1 addition & 0 deletions resources/yaml-test-suite/CC74.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
elements:
- name: Spec Example 6.20. Tag Handles
from: http://www.yaml.org/spec/1.2/spec.html#id2783195
Expand Down
3 changes: 2 additions & 1 deletion src/root.zig
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ pub fn Ymlz(comptime Destination: type) type {
try self.allocations.append(line);

// TODO: Need to fix this comments can start not only from index 0.
if (line.len == 0 or line[0] == '#') {
// TODO: What shoud really happen if a file has '---' which means a new document in the same file.
if (line.len == 0 or line[0] == '#' or std.mem.eql(u8, "---", line)) {
// Skipping comments
return self.readLine();
}
Expand Down
1 change: 1 addition & 0 deletions src/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ test "98YD" {
}

test "CC74" {
// test
const Element = struct {
name: []const u8,
from: []const u8,
Expand Down

0 comments on commit 09b0279

Please sign in to comment.