From 350b1978f3f79c0d6278df3f0997324becd12543 Mon Sep 17 00:00:00 2001 From: Flavio Lozano Isla Date: Mon, 17 Jun 2024 14:42:26 -0500 Subject: [PATCH] fix tabless --- R/gdoc2qmd.R | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/R/gdoc2qmd.R b/R/gdoc2qmd.R index a2c2093..dc513cb 100644 --- a/R/gdoc2qmd.R +++ b/R/gdoc2qmd.R @@ -83,7 +83,7 @@ gdoc2qmd <- function(file fig <- txt %>% dplyr::filter(grepl("#fig", .data$value)) %>% - dplyr::group_split(.data$value) %>% + split(1:nrow(.)) %>% purrr::map_dfr(~ add_row(.x, .before = grepl("#fig", .x))) %>% { if(length(.) != 0) { @@ -117,18 +117,16 @@ gdoc2qmd <- function(file dplyr::filter(grepl("^\\|", .data$value) | grepl("#tbl", .data$value)) %>% { if(nrow(. > 1)) { - dplyr::mutate(.data = ., group = case_when( grepl(pattern = "^:", x = .data$value) ~ as.character(.data$name) , TRUE ~ NA )) %>% - tibble::as_tibble(x = .) %>% - tidyr::fill(data = ., "group", .direction = "up", ) %>% + tidyr::fill(data = ., group, .direction = "up") %>% tidyr::drop_na(data = ., .data$group) %>% dplyr::group_by(.data = ., .data$group) %>% dplyr::slice(.data = ., n(), 1:(n() - 1)) %>% dplyr::ungroup() %>% - dplyr::group_split(.tbl = ., .data$group) %>% + split(1:nrow(.)) %>% purrr::map_dfr(~ add_row(.x, .after = grepl("#tbl", .x))) %>% dplyr::mutate(.data = ., across(.data$value, ~ ifelse(is.na(.), "\\newpage", .))) %>% dplyr::select(.data = ., !.data$group) %>%