Comments (3)
Yes, this is actually something that changed.
@eemeli explained it here: eemeli/yaml#109 (comment) and quoted the relevant parts from the specification.
It is hard to find out because the documentation about tag shorthands doesn't document that explicitly in 1.2, but only says
A YAML character stream may contain several documents. Each document is completely independent from the rest.
The point is probably, that you should be able to take out a YAML document of a file or stream and put it elsewhere, and it should work the same.
But I think this is something that a YAML processor could actually make configurable.
I understand if there are many small documents, repeating the tag directive can be very noisy.
from yaml-test-suite.
Thank you for the explanation. I have two follow-up questions:
Each document is completely independent from the rest.
Given:
%YAML 1.1
---
x: 0
---
x: 1
is it so that the first document version is explicitly v1.1 and second is implicitly v1.2 (provided the implementation uses 1.2 as default version)? And to make this implicit v1.2 inference of second document explicitly clear, it would require explicit <document end>
indicator:
%YAML 1.1
---
x: 0
...
%YAML 1.2
---
x: 1
...
this is something that a YAML processor could actually make configurable.
Lets say that processor has a configuration option called AllowSharedGlobalDirectivesInCharacterStream
, would it exempt us from comparing the version? i.e. regardless of versions, the processor option will be honored OR the option is ON
and not configurable for v1.1, and OFF
for v1.2 and configurable.
from yaml-test-suite.
The spec doesn't actually cover how a stream of documents from more than one YAML version should be handled, so your examples are getting into implementation-specific behaviour.
Speaking on behalf of yaml
, its default version is YAML 1.2, but that is configurable. Because of this YAML 1.1 peculiarity, however, the preceding documents' headers are tracked and what you want should work out of the box, even if the parser is explicitly todl to expect YAML 1.2:
import YAML from 'yaml'
const src11 = `
%YAML 1.1
---
x: 0
---
x: 1`
const stream = YAML.parseAllDocuments(src11, { version: '1.2' )
stream.map(doc => doc.version) // [ '1.1', '1.1' ]
stream.map(doc => doc.toJSON()) // [ { x: 0 }, { x: 1 } ]
For YAML 1.2, that doesn't work though, because its spec doesn't consider preceding documents:
const src12 = `
%YAML 1.2
---
x: 0
---
x: 1`
const stream = YAML.parseAllDocuments(src12, { version: '1.1' )
stream.map(doc => doc.version) // [ '1.2', null ]
stream.map(doc => doc.schema.name) // [ 'core', 'yaml-1.1' ]
stream.map(doc => doc.toJSON()) // [ { x: 0 }, { x: 1 } ]
from yaml-test-suite.
Related Issues (20)
- Individual tags per subtest don't work
- 8G76: an empty file is not a valid JSON document HOT 7
- Should L24T/01/in.yaml and JEF9/02/in.yaml end with \n? HOT 2
- is there some logic to the naming of tests? HOT 2
- Explain Token stream notation, Event stream notation HOT 1
- Create a use case for trailing TAB
- norway problem HOT 1
- Is there an error in 4H7K HOT 1
- Why is `a: :a` valid while `a: a:` is not?
- Fix generated test in Y79Y
- Scala-yaml uses this test suite HOT 1
- json for 4ABK HOT 1
- Missing tests for spec sections 5.13 and 5.14 (Escaped Characters) HOT 2
- 4FJ6 events HOT 2
- K54U out.yaml HOT 7
- 4ABK null value HOT 1
- L24T doublequote instead of literal in `emit.yaml` HOT 2
- Missing Output yaml for 5TYM
- Add test for e.g. `[[], :@]` HOT 1
- Address #40 and #54
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yaml-test-suite.