Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/gtPublic

Add functionality for passing messages to Quarto#1197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
rich-iannone wants to merge7 commits intomaster
base:master
Choose a base branch
Loading
fromquarto-api-redux
Draft
Show file tree
Hide file tree
Changes fromall 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 deletionDESCRIPTION
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,12 +44,14 @@ Imports:
glue (>= 1.6.1),
htmltools (>= 0.5.2),
juicyjuice (>= 0.1.0),
jsonlite,
magrittr (>= 2.0.2),
rlang (>= 1.0.2),
sass (>= 0.4.1),
scales (>= 1.2.0),
tibble (>= 3.1.6),
tidyselect (>= 1.1.1)
tidyselect (>= 1.1.1),
uuid
Suggests:
covr,
digest (>= 0.6.29),
Expand Down
13 changes: 13 additions & 0 deletionsR/print.R
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,19 @@ knitr_is_word_output <- function() {
#' @noRd
knit_print.gt_tbl <- function(x, ...) {

if (check_quarto()) {
caption_text <- dt_options_get_value(data = x, option = "table_caption")
table_uuid <- random_id()
x <- dt_options_set_value(data = x, option = "table_id", value = table_uuid)

if (!is.na(caption_text)) {
quarto_api_send(
"set_table_caption",
caption = caption_text,
table_id = paste0("table-", table_uuid))
}
}

if (knitr_is_rtf_output()) {

x <- as_rtf(x)
Expand Down
1 change: 1 addition & 0 deletionsR/render_as_html.R
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,6 +40,7 @@ render_as_html <- function(data) {
finalize_html_table(
class = "gt_table",
style = table_defs$table_style,
id = if (check_quarto()) paste0("table-", dt_options_get_value(data, "table_id")),
caption_component,
table_defs$table_colgroups,
heading_component,
Expand Down
40 changes: 40 additions & 0 deletionsR/utils_quarto.R
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
check_quarto <- function() {
Sys.getenv("QUARTO_MESSAGES_FILE") != ""
}

check_knitr <- function() {

if (!requireNamespace("knitr", quietly = TRUE)) {

cli::cli_abort(c(
"Please install the knitr package.",
"*" = "Use `install.packages(\"knitr\")`."
))
}
}

get_uuid <- function() {
uuid::UUIDgenerate()
}

quarto_api_send <- function(message, ...) {

uuid <- get_uuid()

# Ensure that the knitr package is available
check_knitr()

# Generate a JSON-formatted line
line <-
jsonlite::toJSON(
list(
message = message,
uuid = uuid,
payload = list(...)
),
auto_unbox = TRUE
)

file <- Sys.getenv("QUARTO_MESSAGES_FILE")

write(line, file, append = TRUE)

uuid
}

[8]ページ先頭

©2009-2025 Movatter.jp