Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning prints onto PDF #22

Open
ailich opened this issue Jan 14, 2022 · 3 comments
Open

Warning prints onto PDF #22

ailich opened this issue Jan 14, 2022 · 3 comments

Comments

@ailich
Copy link

ailich commented Jan 14, 2022

When I create the mydown package as in the example, and then use the template without any editing, I'm getting an R code warning printed at the top

Screenshot 2022-01-14 170908

sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.0.4  fastmap_1.1.0   mydown_0.1      htmltools_0.5.2 tools_4.0.4     yaml_2.2.1      rmarkdown_2.11  knitr_1.36     
[9] xfun_0.23       digest_0.6.27   rlang_0.4.10    evaluate_0.14 
@krlmlr
Copy link
Collaborator

krlmlr commented Jan 16, 2022

Thanks for the report. This looks like a problem that would only occur on Windows.

We need to think more about the mapping language to locale in a platform-independent way.

Can you please tweak the generated cd_format_date() function to use a supported locale, e.g. "English_United States.1252" ?

@christophsax
Copy link
Member

I think cd_format_date() should not rely on the system, but instead do something as discussed in #12.

@ailich
Copy link
Author

ailich commented Jan 16, 2022

@krlmlr changing "en_US" to "English_United States.1252" removed the warning for me on Windows.

cd_format_date <- function(date, lang = default(rmarkdown::metadata$lang, "en-US")) {
  date <- as.Date(date)
  if (lang %in% c("german", "de-DE", "de-CH")) {
    withr::with_locale(c("LC_TIME" = "de_DE"), format(date, "%e. %B %Y"))
  } else {
    withr::with_locale(c("LC_TIME" = "English_United States.1252"), format(date, "%B %e, %Y"))
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants