42 lines
927 B
Plaintext
42 lines
927 B
Plaintext
---
|
|
subtitle: "Abstract"
|
|
author: ""
|
|
---
|
|
|
|
```{r}
|
|
#| out-width: 80%
|
|
fig <- dwfun::ggsavep("./figures/GA.pdf", loadit = TRUE)
|
|
if (!is.null(fig)) fig
|
|
```
|
|
|
|
```{r}
|
|
#| output: asis
|
|
# function
|
|
extract_abstract <- function(file) {
|
|
content <- readLines(file, warn = FALSE)
|
|
abstract_line <- grep("^# Abstract[^:]", content, ignore.case = TRUE)[1]
|
|
if (length(abstract_line) == 0) return(NA)
|
|
start <- abstract_line + 1
|
|
while (start <= length(content) && trimws(content[start]) == "") {
|
|
start <- start + 1
|
|
}
|
|
if (start > length(content)) return(NA)
|
|
end <- start
|
|
while (
|
|
end <= length(content) &&
|
|
trimws(content[end]) != "" &&
|
|
!grepl("^#", content[end])
|
|
) {
|
|
end <- end + 1
|
|
}
|
|
paste(content[start:(end - 1)], collapse = " ")
|
|
}
|
|
# extract
|
|
file <- "./MS/MS.qmd"
|
|
abstract <- rmarkdown::yaml_front_matter(file)$abstract
|
|
if (is.null(abstract)) {
|
|
abstract <- extract_abstract(file)
|
|
}
|
|
cat(abstract)
|
|
```
|