-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Regression: Could not parse YAML metadata #4959
Comments
HsYAML claims to comply strictly with YAML 1.2, so the
first thing you should do is check whether your sample
conforms to that spec. It's possible that it does
not. If it does, then you should report a bug to HsYAML.
If not, then I don't consider this a bug at all.
|
Testing directly with HsYAML:
|
So the Ruby lib is based on a C lib libyaml that does not support YAML 1.2 yet. I could not find out whether my test file is YAML 1.2 compliant. |
I don't think there's much more we can do about this on the pandoc side. If you find there's a bug in HsYAML, you should report there. |
I'm pretty confident that - 'Was geht?
' or reason: 'Was geht?
' are in fact not valid YAML 1.2 If you look at section 7.3.2. Single-Quoted Style, you'll notice that the rules
all have a And as such, if e.g. PS: As it turns out, there's a negative test in the YAML testsuite at http://matrix.yaml.io/sheet/invalid.html#QB6E which expects a compliant YAML parser to fail on ---
quoted: "a
b
c" |
Thanks for telling us @hvr. I just report here for those running into similar issues. I used the YAML 1.2 compliant lib ---
reason: "Was geht?\n"
--- What is different?
My solution is to produce my file with Ruby and then fix this one problem manually with regular expressions. Of course, with a different feature set used in the YAML file, other problems may occur that also need manual treatment. So I hope that in the long run, a YAML 1.2 compliant Ruby lib becomes available. # fix YAML 1.2 compatibility for pandoc > 2.2.1, see https://stackoverflow.com/a/30049447/1407622
sed -r -z -i "s/: '([^']+)\n\n'/: \"\1\\\n\"/g" test.yml |
From Pandoc 2.2.2, HsYAML is the new YAML parser and it has a stricter interpretation of YAML 1.2. My previous indentation was causing an error that resulted, I believe, in the pandoc_args being ignored (?). I detected this via a test failure re: standard output. The parsing error was showing up on standard output in a case where standard output should have been empty. https://stackoverflow.com/questions/31839686/wrapping-a-list-over-multiple-lines-yaml jgm/pandoc#4959 (comment)
The following problem does not occur in Pandoc 2.2.1 and occurs in all recent versions starting with Pandoc 2.2.2.
Minimal Example
test.yml
contains:This is how libyaml embedded by the Ruby programming language outputs strings with trailing newline "\n". The file can be produced with this ruby command:
ruby -r yaml -e 'puts Hash({"reason" => "Was geht?\n"}).to_yaml + "---"'
In my actual setup, I generate meta-data and use this in a document. For the minimal example, I just output the meta-data in JSON AST format.
Expected Output
The output with pandoc 2.2.1 is:
Erronous Output
Pandoc 2.2.2 and higher gives a different output:
As you can see, the meta data is empty.
The cause is certainly linked to the dependency change to HsYAML from @hvr, that I kindly ask to help determining if the file
test.yml
is actually supported syntax.The text was updated successfully, but these errors were encountered: