-
Notifications
You must be signed in to change notification settings - Fork 265
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
Validating static site generator data files #13
Comments
Hi @wkoszek, yamllint uses rules to detect style problems, but also looks for syntax errors. For this purpose, it uses the Python YAML library. This is where the problem is: the The issue can be reduced to this simple YAML file: ---
This is paragraph one.
# comment
This is paragraph two. Importing this file through Python's python -c 'import sys, yaml; yaml.dump(yaml.load(sys.stdin), sys.stdout)' </tmp/bad-yaml I'm not sure whether this is invalid YAML or a
To conclude, I see two solutions here:
|
@adrienverge Thanks. That's helpful. Filled an issue here: yaml/pyyaml#30 |
Sorry @wkoszek, after re-reading the YAML specifications (both 1.1 and 1.2), I realize this is not a PyYAML bug, but a problem with your YAML document. As stated in paragraph 3.2.3.3 of the spec:
This explains why the following document, that only contains one big string scalar, is parsed OK: ---
This is paragraph one.
This is paragraph two. but the following doesn't, because the string scalar has a comment in the middle: ---
This is paragraph one.
# comment
This is paragraph two. |
@adrienverge Let's close this guy here, and maybe keep the discussion open in |
Hi,
I think I may find
yamllint
useful, but I'm trying to understand which rules does it use to validate the files. Spec? I ask, since I've made myself a mini-lint version in Ruby and run it on my sample files:So my understanding is that the static code generator files (YAML frontmatter + text) are a correct files YAML-wise: 1st document in an
.md
file is 1 YAML document, and whatever is after---
is a 2nd document. Command from above seems to work indicating the file is correct enough forYAML
module in Ruby. If you uncomment thepp
part of the script, you'll see that the front matter is loaded. Content isn't (which is OK for now), but might be loaded if I modify the script a bit: http://stackoverflow.com/questions/19325251/ruby-yaml-multiple-documentsAnyway:
yamllint
is more picky however with this file:I'm trying to understand what's wrong with this line, since it seems valid too me and pointing somewhere in the middle of my content.
Any ideas?
The text was updated successfully, but these errors were encountered: