Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YAML parser error when rendering Quarto document

Tags:

r

yaml

quarto

I was trying to re-render a Quarto document after adding some more code. The code previously rendered fine.

However, this time the render failed, with this error:

Error in yaml::yaml.load(meta, handlers = list(expr = parse_only)) : 
  Parser error: while parsing a block mapping at line 1, column 1 did not find expected key at line 2, column 27
Calls: .main ... FUN -> parse_block -> partition_chunk -> <Anonymous>
Execution halted

I thought this was referring to the YAML bit at the top, but I hadn't made any changes to that, and the document previously rendered fine. I simplified the YAML to the simplest case, but the error persisted.

---
title: "Test"
format: html
---

```{r}
#| label: tbl-exibble
#| tbl-cap: "Exibble Bla Bla")

gt::gt(exibble)
```

This was caused by a typo - I'm posting this and answering it here because I think the error message is not particularly helpful and it might mislead other people

like image 805
Andrea M Avatar asked Jan 27 '26 16:01

Andrea M


1 Answers

The bug lies in the table caption chunk option, not in the YAML block at the start.

I had an extra ) at the end of the line; this fixed it:

---
title: "Test"
format: html
---

```{r}
#| label: tbl-exibble
#| tbl-cap: "Exibble Bla Bla"

gt::gt(exibble)

So if you get YAML parser errors similar to mine, please check your YAML; not only in the top part of the Quarto document, but also in your chunk options.

like image 120
Andrea M Avatar answered Jan 30 '26 05:01

Andrea M



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!