quarto-dev / quarto-dev/quarto-cli

knitr chunk options are not working in a notebook

Open
#8,644 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug manuscript
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

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
```{r}
#| label: test-warning-false
#| warning: false
warning("this is a warning")
cat("this is output")
```

This is the YAML file for that manuscript:

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
```{r}
#| 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with test.qmd in the manuscript project configuration, then compare its notebook rendering with the standalone document behavior. Check how the knitr include and warning options are handled for notebooks; done means include: false suppresses output and warnings while warning: false suppresses warnings but preserves output.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.