Skip to content

Commit

Permalink
Merge pull request #6167 from quarto-dev/fix/check-knitr-cat-rprofile
Browse files Browse the repository at this point in the history
  • Loading branch information
cderv authored Jul 11, 2023
2 parents 9c8bf69 + c97c2ce commit a5a81f5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions news/changelog-1.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
- Exit if project pre or post render script fails
- Use InternalError in typescript code, and offer a more helpful error message when an internal error happens.
- ([#6042](https://github.com/quarto-dev/quarto-cli/issues/6042)): Correctly support empty lines in YAML blocks.
- ([#6154](https://github.com/quarto-dev/quarto-cli/issues/6154)): `quarto check knitr` does not fail anymore when user's `.Rprofile` contains `cat()` calls.

## Docusaurus Format

Expand Down
15 changes: 9 additions & 6 deletions src/core/knitr.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/*
* knitr.ts
*
* Copyright (C) 2020-2022 Posit Software, PBC
*
*/
* knitr.ts
*
* Copyright (C) 2020-2022 Posit Software, PBC
*/

import * as colors from "fmt/colors.ts";

Expand Down Expand Up @@ -44,7 +43,11 @@ export async function knitrCapabilities() {
stdout: "piped",
});
if (result.success && result.stdout) {
const caps = readYamlFromString(result.stdout) as KnitrCapabilities;
const jsonLines = result.stdout
.replace(/^.*--- YAML_START ---/sm, "")
.replace(/--- YAML_END ---.*$/sm, "");

const caps = readYamlFromString(jsonLines) as KnitrCapabilities;
// check knitr requirement
const knitrVersion = caps.packages.knitr
? coerce(caps.packages.knitr)
Expand Down
4 changes: 3 additions & 1 deletion src/resources/capabilities/knitr.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version <- getRversion()
cat("--- YAML_START ---\n")
cat("versionMajor:", version$major, "\n")
cat("versionMinor:", version$minor, "\n")
cat("versionPatch:", version$patch, "\n")
Expand All @@ -21,4 +22,5 @@ if (requireNamespace("rmarkdown", quietly = TRUE)) {
} else {
cat("null")
}
cat("\n")
cat("\n")
cat("--- YAML_END ---\n")

0 comments on commit a5a81f5

Please sign in to comment.