Giter VIP home page Giter VIP logo

Comments (11)

GeoBosh avatar GeoBosh commented on May 30, 2024

Thanks for the report. As you suspected, the error is caused by the symbols encoded with the html % codes. If the "%-encoded letters are replaced with the actual letters, as in
"http://www.physics.arizona.edu/~cronin/Solar/References/Irradiance Models and Data/GUE93.pdf",
the command works:

testbib2 <-
"@article{gueymard_critical_1993,
title = {Critical {Analysis} and {Performance} {Assessment} of {Clear} {Sky} {Solar} {Irradiance} {Models} using {Theoretical} and {Measured} {Data}},
 volume = {51},
 url = {http://www.physics.arizona.edu/~cronin/Solar/References/Irradiance Models and Data/GUE93.pdf},
 number = {2},
 journal = {Solar Energy},
 author = {Gueymard, Christian A.},
 year = {1993},
 pages = {121--138}
 }"

bibfname2 <- tempfile()
writeLines( text = testbib2, con = bibfname2)
b <- get_bibentries( bibfile = bibfname2 )
b

In fact, the command succeeds also with the percent-encoded url - the error comes only when the result is printed, since the percents confuse the default print method. This is a known conundrum with bibentry objects. If you assign the result, you can then print it in various styles:

testbib <- "@article{gueymard_critical_1993,\n\ttitle = {Critical {Analysis} and {Performance} {Assessment} of {Clear} {Sky} {Solar} {Irradiance} {Models} using {Theoretical} and {Measured} {Data}},\n\tvolume = {51},\n\turl = {http://www.physics.arizona.edu/%7ecronin/Solar/References/Irradiance%20Models%20and%20Data/GUE93.pdf},\n\tnumber = {2},\n\tjournal = {Solar Energy},\n\tauthor = {Gueymard, Christian A.},\n\tyear = {1993},\n\tpages = {121--138}\n}\n"
bibfname <- tempfile()
writeLines( text = testbib, con = bibfname  )
a <- get_bibentries( bibfile = bibfname )

print(a, style = "html")
print(a, style = "BibTeX")
print(a, style = "citation")

(edit on 2018-03-01 - the example with percents gives errors - I somehow messed up the testing of the above code and didn't get errors the other day.)

Would this resolve your problem?

bug.zip

from rdpack.

jdnewmil avatar jdnewmil commented on May 30, 2024

Thanks for following up, but the workaround doesn't resolve my problem:

a) The percents are needed to make the URL clearly distinguishable as having single spaces [1]

b) I am actually using the insertRef macro in roxygen documentation per Rdpack recommendation.

c) I think the parameter option is "format"?

d) The output of "print(a, format="latex")" still has a superflous period and closing curly brace that confuses LaTeX. The presence of these characters may be the original trigger for the other problems.

[1] https://stackoverflow.com/questions/497908/is-a-url-allowed-to-contain-a-space

from rdpack.

GeoBosh avatar GeoBosh commented on May 30, 2024

As you get the error when using insertRef macro, that is a bug which I will need to sort out somehow.
Have you checked if it works when you produce html documentation instead of pdf?

I think that the argument for print is "style", see ?print.bibentry but I see the error with print(a, style = "latex"), as well.

from rdpack.

jdnewmil avatar jdnewmil commented on May 30, 2024

I am seeing the both the error and spurious brace+period with several versions of your print statement [1]. As for building the help in html... the warning messages and extra brace are in the html print output anyway.

[1] test2.zip

from rdpack.

GeoBosh avatar GeoBosh commented on May 30, 2024

I pushed a draft solution for the problem - insertRef should now work smoothly with percent encoded entries. Could you check? For the moment I have actually included the reference from your example in REFERENCES.bib in Rdpack and it is cited in ?inserRef - I checked that the links are ok in the html and pdf versions of the doc.

Please note that I have not touched get_bibentries yet.

from rdpack.

jdnewmil avatar jdnewmil commented on May 30, 2024

v0.5-6 fixed insertref, which solves my immediate problem... thank you! As you indicated, get_bibentries still gives warnings and prints extra characters after the url.

from rdpack.

jdnewmil avatar jdnewmil commented on May 30, 2024

Looking forward to v0.6 so I can add a minimum version dependency in my DESCRIPTION file. Or, use two-dot version notation...

from rdpack.

GeoBosh avatar GeoBosh commented on May 30, 2024

I cleaned up a little bit and updated also get_bibentries(), further details are oin NEWS. By the way, do you use get_bibentries() or just came to it in the process of investigating the bug concerning insertRef?

I will bump the version to 0.6 once I do a further round of testing or get a confirmation from you that it looks ok. If you are about to submit a package depending on it on CRAN, I will publish it but otherwise I would prefer to delay a little bit since I had two releases in less than two months.

from rdpack.

jdnewmil avatar jdnewmil commented on May 30, 2024

from rdpack.

GeoBosh avatar GeoBosh commented on May 30, 2024

For R it doesn't matter, 0.5.6 and 0.5-6 are the same, you can use dots. I probably didn't know that 8-10 years ago when I started using it and equally there seems little point in changing it now.

Thanks for going into the trouble of searching for the cause of the warnings. If you wonder what is the difference between get_bibentries and insert_ref - here It is. insertRef needs to convert the reference to Rd format by definition. I actually think that the bug there is in tools::toRd, which I use to do that. There are two reasons why I thing this is so. First, WRE explicitly stated that special letters should be percent encoded and the percents escaped. Second, leaving the percents unescaped in Rd text creates invalid Rd text, as you discovered. Even more,there is a case to argue that toRd should actually percent encoded special symbols.

On the other hand, get_bibentries creates a bibentry object and in principle it is not clear if percents should be escaped there. Actually, what matters is how these are exported by the print methods for the different styles. There is no universally applicable solutions since some hinted styles do the escaping themselves, but most simply transfer the content of the URL field.
Now get_bibentries() returns an object from a class with a print method which ensures (or so I hope) that the links produced in the basic styles are fine. (The processing is not ideal but can be remedied if the need arises.)

from rdpack.

GeoBosh avatar GeoBosh commented on May 30, 2024

After the debugging and improvement of get_bibentries() prompted by your comments, I switched \insert_ref to calling it. \insertRef now handles percent encoded URL's everywhere, not only in the url field.
(%'s used for other purposes may cause trouble but can be dealt with if the need arises).

It is sufficient to require Rdpack (>= 0.6).

Thanks again.

from rdpack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.