Ticket #69 (closed defect: invalid)
scalar value of escaped double-newline parsed as a single newline
| Reported by: | anonymous | Owned by: | xi |
|---|---|---|---|
| Priority: | normal | Component: | libyaml |
| Severity: | normal | Keywords: | |
| Cc: |
Description
When parsing the following: terminator : "\n\n"
The value of the right side scalar is returned as \n, rather than \n\n. Likewise, four newlines ("\n\n\n\n") is parsed as three ("\n\n\n").
Attachments
Change History
Changed 6 years ago by anonymous
-
attachment
yaml_test.tar.gz
added
Here is a code example that illustrates the problem. Look at the 3 newlines following the 'terminator' scalar. They end up being returned as 2 newlines.
comment:2 Changed 6 years ago by xi
- Status changed from new to closed
- Resolution set to invalid
Is \n in your examples a new line character or just two symbols: \ and n? PyYAML and LibYAML handle these cases differently:
>>> import yaml >>> yaml.load('"\n\n"') # two new line characters '\n' >>> yaml.load(r'"\n\n"') # four characters: \ n \ n '\n\n'
In the both cases, PyYAML output is correct, see http://yaml.org/spec/cvs/current.html#line%20folding/ and http://yaml.org/spec/cvs/current.html#ns-esc-char.
When N(>1) subsequent new line characters occur in a flow scalar, they are "folded" into N-1 new line characters. A single new line character is replaced with space.

It works fine for me both with pure Python PyYAML and LibYAML bindings:
Could you post a code snippet and a YAML file that produce the problem?