diff --git a/R/figure2qmd.R b/R/figure2qmd.R index 7fd32ff..346f06d 100644 --- a/R/figure2qmd.R +++ b/R/figure2qmd.R @@ -42,9 +42,9 @@ figure2qmd <- function(text tidyr::pivot_longer(!.data$num) %>% dplyr::mutate(opt = dplyr::case_when( .data$name %in% "label" ~ paste0("#| label: ", "fig-",.data$value) - , .data$name %in% "caption" ~ paste0("#| fig-cap: '", .data$value, "'") + , .data$name %in% "caption" ~ paste0('#| fig-cap: "', .data$value, '"') , .data$name %in% "opts" ~ .data$value %>% gsub(",", "\n#|", .) %>% paste("#|", .) - , .data$name %in% "img" ~ paste0("\nknitr::include_graphics('", file.path(path, .data$value) %>% gsub("\\\\", "\\/", .),"')") + , .data$name %in% "img" ~ paste0('\nknitr::include_graphics("', file.path(path, .data$value) %>% gsub("\\\\", "\\/", .),'")') )) %>% tidyr::drop_na(.data$opt) %>% dplyr::select(.data$opt) %>% diff --git a/R/gdoc2qmd.R b/R/gdoc2qmd.R index e39a0f3..54b5ef7 100644 --- a/R/gdoc2qmd.R +++ b/R/gdoc2qmd.R @@ -119,6 +119,9 @@ gdoc2qmd <- function(file grepl("#tbl", .data$value) ~ .data$name )) %>% tidyr::fill(., .data$group, .direction = "up") %>% + dplyr::mutate(group = case_when( + group %in% NA ~ 1 + )) %>% split(.$group) %>% purrr::map_dfr(~ slice(.data = ., c(n(), 1:(n()-1)))) %>% split(.$group) %>% diff --git a/R/table2qmd.R b/R/table2qmd.R index b9595ee..45b41ef 100644 --- a/R/table2qmd.R +++ b/R/table2qmd.R @@ -26,7 +26,7 @@ table2qmd <- function(text, type = "asis") { tidyr::pivot_longer(!.data$num) %>% dplyr::mutate(opt = dplyr::case_when( .data$name %in% "id" ~ paste0("#| label: ", .data$value) - , .data$name %in% "title" ~ paste0("#| tbl-cap: '", .data$value, "'") + , .data$name %in% "title" ~ paste0('#| tbl-cap: "', .data$value, '"') )) %>% dplyr::select(.data$opt) %>% purrr::as_vector() %>%