Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/resources/rmd/hooks.R
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,12 @@ knitr_hooks <- function(format, resourceDir, handledLanguages) {
if (identical(options[["results"]], "asis") && !needCell) {
x
} else {
# Newline first and after to ensure Pandoc Fenced Div is correctly parsed
paste0(
"\n",
options[["indent"]], "::: {",
labelId(label), paste(classes, collapse = " ") ,forwardAttr, "}\n", x, "\n", cell.cap ,
options[["indent"]], ":::"
options[["indent"]], ":::\n"
)
}
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: "Untitled"
format: markdown
keep-md: true
engine: julia
---

This does it:

::: {.cell execution_count=1}
``` {.julia .cell-code}
1 + 1
```

::: {.cell-output .cell-output-display execution_count=1}
```
2
```
:::
:::


Other content

12 changes: 12 additions & 0 deletions tests/docs/julia/intermediate-markdown-output/output-cell-div.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: "Untitled"
format: markdown
keep-md: true
engine: julia
---

This does it:
```{julia}
1 + 1
```
Other content
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: "Untitled"
format: markdown
keep-md: true
---

This does it:

::: {.cell execution_count=1}
``` {.python .cell-code}
1 + 1
```

::: {.cell-output .cell-output-display execution_count=1}
```
2
```
:::
:::


Other content

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: "Untitled"
format: markdown
keep-md: true
---

This does it:
```{python}
1 + 1
```
Other content
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: "Untitled"
format: markdown
keep-md: true
---

This does it:

::: {.cell}

```{.r .cell-code}
1 + 1
```

::: {.cell-output .cell-output-stdout}

```
[1] 2
```


:::
:::

Other content
11 changes: 11 additions & 0 deletions tests/docs/knitr/intermediate-markdown-output/output-cell-div.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: "Untitled"
format: markdown
keep-md: true
---

This does it:
```{r}
1 + 1
```
Other content
29 changes: 29 additions & 0 deletions tests/smoke/engine/intermediate-output-markdown.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { dirname, join } from "path";
import { ensureSnapshotMatches, noErrors, printsMessage } from "../../verify.ts";
import { fileLoader } from "../../utils.ts";
import { safeRemoveIfExists } from "../../../src/core/path.ts";
import { testRender } from "../render/render.ts";

// Define engines to test
const engines = [
{ name: "knitr" },
{ name: "jupyter" },
{ name: "julia" }
];

// Run tests for each engine
engines.forEach(engine => {
// Test for engine
const inputQmd = fileLoader(engine.name, "intermediate-markdown-output")("output-cell-div.qmd", "markdown");
const md = join(dirname(inputQmd.input), "output-cell-div.markdown.md");
testRender(inputQmd.input, "markdown", true, [
noErrors,
// Lua Warning are in INFO
printsMessage({ level: "INFO", regex: /WARNING \(.*\)\s+The following string was found in the document: :::/, negate: true}),
ensureSnapshotMatches(md)
], {
teardown: async () => {
safeRemoveIfExists(md);
} });
});

Loading