yaml.js
yaml.js copied to clipboard
Multiline string with # at start is stripped out as comment
Multiline strings starting with the marker "|-", with lines that begin with a pound character ('#', AKA "hash tag" for you younglings), will not include any lines that start with the pound character in the output object. (Presumably because they are stripped out as comments).
With the following YAML file (test.yaml):
markdown: |-
# Markdown Heading
Markdown Body
var yamlStr = fs.readFileSync('test.yaml').toString();
var obj = YAML.parse(yamlStr);
console.log(obj);
Should output:
{
"markdown": "#Markdown Heading\nMarkdown Body"
}
Instead, it outputs:
{
"markdown": "Markdown Body"
}
I cannot find any information about how this should work in the standard, however, this works in all other YAML parsers I've tried, including:
Came here to report the same bug. Bump, my use-case is:
listing:
- headline: Paragraph/line break
description: To create a paragraph simply add a line of text. To add a line break add two empty lines.
example: |
```
One paragraph
Still the same paragraph
New paragraph
```
- headline: Headline
description: To add a headline add the `#` symbol in-front of your line. The amount of hashes represents the headline level.
example: |
```
# A headline level 1
## A headline level 2
### A headline level 3
```
The leading pipe should prevent the parser to strip comments. Will likely have to move to https://github.com/nodeca/js-yaml as well. Hope this can be fixed here though.
Cheers