quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.76k stars 306 forks source link

_variable.yml variables that contain arbitrary markdown are treated as strings #4624

Open longapalooza opened 1 year ago

longapalooza commented 1 year ago

Bug description

Variables in my _variable.yml file that are arbitrary markdown content are not interpreted as markdown when my .qmd file is rendered. The variable behaves as a simple string. My .qmd file is shown below.

---
title: Test
---

:::{.content-hidden when-format="revealjs"}

My content for HTML

{{< var slide.open >}}
My content for revealjs
{{< var slide.close >}}

My other content for HTML

:::

My _variable.yml has the following keys

slide:
    open: |
        :::
        :::{.content-visible when-format="revealjs"}
    close: |
        :::
        :::{.content-hidden when-format="revealjs"}

The rendered output looks like

Test
MODIFIED
Fr 2023-03-03 22:01

My content for HTML

::: :::{.content-visible when-format=“revealjs”}

My content for revealjs

::: :::{.content-hidden when-format=“revealjs”}

My other content for HTML

Is this the intended behavior? I've tried some other arbitrary markdown (e.g., **) and have yet to be successful. The documentation leads me to believe that any arbitrary markdown may be used, but that doesn't seem to be the case. Using links as provided in the example in the documentation seems to work, though.

I'm using Windows 10 with the 2022.12.0 Build 353 of RStudio, and the 1.3.208 version of quarto.

Checklist

cscheid commented 1 year ago

Ok, I know what the issue is. When we say "arbitrary markdown", we expect the content itself to be well-formed markdown. You're attempting to add content that when spliced into the markdown, yields valid markdown, but the problem is that the content itself changes the markup around it (you're attempting to close the previous div and open a new one).

We should clarify this distinction in the documentation, but we don't support that on purpose (and this isn't a bug), because it would make parsing the document impossible in general, since your var content could arbitrarily change the structure of the document.

I'm going to switch this to a documentation enhancement.

longapalooza commented 1 year ago

Good deal. I figured it wasn't a bug, and I was just misunderstanding something. I appreciate the clarification.

I'd like to say that I recently just discovered Quarto, and it is pretty much exactly what I've been looking for for a while. I appreciate the hard work you all have put into developing it. So thanks!