Merge manuscript objects
cjvanlissa opened this issue · comments
So that revisions can be extracted from multiple documents without having to keep them in multiple objects
This sounds good. I'd vote for a function name bind_manuscripts
.
I'm guessing that if PDF text is present in both we'd have no way to merge that content and would just toss it?
We can definitely merge the PDFs too, but I have to understand how that works first... do you have a working example with a PDF?
Here's an example
man <- c("---", "format: 'pdf_document'","---",stringi::stri_rand_lipsum(30),"",
"[text to match]{#findText}","",stringi::stri_rand_lipsum(15))
rmd <- tempfile(fileext = ".rmd")
pdf <- tempfile(fileext = ".pdf")
writeLines(text = man, con = rmd)
rmarkdown::render(input = rmd, output_file = pdf)
revise::read_manuscript(rmd, PDF = pdf)
revise::get_revision("findText")
#> [1] ">text to match\n>\n>\\begin{flushright}Pg. 4\\end{flushright}"
The manuscript object stores all text content per page. get_revision then triggers a search of this content to provide the relevant page number.
So in the example the function successfully finds the line "text to match" as being on page 4.
Perhaps there's no issue here as currently we don't merge the manuscripts into a single object, but rather conduct searches across multiple objects. If both have the same PDF attached then they would give consistent results.