Skip to content
Tina Müller (tinita) edited this page Sep 20, 2022 · 7 revisions

Status of libyaml regarding YAML 1.2

Changes in version 1.2 (revision 1.2.0) (2009-07-21)

From https://yaml.org/spec/1.2.2/ext/changes/

1. Line break characters ❌

The next-line \x85, line-separator \u2028 and paragraph-separator \u2029 characters are no longer considered line-break characters. Within scalar values, this means that next-line characters will not be included in the white-space normalization. Using any of these outside scalar values is likely to result in errors during parsing. For a relatively robust solution, try replacing \x85 and \u2028 with \n and \u2029 with \n\n.

libyaml still considers those characters as line breaks.

% perl -wE'binmode STDOUT, "encoding(utF-8)";print "- line1\x{2028}- line2\x{2029}- line3\x{85}- line4\n";' >file.yaml

% yamlpp-load file.yaml -M YAML::PP::LibYAML
$doc0 = [
          "line1",
          "line2",
          "line3",
          "line4"
        ];
% yamlpp-load file.yaml -M YAML::PP
$doc0 = [
          "line1\x{2028}- line2\x{2029}- line3\x{85}- line4"
        ];

2. Tag shorthands ✓

Tag shorthands can no longer include any of the characters ,[]{}, but can include #. To work around this, either fix your tag names or use verbatim tags.

libyaml doesn't allow those

3. Anchors ✓

Anchors can no longer include any of the characters ,[]{}.

libyaml doesn't allow those

Escaping forward slash / ✓

Inside double-quoted strings \/ is now a valid escape for the / character.

libyaml accepts that

4. Adjacent mapping values ✓

No space is required after the colon in flow style if the key is quoted, e.g. {"key":value}.

libyaml accepts that

5. 1024 Key limit ❌

The maximum key length of 1024 characters has been removed for flow mapping keys.

libyaml implements the concept of "simple keys" from YAML 1.1.

Allowing more than 1024 characters only for flow mapping keys seems to be complicated, because the information on what kind of mapping we have doesn't seem to be available when checking the key. @perlpunk

6. Allowed unicode characters

Quoted content can include practically all Unicode characters.

Independent documents ✓

Documents in streams are now independent of each other, and no longer inherit preceding document directives if they do not define their own.

libyaml was implemented with that behaviour already for 1.1, diverging from the spec.

7. Document end marker before directive ❌

Explicit document-end marker is now always required before a directive.

At least the output is now emitted according to 1.2: https://github.com/yaml/libyaml/pull/160

libyaml allows to omit the marker

% echo '---
- a
%YAML 1.1
---
- b' | yamlpp-events -M YAML::PP::LibYAML
+STR
+DOC ---
+SEQ
=VAL :a
-SEQ
-DOC
+DOC ---
+SEQ
=VAL :b
-SEQ
-DOC
-STR
Clone this wiki locally