Skip to content

Commit 359a643

Browse files
authored
fixup rmd 'always_allow_html' error message (#1729)
fixup rmd 'always_allow_html' error message (#1729)
1 parent 7e34906 commit 359a643

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

news/changelog-1.1.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
- Correct handling of `knitr::include_graphics()` within inline expressions.
1010

11+
# RMarkdown
12+
13+
- improve error message for HTML being emitted in non-HTMl formats (#1745)
14+
1115
## Pandoc
1216

1317
- Update to Pandoc 2.19

src/execute/rmd.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ export const knitrEngine: ExecutionEngine = {
116116
);
117117
}
118118

119+
output = filterAlwaysAllowHtml(output);
120+
119121
return output;
120122
},
121123
);
@@ -283,3 +285,16 @@ async function printCallRDiagnostics() {
283285
info("");
284286
}
285287
}
288+
289+
function filterAlwaysAllowHtml(s: string): string {
290+
if (
291+
s.indexOf(
292+
"Functions that produce HTML output found in document targeting",
293+
) !== -1
294+
) {
295+
s = s
296+
.replace("your rmarkdown file", "your quarto file")
297+
.replace("always_allow_html: true", "prefer-html: true");
298+
}
299+
return s;
300+
}

0 commit comments

Comments
 (0)