Skip to content

Commit

Permalink
Add several changes
Browse files Browse the repository at this point in the history
  • Loading branch information
danielvartan committed Aug 12, 2024
1 parent 32487fc commit a12ddb6
Show file tree
Hide file tree
Showing 84 changed files with 398 additions and 21,121 deletions.
1 change: 0 additions & 1 deletion .Rprofile
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
source("renv/activate.R")
options(renv.download.override = utils::download.file)
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# See <https://git-scm.com/docs/gitignore>.

_freeze/
_print/
_slides/
_web/
.quarto/
.temp/
.Rapp.history
Expand All @@ -9,5 +12,3 @@ _freeze/
.Rhistory
.Rproj.user
.Ruserdata

/.quarto/
9 changes: 5 additions & 4 deletions R/_dev.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# renv::activate()
# renv::deactivate()
# renv::status()
# renv::dependencies("R/quarto-setup.R")
# renv::dependencies("R/_setup.R")
# renv::install()
# renv::update()
# renv::restore()
Expand All @@ -35,8 +35,8 @@

# # Quarto (see <https://quarto.org/docs/projects/quarto-projects.html>)
#
# source(here::here("R", "quarto-pre-render-pdf.R"))
# source(here::here("R", "quarto-pre-render-html.R"))
# source(here::here("R", "_pre-render-pdf.R"))
# source(here::here("R", "_pre-render-html.R"))
#
# quarto render
# quarto render --profile pdf
Expand Down Expand Up @@ -68,7 +68,7 @@
# * Set indentation of unordered and ordered list (see ABNT norms).
# * Add post- and pre-chapters code automatically.
# * Refactor code for creating ambient variables in
# 'quarto-pre-render-common.R' . Transform code into function and then add
# '_pre-render-common.R' . Transform code into function and then add
# it in the {rutils} package.
# * Add function to auto generate the visit date in the thesis reference
# located in '_index-html.qmd'.
Expand All @@ -86,3 +86,4 @@
# * Finish translating `english-abnt-author-date.csl`.
# * Add DOI field into ABNT CSL files.
# * Create `check_quarto_urls()` based on `urlchecker::url_check()`.
# * Create `write_cff()` based on `cffr::cff_write().
17 changes: 17 additions & 0 deletions R/_post-render-clean.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# library(rutils, quietly = TRUE)
# library(here, quietly = TRUE)

dir_list <-
c(".temp", "index_cache", "index_files") |>
append(x = _, list.dirs("qmd")[-1])

rutils:::clean_quarto_mess(
file = NULL,
dir = dir_list,
ext = c(
"aux", "bbx", "cbx", "dbx", "fdb_latexmk", "lbx", "loa", "log", "pdf",
"scss", "tex", "xdv"
),
ignore = NULL,
wd = here::here()
)
File renamed without changes.
11 changes: 2 additions & 9 deletions R/quarto-post-render-html.R → R/_post-render-html.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# library(rutils, quietly = TRUE)
# library(yaml, quietly = TRUE)

source(here::here("R", "quarto-post-render-common.R"))
source(here::here("R", "_post-render-common.R"))

# Copy PDF (if exists) to `output_dir_html` folder ----------

