Debugging advice: Look at intermediate files:
keep-typ: true
keep-md: true
This is valid if you produced Raw typst. Currently, you produce Markdown content that will be parsed. In Markdown linebreak is done using two spaces and a new line
(Pandoc - Pandoc User’s Guide)
If you need a hard line break, put two or more spaces at the end of a line.
In the intermediate, you can see that you would produce Markdown content, that will be then converted to typst.
So you could do two spaces and a newline
(UA_string <- params$UAs |> stringr::str_replace_all(" ", " \n"))
Otherwise, if you produce raw content, you need to use specific block or at least use correct typst. From the doc you linked, I do think you need to had newlines after the \
. So I would try
```{r}
#| include: false
# Format the UA string for printing.
(UA_string <- params$UAs |> stringr::str_replace_all(" ", " \\\\\n") |> knitr::raw_block(type = "typst"))
```
## Current NKR UAs (avoids):
`r UA_string`
knitr::raw_block()
will ensure you are setting the content to be Raw Typst- using
`r
and not`{r}
will make sure the content is not escaped. If you are already producing Markdown output, you need to either using`{r} I(<markdown_string>)`
or just usual knitr (See Quarto – Inline Code)
This will produce this Markdown
```{=typst}
A:66 \
B:8,18,35,37,38,39,41,42,54,55,59,64,65,67,73,78 \
Cw:2,4,5,6,7,8,12,15,17,18 \
DR:8,11,12,13,14,17,18 \
DQ:7 \
DQA:04,05,06
```
And Same output as above.
Another variant as example
```{r}
#| include: false
# Format the UA string for printing.
(UA_string <- params$UAs |> stringr::str_replace_all(" ", " \\\\\n"))
```
## Current NKR UAs (avoids):
```{=typst}
`{r} I(UA_string)`
```
Hope it helps understand
Note: I edited your post. Please format correctly next time (FAQ: How to Format R Markdown Source). Thank you !