quarto-dev / quarto-cli

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

Failure of multiple inline OJS elements with inline style #5478

Open bifouba opened 1 year ago

bifouba commented 1 year ago

Having more than one inline OJS element ${x} combined with inline styling [foo]{style="color:red;"} fails to render properly, although it works having more than one of one or the other, and having one element combining both.

```{r}
ojs_define(x = "inline OJS")

Multiple inline OJS elements in a single paragraph work: ${x} and ${x}.

Multiple [inline]{style="color: red;"} styles [work]{style="color: red;"}.

One [${x}]{style="color: red;"} element with inline style works in the same paragraph as another [inline style]{style="color: red;"}.

One [${x}]{style="color: red;"} element with inline style works in the same paragraph as another non-styled ${x} element.

One [${x}]{style="color: red;"} element with inline style does not work in the same paragraph as another styled [${x}]{style="color: red;"} element.


This is with `` sessionInfo() ``:

R version 4.3.0 (2023-04-21) Platform: aarch64-apple-darwin20 (64-bit) Running under: macOS Ventura 13.0

Matrix products: default BLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/Vienna tzcode source: internal

attached base packages: [1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] htmlwidgets_1.6.2 compiler_4.3.0 fastmap_1.1.1 cli_3.6.1
[5] tools_4.3.0 htmltools_0.5.5 rstudioapi_0.14 yaml_2.3.7
[9] rmarkdown_2.21 knitr_1.42 xfun_0.39 digest_0.6.31
[13] jsonlite_1.8.4 rlang_1.1.1 evaluate_0.21

mcanouil commented 1 year ago

It appears you did not followed the template for bug reports, could you follow and fill the missing information listed below (extracted from the template)?

Also could you elaborate on "fails to render properly"?

Screenshot 2023-05-10 at 14 20 03
mcanouil commented 1 year ago
See code for Quarto document. ````qmd --- title: "Quarto Playground" format: html --- This is a playground for Quarto. ```{ojs} //| include: false //| echo: false x ``` ```{r} x <- "inline OJS" ojs_define(x) ``` Multiple inline OJS elements in a single paragraph work: ${x} and ${x}. Multiple [inline]{style="color: red;"} styles [work]{style="color: red;"}. One [${x}]{style="color: red;"} element with inline style works in the same paragraph as another [inline style]{style="color: red;"}. One [${x}]{style="color: red;"} element with inline style works in the same paragraph as another non-styled ${x} element. One [${x}]{style="color: red;"} element with inline style **does not work** in the same paragraph as another styled [${x}]{style="color: red;"} element. ````
image

Image generated with Quarto 1.3.340.

bifouba commented 1 year ago

It appears you did not followed the template for bug reports, could you follow and fill the missing information listed below (extracted from the template)?

Also could you elaborate on "fails to render properly"?

Screenshot 2023-05-10 at 14 20 03
  • Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
  • "Please format your issue so it is easier for us to read the bug report."
  • Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
  • Please document the operating system you're running. If on Linux, please provide the specific distribution.
  • Please provide the output of quarto check so we know which version of quarto and its dependencies you're running.

Hi, I see you already managed to reproduce it, but for the sake of completeness:

Thanks!

mcanouil commented 1 year ago

It doesn't let me attach .qmd files, actually.

I did not attached anything, I simply put the content of the Quarto document into a code block with four back ticks as described in the link. 😉

cscheid commented 1 year ago

I'm running Quarto 1.2.335

That is quite an old version, just FYI.

You're seeing a real bug, but unfortunately it's not an easy fix. The problem is that we currently parse ${} expressions from inside Pandoc's AST, and that's a, well, generally impossible task. Pandoc sees some of the statements and tries its own hand at parsing them, and sometimes we step on each other's toes.

I have a plan for improving this, but it's relatively low priority for 1.4.

In the mean-time, can you try using classes on those spans? That might work better.

bifouba commented 1 year ago

Thanks. This is a new install of R, RStudio, and the quarto package, so I'm not sure why I'd end up with an old version that way.

Anyhow, on the matter at hand, thanks for confirming it's a real bug. I'll look into the suggested workaround. For my purposes, even including a not strictly necessary paragraph break is not a deal-breaker, so it's fine for now. I just wanted to bring it to your attention.

bifouba commented 1 year ago

Unfortunately, classes on spans fails just the same.

```{css, echo=FALSE}
span.hilite {
  color: red;
}
ojs_define(x = "inline OJS")

One ${x} element with inline style does not work in the same paragraph as another styled ${x} element.


<img width="1716" alt="Screenshot 2023-05-10 at 17 13 28" src="https://github.com/quarto-dev/quarto-cli/assets/9115276/4b99a7c1-50b8-4fb5-86bd-521b25b6fbb7">
cscheid commented 1 year ago

I mean native spans:

[${x}]{.hilite}

If that doesn't work, then the best I can offer is to wrap the entire thing with a div, and then write the CSS using the div.

bifouba commented 1 year ago

I mean native spans:

[${x}]{.hilite}

If that doesn't work, then the best I can offer is to wrap the entire thing with a div, and then write the CSS using the div.

No luck.

cscheid commented 1 year ago

I'm sorry about that; hopefully we'll fix this by 1.4's release.

bifouba commented 1 year ago

No worries. In the meantime I'll split over multiple paragraphs and make them into mere line breaks visually with negative margins.