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

Some parameter names are converted to TRUE or FALSE #2

Open
PuzzledFace opened this issue Mar 1, 2023 · 0 comments
Open

Some parameter names are converted to TRUE or FALSE #2

PuzzledFace opened this issue Mar 1, 2023 · 0 comments
Labels
blocked A desirable change/fix/improvement that can't be progressed for some reason bug Something isn't working

Comments

@PuzzledFace
Copy link
Collaborator

Consider the YAML header

---
params:
  x: NA
  y: NA
  n: NA
  t: NA
  f: NA
---

This header passes validation at https://www.yamllint.com/, but when reading it with rmarkdown::yaml_front_matter() some parameter names are not handled correctly:

ymlthis::draw_yml_tree(
  rmarkdown::yaml_front_matter(
    textConnection("---\nparams:\n  x: NA\n  y: NA\n  n: NA\n  t: NA\n  f: NA\n---")
  )
)
└── params:
    ├── x: NA
    ├── 'TRUE': NA
    ├── 'FALSE': NA
    ├── t: NA
    └── f: NA

The problem occurs for other parameter names such as Yes and yes but, interestingly, not with T or t. The root cause lies in yaml::yaml.load because the underlying parser supports YAML 1.1 rather than YAML 1.2. The fix is to quote the problematic parameter names:

ymlthis::draw_yml_tree(
  rmarkdown::yaml_front_matter(
    textConnection("---\nparams:\n  x: NA\n  'y': NA\n  'n': NA\n  t: NA\n  f: NA\n---")
  )
)
└── params:
    ├── x: NA
    ├── 'y': NA
    ├── 'n': NA
    ├── t: NA
    └── f: NA

autoquarto attempts to handle the problem by converting any parameter names that appear as TRUE to y and any that appear as FALSE to n, but this obviously is not robust as more than one correct parameter name is mapped to each incorrect one.

Also relevant:

@PuzzledFace PuzzledFace added bug Something isn't working blocked A desirable change/fix/improvement that can't be progressed for some reason labels Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked A desirable change/fix/improvement that can't be progressed for some reason bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant