Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support encoding of comment node #233

Merged
merged 1 commit into from
Jul 16, 2021
Merged

Support encoding of comment node #233

merged 1 commit into from
Jul 16, 2021

Conversation

goccy
Copy link
Owner

@goccy goccy commented Jul 16, 2021

Supports comment encoding.
This allows you to parse the following document with comments and undo it !

# foo comment
# foo comment2
foo: # map key comment
  # bar above comment
  # bar above comment2
  bar: 10 # comment for bar
  # baz above comment
  # baz above comment2
  baz: bbbb # comment for baz
  piyo: # sequence key comment
  # sequence1 above comment 1
  # sequence1 above comment 2
  - sequence1 # sequence1
  # sequence2 above comment 1
  # sequence2 above comment 2
  - sequence2 # sequence2
  # sequence3 above comment 1
  # sequence3 above comment 2
  - false # sequence3
# foo2 comment
# foo2 comment2
foo2: &anchor text # anchor comment
# foo3 comment
# foo3 comment2
foo3: *anchor # alias comment
f, err := parser.ParseBytes([]byte(yml), parser.ParseComments)
if err != nil {
  panic(err)
}
fmt.Println(f.String()) // You can get the same as the original document

@goccy goccy merged commit 0330953 into master Jul 16, 2021
@goccy goccy deleted the feature/fix-comment branch July 16, 2021 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant