Skip to content
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

Frontmatter: bools aren't parsed as such #593

Open
cxw42 opened this issue Nov 10, 2019 · 1 comment
Open

Frontmatter: bools aren't parsed as such #593

cxw42 opened this issue Nov 10, 2019 · 1 comment

Comments

@cxw42
Copy link

cxw42 commented Nov 10, 2019

(At most tangentially related to #541 (comment))

System:

$ statocles -v
Statocles version 0.095 (Perl v5.26.3)
Locale: en_US.UTF-8
$ uname -a
CYGWIN_NT-6.1 Desktop 3.0.7(0.338/5/3) 2019-04-30 18:08 x86_64 Cygwin

Input file:

---
disable_content_template: false
---
# Header

Expected: parses OK

Observed:

Error creating document in "index.markdown": Value "false" is not valid for attribute "disable_content_template" (expected "Bool")

It looks like this is because Statocles::Document uses YAML, not YAML::PP or YAML::XS. For example:

$ perl -MYAML -MData::Dumper -E 'say Dumper Load "foo: true"'
$VAR1 = {
      'foo' => 'true'     # <== NOTE: string
    };

$ perl -MYAML::PP=Load -MData::Dumper -E 'say Dumper Load "foo: true"'
$VAR1 = {
      'foo' => 1          # <== NOTE: boolish
    };

I looked in the test suite and didn't see a test of parsing this attribute. t/page/document.t tests the behaviour of the attribute, but not the parsing of the attribute from frontmatter into a Statocles::Document.

What say you?

Thanks!

-CXW

@preaction
Copy link
Owner

I say I'm starting to see why folks hate YAML 🙁. IIRC tinita has been working on making YAML::PP better, so Statocles should probably use that. But I also thought she was making YAML.pm a frontend to the (compatible) backend libraries (that work may be still underway).

I think for now swapping to YAML::PP is probably the best option. Statocles v0 is in maintenance mode until the v2 branch is ready (which uses Yancy::Backend::Static to parse the documents, which may also have this same problem), so drastic changes here aren't that valuable.

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants