-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7829 from quarto-dev/knitr-eng-sql-wrapping
- Loading branch information
Showing
6 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
knitr_fixup = function() | ||
return { | ||
-- https://github.com/quarto-dev/quarto-cli/issues/4869 | ||
-- knitr:::eng_sql is badly design and escape our cell-output wrapping in R | ||
-- so we need to fix it up here by detecting the <div> which will be seen as DIV because | ||
-- we use +native_divs by default | ||
Div = function(e) | ||
if e.classes:includes("knitsql-table") then | ||
return pandoc.Div(e.content, { class = "cell-output-display" }) | ||
end | ||
return e | ||
end | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Pandoc = function(doc) | ||
local found = false | ||
doc.blocks:walk({ | ||
Div = function(div) | ||
if div.classes:includes("cell-output-display") then | ||
found = true | ||
end | ||
end | ||
}) | ||
if not found then | ||
error("Should have found a wrapping cell here") | ||
crash_with_stack_trace() | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
title: cell output display wrapping for sql engine | ||
engine: knitr | ||
format: html | ||
filters: | ||
- at: pre-quarto | ||
path: check-output-display.lua | ||
--- | ||
|
||
```{r} | ||
#| echo: false | ||
library(DBI) | ||
con <- dbConnect(RSQLite::SQLite(), ":memory:") | ||
dbWriteTable(con, "mtcars", mtcars) | ||
``` | ||
|
||
```{sql} | ||
#| column: margin | ||
#| connection: con | ||
select cyl from mtcars limit 5 | ||
``` |