Skip to content

Commit

Permalink
Support space between fences and language in fenced code block when a…
Browse files Browse the repository at this point in the history
…pplying collapse option (#2347)
  • Loading branch information
cderv committed May 30, 2024
1 parent 493aec0 commit f50b75b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/actions/checkout-knitr-examples/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ runs:
echo '::debug::On pull request'
branch=$(gh api repos/yihui/knitr-examples/branches | jq -cr '.[] | select(.name == '\"$headref\"') | .name')
fi
echo ::set-output name=ref::$(echo $branch)
echo "ref=$(echo $branch)" >> "$GITHUB_OUTPUT"
shell: bash
- name: Retrieve knitr-examples
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: knitr
Type: Package
Title: A General-Purpose Package for Dynamic Report Generation in R
Version: 1.47.1
Version: 1.47.2
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
person("Abhraneel", "Sarma", role = "ctb"),
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGES IN knitr VERSION 1.48

## BUG FIXES

- Fix regression from 1.46 with `collapse = TRUE` option not correctly collapsing source code and output into one when code chunk returns multiple outputs (thanks, @jennybc, @florisvdh, tidyverse/reprex#463).

# CHANGES IN knitr VERSION 1.47

Expand Down
2 changes: 1 addition & 1 deletion R/hooks-md.R
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ hooks_markdown = function(strict = FALSE, fence_char = '`') {
x = gsub('[\n]+$', '', x)
x = gsub('^[\n]+', '\n', x)
if (isTRUE(options$collapse)) {
r = sprintf('\n([%s]{3,})\n+\\1((\\{[.])?%s[^\n]*)?\n', fence_char, tolower(options$engine))
r = sprintf('\n([%s]{3,})\n+\\1((\\{[.]| )?%s[^\n]*)?\n', fence_char, tolower(options$engine))
x = gsub(r, '\n', x)
x = gsub(asis_token, '', x, fixed = TRUE)
}
Expand Down

0 comments on commit f50b75b

Please sign in to comment.