cboettig / knitcitations

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

output format issue? #40

Closed pH-roc closed 11 years ago

pH-roc commented 11 years ago

Carl,

I really love the package but I am having some trouble. What am I doing wrong?

I am trying to cite some paper using the inline pattern in my .rmd like so:

In a paper `r citet("10.1111/j.1540-5907.2011.00525.x")` make a claim.

When I knit this .rmd (setting cite_options(tooltip=TRUE)) the resulting .md looks like this:

In a paper <span class="showtooltip" title="Greenhill B, Ward M and Sacks A (2011). The Separation Plot: A New Visual Method For Evaluating The Fit of Binary Models. _American Journal of Political Science_, *55*. http://dx.doi.org/10.1111/j.1540-5907.2011.00525.x."><a href="http://dx.doi.org/10.1111/j.1540-5907.2011.00525.x">Greenhill _et. al._ (2011)</a></span> make a claim.

When I then generate the website in jekyll, both the citation link and the tooltip contain the markdown syntax that was generated by knitcitations.

I noticed that the tooltips on your website also contain the markdown but your citations do not. So I assume I am doing something wrong. I can live with the tooltips not being formatted perfectly but it looks kind of silly that the citation in the text looks like this:

In a paper Greenhill _et al._(2011) make a claim.

Any help would be appreciated and I apologize in advance if this is a silly question.

Peter

P.S. I am using the knitcitations version from CRAN. P.P.S. Also is there an option to only trigger the et al. for 4 or more authors instead of 3 or more?

pH-roc commented 11 years ago

Follow up ... after reading through some of the other issues I tried the development version instead of the package that is on CRAN.

Using the development version gives me somewhat different albeit still "broken" results.

I am using the same example as before:

In a paper `r citet("10.1111/j.1540-5907.2011.00525.x")` make a claim.

This time I am getting this:

In a paper <span class="showtooltip" title="<p>Greenhill B, Ward M and Sacks A (2011). &ldquo;The Separation Plot: A New Visual Method For Evaluating The Fit of Binary Models.&rdquo; American Journal of Political Science, 55, pp. 991&ndash;1002. ."><a href="http://dx.doi.org/10.1111/j.1540-5907.2011.00525.x">Greenhill _et. al._ (2011)</a></span> make a claim.

The .md that was knit causes problems with jekyll because the citet function now returns an errant <p> tag. When I manually remove it the tooltip is nicely formatted (i.e. no more markdown). However, the the actually link still comes out as

In a paper Greenhill _et. al._(2011) make a claim.

I hope any of this makes sense.

pH-roc commented 11 years ago

And finally one minor quibble: I think the correct abbreviation for et alia is et al. (currently you have et. al.).

cboettig commented 11 years ago

Thanks for the bug report. The commits above should fix these issues. (Sorry about that, as you can see I was playing around a bit with this in issue #37 and apparently introduced more problems. I'm still a bit undecided if it would be worth implementing the html formatting for the tooltip or leave it in plain text.

For the moment I've just removed the the underscores around et. al., though as I am usually running knitcitations to produce markdown output (despite having the citations in html already), so I believe my markdown parser italicizes the et al. Maybe there is something about your workflow I don't follow that is causing you to get the raw markdown as your final output.

Overall though I should overhaul the inline formatting to handle this (e.g. html-formatted italics) and other things (the abbreviate 3 or more authors, for instance, is also hard-coded.) The inline citation formatting needs to be generalized a bit to handle citing by number instead of author-year too. Haven't really figured out the best way to fix these, but open to advice.

pH-roc commented 11 years ago

Carl,

That was quick and it definitely fixed the issue for me. Also, I think having plain text in the tooltips is perfectly fine anything else would probably be overkill.

(Regarding my workflow, I think I am doing the same thing as you. I use knitr and knitchitations to produce markdown output. But I am not sure why the et al. doesn't get italicized when jekyll generates the html in the next step.)

Anyways, thanks for the quick response. This is a great project. I look forward to seeing where it goes next!

P.S. In tooltips for citations that do not contain an ISSN, a blank space followed by a period is created. The citation below is an example:

citet("10.1111/j.1540-5907.2011.00525.x")

cboettig commented 11 years ago

Thanks for the bug reports! Yeah, I have a handful of things to tidy up on missing entries (particularly for the url/greycite based citations). Good to know about the ISSN thing; the tooltip formatting is based on the built-in / JSS html formatting (which also introduces the stray

tags), so that may actually be a bug in base R.

Glad to hear you got things working with the tooltips btw, I know that's not particularly well documented. The open issues log is the best road-map of things to do, but I'm always open to suggestions or ideas. and definitely drop me a line if you hit some other bugs.

On Mon, Apr 29, 2013 at 10:02 AM, Peter Haschke notifications@github.comwrote:

Carl,

That was quick and it definitely fixed the issue for me. Also, I think having plain text in the tooltips is perfectly fine anything else would probably be overkill.

(Regarding my workflow, I think I am doing the same thing as you. I use knitr and knitchitations to produce markdown output. But I am not sure why the et al. doesn't get italicized when jekyll generates the html in the next step.)

Anyways, thanks for the quick response. This is a great project. I look forward to seeing where it goes next!

P.S. In tooltips for citations that do not contain an ISSN, a blank space followed by a period is created. The citation below is an example:

citet("10.1111/j.1540-5907.2011.00525.x")

— Reply to this email directly or view it on GitHubhttps://github.com/cboettig/knitcitations/issues/40#issuecomment-17179608 .

Carl Boettiger UC Santa Cruz http://www.carlboettiger.info/

pH-roc commented 11 years ago

Right on. I will do that ... I am new to git and apologize for misfiling this. I will let you know if I have ideas, suggestions or encounter other issues.

cboettig commented 11 years ago

Closing this issue as I think it is now resolved... feel free to reopen if I missed something.