It looks like we're not suppressing the HTML output from OJS in PDF formats. At the very least we should be emitting a better error message.

### Discussed in https://github.com/quarto-dev/quarto-cli/discussions/2334

<div type='discussions-op-text'>

<sup>Originally posted by **Eline2020** September  7, 2022</sup>
I am trying to generate a PDF file using Quarto, but I am getting an error when I try to use ojs_define. When ojs_define is commented out the PDF renders without any issues. The error message is the following: 

> running xelatex - 1
>   This is XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022) (preloaded format=xelatex)
>    restricted \write18 enabled.
>   entering extended mode
> 
> updating tlmgr
> 
> updating existing packages
> 
> compilation failed- error
> LaTeX Error: Missing \begin{document}.
> 
> See the LaTeX manual or LaTeX Companion for explanation.
> Type  H <return>  for immediate help.
>  ...
> 
> l.118 <
>        script type="ojs-define">

I am using R 4.2.1 on Windows and I am using Visual Studio Code, but when I tried in RStudio I got the same error.

For a minimal reproducible example I have the following files: 

_quarto.yml
```
project:
  type: book

book:
  title: "Title"
  author: "Author"
  date: "2022-09-07"
  chapters:
    - index.qmd
    - example.qmd

format:
  pdf:
    documentclass: scrreprt
```

index.qmd (was required to make a book, only includes # Index)

example.qmd
```
# Test

```{r}
#| output: false
df <- data.frame(
    id = c(1, 2, 3, 4, 5),
    value = c(10, 20, 30, 40, 50)
)

ojs_define(df_ojs = df)
```#end R block

I'm really not sure what the issue is, so I would love some help!</div>
cscheid
2022-09-07T16:29:30Z
cscheid
bug ojs-engine
v1.2
closed
Issue with ojs_define and rendering PDF
https://github.com/quarto-dev/quarto-cli/issues/2338