quarto-dev / quarto-cli

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

knitr chunk options are not working in a notebook #8644

Open sdoms opened 9 months ago

sdoms commented 9 months ago

Bug description

The knitr chunk options are not being validated for notebooks. Output is still being printed even if "include: false" is provided. Screen Shot 2024-02-08 at 11 46 31 Screen Shot 2024-02-08 at 11 47 08

Steps to reproduce

test.qmd as part of my manuscript:

---
title: Test as part of manuscript
description: test knitr chunk options
data: last-modified
---
## This should not have anything below
```{r}
#| label: test-include-false
#| include: false
warning("this is a warning")
cat("this is output")

This should have only the output

#| label: test-warning-false
#| warning: false
warning("this is a warning")
cat("this is output")
This is the YAML file for that manuscript:

````yml
project: 
  type: manuscript
execute:
  freeze: auto

format:
  html:
    code-fold: true
    code-tools: true
    toc: true
    comments:
      hypothesis: true
  docx: default
  jats: default
  agu-pdf: default
manuscript: 
  article: index.qmd
  notebooks: 
    - taxonomy.qmd
    - functions.qmd
    - test.qmd

Here the chunk options behave as expected as a stand-alone document:

---
title: Test as stand-alone document
description: test knitr chunk options stand-alone document
data: last-modified
---
## This should not have anything below
```{r}
#| label: test-include-false
#| include: false
warning("this is a warning")
cat("this is output")

This should have only the output

#| label: test-warning-false
#| warning: false
warning("this is a warning")
cat("this is output")


### Expected behavior

With the "include: false" chunk option, the code should be executed, but not shown. Neither should warnings be printed. 

### Actual behavior

Output and warnings are printed in a notebook document. 

### Your environment

- IDE: VS code
- Quarto version 1.4.549, but also tested with pre-release 1.5.9
- macOS Monterey 12.7.2

### Quarto check output

Quarto 1.4.549
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.11: OK
      Dart Sass version 1.69.5: OK
      Deno version 1.37.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.4.549
      Path: /Applications/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: v2023.09
      Chromium: (not installed)

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

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

[✓] Checking Python 3 installation....OK
      Version: 3.9.2
      Path: /usr/local/opt/python@3.9/bin/python3.9
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with python3 -m pip install jupyter

[✓] Checking R installation...........OK
      Version: 4.3.1
      Path: /Library/Frameworks/R.framework/Resources
      LibPaths:
        - /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library
      knitr: 1.45
      rmarkdown: 2.25

[✓] Checking Knitr engine render......OK
dragonstyle commented 9 months ago

See also: