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

FR: accept parsing file with no yaml if no --- is found in the file #11

Open
olivroy opened this issue May 31, 2024 · 0 comments
Open

Comments

@olivroy
Copy link
Contributor

olivroy commented May 31, 2024

If some ---, still don't accept, but if none at all, then no chance of confusion, so lightparser could accept it?

Could lightparser add dummy yaml header?

In Quarto projects, it is common not to have yaml header in child docs..

Here is my workaround for now.

split_to_tbl2 <- function(file) {
 tryCatch(
      lightparser::split_to_tbl(file),
      error = function(e) {
        tmp <- withr::local_tempfile(
          lines = c(
            "---",
            "title: dummy",
            "---",
            readLines(file, warn = FALSE)
          )
        )
        lightparser::split_to_tbl(tmp) 
      }
    )
}

Also would be great to add warn = FALSE to call to readLines() to avoid warning on missing final lines.

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

1 participant