nstrayer / datadrivencv

R package for building customizable CVs from spreadsheets
http://nickstrayer.me/datadrivencv/
Other
594 stars 178 forks source link

knit pdf error #29

Closed LainPardo closed 4 years ago

LainPardo commented 4 years ago

I can create my html version but when I try to knit it for the pdf I get this error: Quitting from lines 201-202 (cv_1.Rmd) Error: nm must be NULL or a character vector the same length as x

Any thoughts? thanks

kara-swartz commented 4 years ago

I had the same error when I used square brackets [] in googlesheets. In markdown it's a link

LainPardo commented 4 years ago

Thanks, just double checked and it seems that I am using the syntax correctly. E.g. if I want to read a hyperlink I write [] () doi. I get in the cv only the [] part. In other sections, I use the whole address starting from http: since I noticed if I don´t start from there it won´t be read as a link on the online version. So, not sure, but yes if I get rid of all the links it runs, but I would prefer being able to include them. Cheers. Let´s see if there is another experience. thanks

nstrayer commented 4 years ago

Hi! Sorry for the slow response.

Quick fix: Go into cv_printing_functions.r and replace the lines that start with link_titles <- and link_destinations<- with

    link_titles <- stringr::str_extract_all(text, '(?<=\\[).+?(?=\\]\\()')[[1]]
    link_destinations <- stringr::str_extract_all(text, '(?<=\\]\\().+?(?=\\))')[[1]]

And a few lines below update the second str_replace_all() call to this.

      # Replace the link destination and remove square brackets for title
      text <- text %>%
        stringr::str_replace_all(stringr::fixed(link_superscript_mappings)) %>%
        stringr::str_replace_all('\\[(.+?)\\](?=<sup>)', "\\1")

Slower fix: I have a branch that fixes this that will be merged to master soon so you can update to that and then run:

datadrivencv::use_datadriven_cv(
    which_files = c( "cv_printing_functions.r"),
    open_files = FALSE
)

To get the new version of the cv printing functions script.

What was going on was my regular expressions for grabbing markdown links assumed that any text that was surrounded in square brackets was the title for a markdown link. Now that square bracketed text must be followed by a round bracket for it to be detected.

nstrayer commented 4 years ago

I tested by using the following text for a description:

Thesis: An [agent] based (model) of Diel Vertical Migration patterns of Mysis diluviana

The result looks like this:

image

LainPardo commented 4 years ago

Thank you Nick, it seems to be working now! all the best!