Skip to content

Commit

Permalink
fix tabless
Browse files Browse the repository at this point in the history
  • Loading branch information
Flavio Lozano Isla committed Jun 17, 2024
1 parent 03e7070 commit 350b197
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions R/gdoc2qmd.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) %>%
Expand Down

0 comments on commit 350b197

Please sign in to comment.