Skip to content

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

@olivroy

Description

@olivroy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions