Skip to content

Commit

Permalink
updt articles
Browse files Browse the repository at this point in the history
  • Loading branch information
Flavjack committed Aug 29, 2024
1 parent 38be898 commit 98a1fe8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions R/figure2qmd.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) %>%
Expand Down
3 changes: 3 additions & 0 deletions R/gdoc2qmd.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) %>%
Expand Down
2 changes: 1 addition & 1 deletion R/table2qmd.R
Original file line number Diff line number Diff line change
Expand Up @@ -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() %>%
Expand Down

0 comments on commit 98a1fe8

Please sign in to comment.