Skip to content

Commit f4474df

Browse files
authored
Merge pull request #2 from A2-ai/whitespace_fix
triming whitespace after magic string so filename is correct.
2 parents 4fc2327 + 6be6bab commit f4474df

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

R/add_tables.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#' )
2929
#' }
3030
add_tables <- function(docx_in, docx_out, tables_path, debug = F) {
31-
log4r::debug(.le$logger, "Starting add_tables_by_magic_string function")
31+
log4r::debug(.le$logger, "Starting add_tables function")
3232
tictoc::tic()
3333

3434
if (!file.exists(docx_in)) {
@@ -69,7 +69,7 @@ add_tables <- function(docx_in, docx_out, tables_path, debug = F) {
6969

7070
if (length(matches) > 0) {
7171
log4r::info(.le$logger, paste0("Found magic string: ", matches[1], " in paragraph ", i))
72-
table_name <- gsub("\\{rpfy\\}:", "", matches[1]) # Remove "{rpfy}:"
72+
table_name <- gsub("\\{rpfy\\}:", "", matches[1]) |> trimws() # Remove "{rpfy}:"
7373
table_file <- file.path(tables_path, table_name)
7474
#if (tools::file_ext(table_file) %in% c("RDS", "csv")) {
7575

inst/scripts/add_figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def add_figure(docx_in, docx_out, figure_dir, fig_width, fig_height):
2020
print(f"Duplicate figure names found in paragraph {i+1}.")
2121
for match in matches:
2222
# Extract the image directory from the match
23-
figure_name = match.replace("{rpfy}:", "")
23+
figure_name = match.replace("{rpfy}:", "").strip()
2424
found_magic_strings.append(figure_name)
2525

2626
image_path = os.path.join(figure_dir, figure_name)

inst/scripts/add_figure_footnotes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def add_figure_footnotes(docx_in, docx_out, figure_dir, footnotes_yaml):
2626
if matches:
2727
for match in matches:
2828
# Generalized extraction of the figure name
29-
figure_name = match.replace("{rpfy}:", "")
29+
figure_name = match.replace("{rpfy}:", "").strip()
3030
if figure_name in os.listdir(figure_dir):
3131

3232
object_name, extension = os.path.splitext(figure_name)

inst/scripts/add_table_footnotes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def add_table_footnotes(docx_in, docx_out, table_dir, footnotes_yaml):
2626
if matches:
2727
for match in matches:
2828
# Generalized extraction of the figure name
29-
table_name = match.replace("{rpfy}:", "")
29+
table_name = match.replace("{rpfy}:", "").strip()
3030
if table_name in os.listdir(table_dir):
3131
object_name, extension = os.path.splitext(table_name)
3232
metadata_file = os.path.join(table_dir, f"{object_name}_{extension[1::]}_metadata.json")

0 commit comments

Comments
 (0)