Skip to content

Commit

Permalink
rticles
Browse files Browse the repository at this point in the history
  • Loading branch information
Flavio Lozano Isla committed Feb 22, 2024
1 parent 5dfb8c4 commit fdebabf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
- Include lattice
- Include LCD

# inti 0.6.5

- Rticles
- Fix title position in article
- Fix figure caption and cross reference

# inti 0.6.4

- Update bootstrap in apps
Expand Down
22 changes: 9 additions & 13 deletions R/figure2qmd.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,32 @@ figure2qmd <- function(text

# path <- tempdir()
# text <- "The experiment was carried out in a complete randomized block design with two irrigation treatments with five replications of each genotype per treatment. In well-watered (WW) treatment, plants were irrigated according to their transpiration demand ([Figure @fig:id.z21kyltlev9z]:A) and in water deficit (WD) treatment, the water supply was gradually reduced until the wilting point [(Ray & Sinclair, 1998)](https://www.zotero.org/google-docs/?y2XuVg). At 35 dap, before the stress initiation, the pots were watered to soaking and then allowed to drain overnight [(Bhatnagar-Mathur et al., 2007)](https://www.zotero.org/google-docs/?aBxXpi). The next morning, the pots were sealed in a plastic bag secured with a twist tie to prevent water loss except by transpiration and arranged in the greenhouse according to the experimental design. Thereafter, all the pots were weighed and this weight was defined as the initial pot weight. The inter-daily weight of the pots was measured for ten days to calculate the initial dry down parameters for treatment application ([Figure @fig:id.z21kyltlev9z]:B). The WD treatment started at 45 dap which coincides with the beginning of tuber initiation."
# text <- "![(A) Fraction of transpirable soil water (FTSW). (B) Daily transpiration in 15 potato genotypes under well-watered (WW) and water deficit (WD) conditions.](img_0.png){#fig-id.olts8je85fk5}"
# text <- "![Essays grading during the implementation of journal club during two academic semesters in years 2021 and 2022 for synchronous e-learning at plant genetics lectures in five different sections. The grading system was from 0 to 20, where 20 is the highest grade. Results were based on the grading book from the five sections with a total of 90 students.](img_3.png){#fig:id.y18qqmtszisb}"
# text <- "![Choose the images. {{fig-width: “50%”, echo: true}}](img_1.png){#fig:id.bzfoh3m13vt1}"
# text <- "![null|null](img_3.jpg)"
# text <- "@fig:id.y18qqmtszisb"

# text %>% gsub(".+\\{\\{(.+)\\}\\}(.+)", "\\1", .)
# text <- "![null|null](img_5.jpg) \t\n\r\v\f"

# result %>% cat()
# 'manuscript/img_0.jpg​' %>% gsub('\u200B', '', .)


result <- if(isTRUE(grepl("^\\!\\[", text))) {

opt <- text %>%
tibble::enframe(name = "num") %>%
dplyr::mutate(img = gsub(".+](.*)", "\\1", .data$value)) %>%
dplyr::mutate(label = gsub(".+\\{\\#fig\\:(.*)\\}", "\\1", .data$value)) %>%
dplyr::mutate(caption = gsub("\\!\\[(.*)\\]\\(.+", "\\1", .data$value)) %>%
dplyr::mutate(img = gsub(".+]\\((.*)\\)\\{.+", "\\1", .data$value)) %>%
dplyr::mutate(img = gsub("[[:space:]]", "", .data$img)) %>%
dplyr::mutate(img = gsub("\u200B", "", .data$img)) %>%
dplyr::mutate(img = gsub("\\(|\\)", "", .data$img)) %>%
dplyr::select(!c(.data$value)) %>%
tidyr::pivot_longer(!.data$num) %>%

dplyr::mutate(opt = dplyr::case_when(
.data$name %in% "id" ~ paste0("#| label: ", .data$value)
, .data$name %in% "title" ~ paste0("#| fig-cap: '", .data$value, "'")
, .data$name %in% "img" ~ paste0("\nknitr::include_graphics('", file.path(path, .data$value) %>% gsub("\\\\", "\\/", .),"')")
.data$name %in% "label" ~ paste0("#| label: ", "fig-",.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("\\\\", "\\/", .),"')")
)) %>%
tidyr::drop_na(.data$opt) %>%
dplyr::select(.data$opt) %>%
dplyr::mutate(opt = gsub("[[:space:]]", "", .data$opt)) %>%
purrr::as_vector() %>%
paste0(collapse = "\n")

Expand Down
5 changes: 3 additions & 2 deletions R/gdoc2qmd.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ gdoc2qmd <- function(file
tibble::add_row(value = "\\newpage", .before = which(grepl("# discussion", .$value, ignore.case = TRUE))) %>%
{
if (any(grepl(pattern = '# abstract', x = .$value, ignore.case = TRUE))) {
tibble::add_row(.data = ., value = paste(tt, sep = "\n\n"),
.before = which(x = grepl(pattern = "# abstract", x = .$value, ignore.case = TRUE)))
tibble::add_row(.data = ., value = paste(tt, "\n\n"),
.before = which(x = grepl(pattern = "# abstract", x = .$value
, ignore.case = TRUE)))
} else {.}
} %>%
dplyr::select(.data$value) %>%
Expand Down

0 comments on commit fdebabf

Please sign in to comment.