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

Document-End marker should always be emitted after block scalar with trailing empty lines #123

Closed
perlpunk opened this issue Jun 29, 2018 · 1 comment

Comments

@perlpunk
Copy link
Member

The following YAML demonstrates a case where a document-end marker is important and should not be omitted:

foo: |+
  foo

...

libyaml should emit it even if implicit is true. Currently it does not, pyyaml and ruamel do.

Demo:

libyaml % echo '+STR
+DOC
=VAL |foo\n\n\n
-DOC
-STR' | ./tests/run-emitter-test-suite
|+
  foo


libyaml %
perlpunk added a commit that referenced this issue Dec 26, 2019
In YAML 1.1, the document end marker `...` is optional even if the next document starts with a directive:
https://github.com/yaml/pyyaml/blob/master/tests/data/spec-07-09.canonical
```
%YAML 1.1
---
!!str "foo"
%YAML 1.1
---
!!str "bar"
%YAML 1.1
---
!!str "baz"
```
It is only required if the scalar is "open ended", for example for plain scalars.

In YAML 1.2 the `...` marker is always required before a directive.

My suggestion would be to make the output 1.2 compatible. It will still be 1.1 compatible, so that shouldn't be a problem.

I believe this will also make it easier to fix #123 which was introduced with the last fixes regarding `open_ended`. I think I can make a fix for this soon after this issue is fixed.
Fixing #123 without this would be a bit more complicated.

If we do this, we also need to adjust PyYAML to behave the same.

Related issues/commits:
- #60
- #122
- 56400d9, 8ee83c0, 56f4b17
@perlpunk
Copy link
Member Author

Related: yaml/yaml-test-suite#49

@yaml yaml deleted a comment from perlpunk Dec 30, 2019
perlpunk added a commit that referenced this issue Mar 23, 2020
In YAML 1.1, the document end marker `...` is optional even if the next document starts with a directive:
https://github.com/yaml/pyyaml/blob/master/tests/data/spec-07-09.canonical
```
%YAML 1.1
---
!!str "foo"
%YAML 1.1
---
!!str "bar"
%YAML 1.1
---
!!str "baz"
```
It is only required if the scalar is "open ended", for example for plain scalars.

In YAML 1.2 the `...` marker is always required before a directive.

My suggestion would be to make the output 1.2 compatible. It will still be 1.1 compatible, so that shouldn't be a problem.

I believe this will also make it easier to fix #123 which was introduced with the last fixes regarding `open_ended`. I think I can make a fix for this soon after this issue is fixed.
Fixing #123 without this would be a bit more complicated.

If we do this, we also need to adjust PyYAML to behave the same.

Related issues/commits:
- #60
- #122
- 56400d9, 8ee83c0, 56f4b17
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

No branches or pull requests

1 participant