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 for parsing multiple documents #369

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

coreyoconnor
Copy link

This adds parseAllYAMLs (and parseYAML) to the yaml package object.

  • parseAllYAMLs either fails or returns a list of all yaml documents (Node) contained in the string content.
  • parseYAML is an explicit form of the is the single document parsing provided by .asNode.

To implement this, a fairly small addition was made to Composer: multipleFromEvents. Which uses composeNode to parse Nodes from the events so long as there are tail events returned.

This also exposes the pos method of Node. This is useful when writing custom decoders for nicer error messages.

This is a mix of style (exposing the explicit parseYAML methods and pos) plus functionality. Let me know if you'd like me to separate this into multiple PRs.

This adds `parseYAML` and `parseAllYAMLs` to the `yaml` package object.

The first is the single document parsing provided by `.asNode`. The
second parses a sequence of documents.

To implement this, a fairly small addition was made to `Composer`:
`multipleFromEvents`. Which uses `composeNode` to parse `Node`s from the
events so long as there are `tail` events returned.

This also exposes the `pos` method of `Node`. This is useful when
writing custom decoders for nicer error messages.
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.

1 participant