Expand Down Expand Up @@ -37,11 +37,4 @@ writeLines(

# Delete unnecessary files and folders -----

rutils:::clean_quarto_mess(
file = NULL,
dir = c(".temp", "index_cache", "index_files", "qmd/images"),
ext = c("aux", "bbx", "cbx", "cls", "dbx", "fdb_latexmk", "lbx", "loa",
"log", "pdf", "scss", "tex", "xdv"),
ignore = NULL,
wd = here::here()
)
source(here::here("R", "_post-render-clean.R"))
11 changes: 2 additions & 9 deletions R/quarto-post-render-pdf.R → R/_post-render-pdf.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# library(here, quietly = TRUE)
# library(rutils, quietly = TRUE)

source(here::here("R", "quarto-post-render-common.R"))
source(here::here("R", "_post-render-common.R"))

# Copy and rename the PDF file (if exists) to `output_dir_pdf` folder -----

Expand All @@ -23,11 +23,4 @@ if (length(tex_file) == 1) {

# Delete unnecessary files and folders -----

rutils:::clean_quarto_mess(
file = NULL,
dir = c(".temp", "index_cache", "index_files"),
ext = c("aux", "bbx", "cbx", "dbx", "fdb_latexmk", "lbx", "loa", "log",
"otf", "pdf", "tex", "xdv"),
ignore = NULL,
wd = here::here()
)
source(here::here("R", "_post-render-clean.R"))
23 changes: 14 additions & 9 deletions R/quarto-pre-render-common.R → R/_pre-render-common.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ if (!checkmate::test_file_exists(env_vars_file_path)) {
env_vars <- list()

var_files <- c(
"quarto_yml_vars", "quarto_yml_html_vars", "quarto_yml_pdf_vars",
"quarto_yml_extension_vars"
"quarto_yml_extension_vars", "quarto_yml_vars", "quarto_yml_html_vars",
"quarto_yml_pdf_vars"
)

var_patterns <- c(
"academic-title", "academic-degree", "area-of-concentration", "author",
"^book.url$", "cosupervisor", "date", "keyword", "language", "pdf.location$",
"mainfont", "monofont", "program", "sansfont", "school", "supervisor",
"title","type-of-work", "university", "version-note"
"^book.title$","type-of-work", "university", "version-note"
)

for (i in var_files){
Expand All @@ -44,23 +44,24 @@ for (i in var_files){
test <- grepl(j, names(values))

if (any(test, na.rm = TRUE)) {
if (grepl("\\.", j)) {
j <- sub("^.+\\.", "", j)

if (grepl("\\$$", j)) j <- sub("\\$$", "", j)
if (grepl("^\\^", j) || grepl("\\$$", j)) {
j <- sub("^\\^", "", j)
j <- sub("\\$$", "", j)
}

if (grepl("\\.", j)) j <- sub("^.+\\.", "", j)

if (j == "date") {
if (!grepl("\\d{4}", values[test][1]) &&
!any(values[test][1] == "today", na.rm = TRUE)) {
next()
} else if (any(values[test][1] == "today", na.rm = TRUE)) {
env_vars[[j]] <- as.character(Sys.Date())

env_vars[["year"]] <- as.character(lubridate::year(Sys.Date()))
next()
} else {
env_vars[["year"]] <-
as.character(stringr::str_extract(values[test][1], "\\d{4}"))
env_vars[["year"]] <- stringr::str_extract(values[test][1], "\\d{4}")
}
}

Expand Down Expand Up @@ -100,6 +101,10 @@ env_vars |> yaml::write_yaml(env_vars_file_path)
quarto_yml_pdf_path <- here::here("_quarto-pdf.yml")
quarto_yml_pdf_vars <- yaml::read_yaml(quarto_yml_pdf_path)

# (2024-06-05)
# This function only works with BetterBibTeX (BBT) for Zotero version v6.7.140
# or lower.

if (isTRUE(quarto_yml_pdf_vars$format$`abnt-pdf`$zotero)) {
rutils:::bbt_write_quarto_bib(
bib_file = "references.bib",
Expand Down
2 changes: 1 addition & 1 deletion R/quarto-pre-render-html.R → R/_pre-render-html.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# library(rutils, quietly = TRUE)
# lybrary(yaml)

source(here::here("R", "quarto-pre-render-common.R"))
source(here::here("R", "_pre-render-common.R"))

# Update Quarto files -----

Expand Down
72 changes: 36 additions & 36 deletions R/quarto-pre-render-pdf.R → R/_pre-render-pdf.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,150 +2,150 @@
# library(rutils)
# lybrary(yaml)

source(here::here("R", "quarto-pre-render-common.R"))
source(here::here("R", "_pre-render-common.R"))

# Update Quarto files -----

swap_list <- list(
index_h1 = list(
from = here::here("qmd/introduction.qmd"),
from = here::here("qmd", "introduction.qmd"),
to = here::here("index.qmd"),
begin_tag = "%:::% .common h1 begin %:::%",
end_tag = "%:::% .common h1 end %:::%",
value = NULL,
quarto_render = FALSE
),
index_pdf = list(
from = here::here("qmd/introduction.qmd"),
to = here::here("qmd/_index-pdf.qmd"),
from = here::here("qmd", "introduction.qmd"),
to = here::here("qmd", "_index-pdf.qmd"),
begin_tag = "%:::% index pdf begin %:::%",
end_tag = "%:::% index pdf end %:::%",
value = NULL,
quarto_render = FALSE
),
title_page = list(
from = here::here("qmd/_config.qmd"),
to = here::here("tex/include-in-header.tex"),
from = here::here("qmd", "_config.qmd"),
to = here::here("tex", "include-in-header.tex"),
begin_tag = "%:::% title-page body begin %:::%",
end_tag = "%:::% title-page body end %:::%",
value = NULL,
quarto_render = FALSE
),
cataloging_record = list(
from = here::here("qmd/_config.qmd"),
to = here::here("tex/include-before-body.tex"),
from = here::here("qmd", "_config.qmd"),
to = here::here("tex", "include-before-body.tex"),
begin_tag = "%:::% cataloging-record body begin %:::%",
end_tag = "%:::% cataloging-record body end %:::%",
value = NULL,
quarto_render = FALSE
),
errata_reference = list(
from = here::here("qmd/errata.qmd"),
to = here::here("tex/include-before-body.tex"),
from = here::here("qmd", "errata.qmd"),
to = here::here("tex", "include-before-body.tex"),
begin_tag = "%:::% errata reference begin %:::%",
end_tag = "%:::% errata reference end %:::%",
value = NULL,
quarto_render = FALSE
),
errata_body = list(
from = here::here("qmd/errata.qmd"),
to = here::here("tex/include-before-body.tex"),
from = here::here("qmd", "errata.qmd"),
to = here::here("tex", "include-before-body.tex"),
begin_tag = "%:::% errata body begin %:::%",
end_tag = "%:::% errata body end %:::%",
value = NULL,
quarto_render = TRUE
),
approval_sheet = list(
from = here::here("qmd/_config.qmd"),
to = here::here("tex/include-before-body.tex"),
from = here::here("qmd", "_config.qmd"),
to = here::here("tex", "include-before-body.tex"),
begin_tag = "%:::% approval-sheet body begin %:::%",
end_tag = "%:::% approval-sheet body end %:::%",
value = NULL,
quarto_render = FALSE
),
inscription_body = list(
from = here::here("qmd/inscription.qmd"),
to = here::here("tex/include-before-body.tex"),
from = here::here("qmd", "inscription.qmd"),
to = here::here("tex", "include-before-body.tex"),
begin_tag = "%:::% inscription body begin %:::%",
end_tag = "%:::% inscription body end %:::%",
value = NULL,
quarto_render = FALSE
),
acknowledgments_body = list(
from = here::here("qmd/acknowledgments.qmd"),
to = here::here("tex/include-before-body.tex"),
from = here::here("qmd", "acknowledgments.qmd"),
to = here::here("tex", "include-before-body.tex"),
begin_tag = "%:::% acknowledgments body begin %:::%",
end_tag = "%:::% acknowledgments body end %:::%",
value = NULL,
quarto_render = TRUE
),
epigraph_body = list(
from = here::here("qmd/epigraph.qmd"),
to = here::here("tex/include-before-body.tex"),
from = here::here("qmd", "epigraph.qmd"),
to = here::here("tex", "include-before-body.tex"),
begin_tag = "%:::% epigraph body begin %:::%",
end_tag = "%:::% epigraph body end %:::%",
value = NULL,
quarto_render = FALSE
),
vernacular_abstract_reference = list(
from = here::here("qmd/vernacular-abstract.qmd"),
to = here::here("tex/include-before-body.tex"),
from = here::here("qmd", "vernacular-abstract.qmd"),
to = here::here("tex", "include-before-body.tex"),
begin_tag = "%:::% vernacular-abstract reference begin %:::%",
end_tag = "%:::% vernacular-abstract reference end %:::%",
value = NULL,
quarto_render = FALSE
),
vernacular_abstract_body = list(
from = here::here("qmd/vernacular-abstract.qmd"),
to = here::here("tex/include-before-body.tex"),
from = here::here("qmd", "vernacular-abstract.qmd"),
to = here::here("tex", "include-before-body.tex"),
begin_tag = "%:::% vernacular-abstract body begin %:::%",
end_tag = "%:::% vernacular-abstract body end %:::%",
value = NULL,
quarto_render = TRUE
),
vernacular_abstract_keywords = list(
from = here::here("qmd/vernacular-abstract.qmd"),
to = here::here("tex/include-before-body.tex"),
from = here::here("qmd", "/vernacular-abstract.qmd"),
to = here::here("tex", "include-before-body.tex"),
begin_tag = "%:::% vernacular-abstract keywords begin %:::%",
end_tag = "%:::% vernacular-abstract keywords end %:::%",
value = NULL,
quarto_render = FALSE
),
foreign_abstract_reference = list(
from = here::here("qmd/foreign-abstract.qmd"),
to = here::here("tex/include-before-body.tex"),
from = here::here("qmd", "foreign-abstract.qmd"),
to = here::here("tex", "include-before-body.tex"),
begin_tag = "%:::% foreign-abstract reference begin %:::%",
end_tag = "%:::% foreign-abstract reference end %:::%",
value = NULL,
quarto_render = FALSE
),
foreign_abstract_body = list(
from = here::here("qmd/foreign-abstract.qmd"),
to = here::here("tex/include-before-body.tex"),
from = here::here("qmd", "foreign-abstract.qmd"),
to = here::here("tex", "include-before-body.tex"),
begin_tag = "%:::% foreign-abstract body begin %:::%",
end_tag = "%:::% foreign-abstract body end %:::%",
value = NULL,
quarto_render = TRUE
),
foreign_abstract_keywords = list(
from = here::here("qmd/foreign-abstract.qmd"),
to = here::here("tex/include-before-body.tex"),
from = here::here("qmd", "foreign-abstract.qmd"),
to = here::here("tex", "include-before-body.tex"),
begin_tag = "%:::% foreign-abstract keywords begin %:::%",
end_tag = "%:::% foreign-abstract keywords end %:::%",
value = NULL,
quarto_render = FALSE
),
list_of_abbreviations = list(
from = here::here("qmd/list-of-abbreviations.qmd"),
to = here::here("tex/include-before-body.tex"),
from = here::here("qmd", "list-of-abbreviations.qmd"),
to = here::here("tex", "include-before-body.tex"),
begin_tag = "%:::% list-of-abbreviations body begin %:::%",
end_tag = "%:::% list-of-abbreviations body end %:::%",
value = NULL,
quarto_render = TRUE
),
list_of_symbols = list(
from = here::here("qmd/list-of-symbols.qmd"),
to = here::here("tex/include-before-body.tex"),
from = here::here("qmd", "list-of-symbols.qmd"),
to = here::here("tex", "include-before-body.tex"),
begin_tag = "%:::% list-of-symbols body begin %:::%",
end_tag = "%:::% list-of-symbols body end %:::%",
value = NULL,
Expand Down
Loading

0 comments on commit a12ddb6

Please sign in to comment.