cboettig / knitcitations

:package: Generate citations for knitr markdown and html files
http://carlboettiger.info
Other
220 stars 28 forks source link

citep(): format accent characters #51

Closed zkamvar closed 10 years ago

zkamvar commented 10 years ago

Hello, this is similar to my previous issue*.

The function citep() doesn't appear to format the accent characters. After digging around, It seems that print.bibentry() calls format.bibentry(), which seems to work some voodoo via Rd files using tools::Rd2txt(). In any case, my hopefully reproducible code is below. Is there any easy way to work the formatting into the inline citations?

library(knitcitations)
x <- structure(list(grunwald2006hierarchical = structure(list(title = "Hierarchical analysis of diversity, selfing, and genetic differentiation in populations of the oomycete Aphanomyces euteiches", 
    author = structure(list(structure(list(given = c("N.", "J."
    ), family = "Gr{\\\"u}nwald", role = NULL, email = NULL, 
        comment = NULL), .Names = c("given", "family", "role", 
    "email", "comment")), structure(list(given = "G.-A.", family = "Hoheisel", 
        role = NULL, email = NULL, comment = NULL), .Names = c("given", 
    "family", "role", "email", "comment"))), class = "person"), 
    journal = "Phytopathology", volume = "96", number = "10", 
    pages = "1134--1141", year = "2006", publisher = "Am Phytopath Society"), .Names = c("title", 
"author", "journal", "volume", "number", "pages", "year", "publisher"
), bibtype = "Article", key = "grunwald2006hierarchical")), .Names = "grunwald2006hierarchical", class = "bibentry")

citep(x)
## [1] "(<a href=\"\">Gr{\\\"u}nwald & Hoheisel, 2006</a>)"

It appears as: (Gr{\"u}nwald & Hoheisel, 2006) when it should be: (Grünwald & Hoheisel, 2006)

Here is my sessionInfo():

R version 3.0.2 (2013-09-25)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] knitcitations_0.5-0 bibtex_0.3-6        knitr_1.5          

loaded via a namespace (and not attached):
[1] digest_0.6.4   evaluate_0.5.1 formatR_0.10   httr_0.2       RCurl_1.95-4.1
[6] stringr_0.6.2  tools_3.0.2    XML_3.95-0.2   xtable_1.7-1 

Thanks! Zhian

*I swear it's not a problem existing between the keyboard and chair this time!

cboettig commented 10 years ago

Yup, looks like a bug on my end in the default text format. Will try and fix soon.

Nowosad commented 10 years ago

Up

cboettig commented 10 years ago

Okay, I still have to fix this, (think I have a good way to improve all the formatting), but meanwhile I'm curious if you might prefer the pandoc-based solution I've just released to address #57? Since pandoc will be handling the final formatting of the inline citation, this should sidestep the issue. (Note that a pandoc markdown parser is set to become a standard part of RStudio as well).