Skip to content

Close leftover panel tabsets when knitr chunks error - #104

Open
maxkarlsson wants to merge 1 commit into
mainfrom
cursor/handle-unclosed-tabsets-179d
Open

Close leftover panel tabsets when knitr chunks error#104
maxkarlsson wants to merge 1 commit into
mainfrom
cursor/handle-unclosed-tabsets-179d

Conversation

@maxkarlsson

Copy link
Copy Markdown
Collaborator

Description

When the Experiment Summary is rendered with chunk error tolerance, a failed chunk could leave a Quarto {.panel-tabset} fence unclosed. That leaked into later markdown and broke the rest of the report.

This change tracks tabset depth in open_tabset() / close_tabset(), closes leftover fences from tabset_plotlist() / tabset_nested_plotlist() on error, and registers a knitr chunk hook that appends any missing ::: fences if a chunk fails after opening a tabset.

Report setup calls register_tabset_chunk_hooks(). .qmd chunks that used to cat() the opening fence now call open_tabset().

Type of change

  • Bug fix
  • New feature
  • Breaking change

How Has This Been Tested?

  • Added unit tests for tabset depth tracking and flushing leftover fences.
  • Added a knitr document test: a chunk that opens a tabset then stop()s still emits a closing fence before later markdown.
  • Existing tabset_plotlist / tabset_nested_plotlist capture.output expectations are unchanged.

R is not available in this Cloud Agent environment, so tests were not executed here. Please run devtools::test() / R CMD check in CI.

PR checklist:

  • I have run R CMD check on the package and it passes.
  • I have made changes to the documentation.
  • I have added tests.
  • I have documented any significant changes in CHANGELOG.md
Open in Web Open in Cursor 

Track panel-tabset depth in open_tabset()/close_tabset() and register a
knitr chunk hook that emits missing closing fences if a chunk fails
after opening a tabset, so later report sections still parse.

Co-authored-by: max.karlsson <max.karlsson@pixelgen.com>
@maxkarlsson
maxkarlsson marked this pull request as ready for review September 4, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants