Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contents shortcode does not work on code-cell div with knitr #12065

Open
mcanouil opened this issue Feb 11, 2025 · 0 comments
Open

Contents shortcode does not work on code-cell div with knitr #12065

mcanouil opened this issue Feb 11, 2025 · 0 comments
Assignees
Labels
bug Something isn't working knitr shortcodes issues related to shortcodes triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone.

Comments

@mcanouil
Copy link
Collaborator

mcanouil commented Feb 11, 2025

Bug description

It appears {{< contents ID >}} cannot move code-cells with an ID when the engine is set to knitr.

I'm not sure what the limitation actually is:

Currently, {{< contents >}} itself does not work inside code elements. We may lift that limitation in the future.

Steps to reproduce

Jupyter (works)knitr (does not work)
Div
---
title: "Quarto Playground"
format: html
engine: jupyter
---

## Section 1

```{python}
#| label: my-figure
import matplotlib.pyplot as plt
plt.plot([1,2,3])
```

## Section 2

{{< contents my-figure >}}
---
title: "Quarto Playground"
format: html
engine: knitr
---

## Section 1

```{r}
#| label: my-figure
plot(1:10)
```

## Section 2

{{< contents my-figure >}}
Cross-ref Div
---
title: "Quarto Playground"
format: html
engine: jupyter
---

## Section 1

```{python}
#| label: fig-figure
import matplotlib.pyplot as plt
plt.plot([1,2,3])
```

## Section 2

{{< contents fig-figure >}}
---
title: "Quarto Playground"
format: html
engine: knitr
---

## Section 1

```{r}
#| label: fig-figure
plot(1:10)
```

## Section 2

{{< contents fig-figure >}}

Expected behavior

Content is moved without warning.

Actual behavior

WARNING (/Users/mcanouil/Projects/quarto/quarto-cli/src/resources/filters/./quarto-pre/contentsshortcode.lua:79) [Malformed document] Found `contents` shortcode without a corresponding div with id: my-figure.
This might happen because the shortcode is used in div context, while the id corresponds to a span.
Removing from document.
WARNING (/Users/mcanouil/Projects/quarto/quarto-cli/src/resources/filters/./quarto-pre/contentsshortcode.lua:79) [Malformed document] Found `contents` shortcode without a corresponding div with id: fig-figure.
This might happen because the shortcode is used in div context, while the id corresponds to a span.
Removing from document.

Your environment

No response

Quarto check output

Quarto 99.9.9
[✓] Checking environment information...
      Quarto cache location: /Users/mcanouil/Library/Caches/quarto
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.4.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.46.3: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 99.9.9
      commit: b822c3f5cc2b7dd57238bed2bcbbd2c2ed7688b8
      Path: /Users/mcanouil/Projects/quarto/quarto-cli/package/dist/bin

[✓] Checking tools....................OK
      TinyTeX: v2025.02
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /Users/mcanouil/Library/TinyTeX/bin/universal-darwin
      Version: 2024

[✓] Checking Chrome Headless....................OK
      Using: Chrome found on system
      Path: /Applications/Brave Browser.app/Contents/MacOS/Brave Browser
      Source: QUARTO_CHROMIUM

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.13.2
      Path: /Users/mcanouil/Projects/quarto/quarto-playground/.venv/bin/python
      Jupyter: 5.7.2
      Kernels: julia-1.11, python3

[✓] Checking Jupyter engine render....OK

(|) Checking R installation...........ℹ R version 4.4.2 (2024-10-31)
! Config '~/.Rprofile' was loaded!
[✓] Checking R installation...........OK
      Version: 4.4.2
      Path: /Library/Frameworks/R.framework/Resources
      LibPaths:
        - /Users/mcanouil/Projects/quarto/quarto-playground/renv/library/macos/R-4.4/aarch64-apple-darwin20
        - /Users/mcanouil/Library/Caches/org.R-project.R/R/renv/sandbox/macos/R-4.4/aarch64-apple-darwin20/f7156815
      knitr: 1.46
      rmarkdown: 2.29

[✓] Checking Knitr engine render......OK
@mcanouil mcanouil added bug Something isn't working triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. shortcodes issues related to shortcodes labels Feb 11, 2025
@cderv cderv added the knitr label Feb 13, 2025
@cderv cderv self-assigned this Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working knitr shortcodes issues related to shortcodes triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone.
Projects
None yet
Development

No branches or pull requests

3 participants