Skip to content

Provide good message for --- possibly interpreted as malformed YAML block #33

@cderv

Description

@cderv

This comes from unexpected edge case example at

Take this simple document

---
title: "Anova test"
date: 2022-09-12
format: html
keep-md: true
---

```{r}
knitr::opts_chunk$set(echo = FALSE, message = TRUE, warning = FALSE)
```

---
# Anova test

```{r}
# Create a simple dataset
set.seed(123)
x1 <- rnorm(100)
x2 <- rnorm(100)
y <- 2*x1 + 3*x2 + rnorm(100)
data <- data.frame(y = y, x1 = x1, x2 = x2)

# Fit two nested models
model1 <- lm(y ~ x1, data = data)
model2 <- lm(y ~ x1 + x2, data = data)

# Compare the models using anova()
anova(model1, model2)
```

the part with the hrule

---
# Anova test

Quarto render

Error running Lua:
YAML parse exception at line 7, column 0,
while scanning for the next token:
found character that cannot start any token
stack traceback:
        ...oop\apps\quarto\current\share\pandoc\datadir\readqmd.lua:170: in function 'readqmd.readqmd'
        ...s\scoop\apps\quarto\current\share\filters\qmd-reader.lua:13: in function 'Reader'
WARN: Error encountered when rendering files

will be interpreted as a YAML block start because anova() does produce another --- inside the code block

Intermediate .md

---
title: "Anova test"
date: 2022-09-12
format: html
keep-md: true
---


::: {.cell}

```{.r .cell-code}
knitr::opts_chunk$set(echo = FALSE, message = TRUE, warning = FALSE)
```
:::


---
# Anova test


::: {.cell}
::: {.cell-output .cell-output-stdout}

```
Analysis of Variance Table

Model 1: y ~ x1
Model 2: y ~ x1 + x2
  Res.Df    RSS Df Sum of Sq      F    Pr(>F)    
1     98 932.12                                  
2     97  87.78  1    844.34 933.01 < 2.2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
```


:::
:::

And this fails as some YAML is tried to be parsed.

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