Automatically add link if provided by BibTeX

Issue #23 closed
Andreas Purde repo owner created an issue

Automatically add the link to the cite in case it is provided by BibTeX.

Comments (9)

  1. Andreas Purde reporter

    Short update here: citeproc-java and the underlying code do not seem to have implemented the howpublished field. This might be a show-stopper for this request.

  2. Marco Kuper

    Hi Andreas, thank you for working on the issue. I did some digging as well as i was implementing it myself too. First, I welcome the change to use html, as i think this is the appropriate way to use citeproc-java anyway.

    Edit: I have to correct myself, didn't look at the commit properly. Looks very good. Don't think it is a problem, that howpublished is not converted.

  3. Marco Kuper

    I think the regex you used to replace the div tags is a bit fragile, as the class returned by citeproc-java does not seem to always be the same. I've created a pull request with a more generic version.

    May I ask why you replace the i tags with em?

  4. Andreas Purde reporter

    Dear Marco,

    thank you for contribution by providing the changes:

    1. With the code you suggested you remove all div and /div tags leaving the inner part. However when you look at the sample provided from citeproc-java there are two inner parts. The number of the cite and the cite. So you still need to remove the number or am I wrong?
    <div class="csl-bib-body">
      <div class="csl-entry">
        <div class="csl-left-margin">[1]</div>
        <div class="csl-right-inline">M. Krämer, “citeproc-java: A Citation Style
          Language (CSL) processor for Java,” 20-Nov-2016. [Online]. Available:
          http://michel-kraemer.github.io/citeproc-java/. [Accessed: 01-Nov-2017].
        </div>
      </div>
    </div>
    
    1. I replace <i> by <em> because we need Confluence storage format not html.
    2. What kind of experience did you make to say that to original code is not robust?
    3. I still think the missing "howpublished" field mapping is a show-stopper for that improvement as it means I would have to evaluate the BibTeX file on my own what I don't plan right now.

    Kind regards

    Andreas

  5. Marco Kuper

    Hi Andreas,

    I'll give you a defintive answer for 1) later today, as I don't have access to my code at the moment. There I have a Test case which fails with the current implementation. This is also linked to my statement that it might not be robust. Currently, if for some reason the supplied Strings do not match, everything is replaced by an empty String. You are right however, that my solution does not take the numbers into consideration. I will have a look at this again. Alternatively one could consider using Jsoup, as was suggested here: https://stackoverflow.com/questions/240546/remove-html-tags-from-a-string. This seems to be a pretty clean solution, as it would make removing the number much easier too. In regards to 3), as I said for me personally being able to use the URL field is enough, so I don't mind that howpublished is not converting links. If you really want to get this enabled as well, I would suggest taking a look at the VariableWrapper Interface which you can pas as a constructor argument to CSL. With this, you can freely alter formatting for every CSL field seperately and could therefore add links to the howpublished field yourself. Again, for me personally this would not be necessary.

  6. Marco Kuper

    Hi Andreas,

    I looked at my Test case again and figured out what is causing the different html strings. If using "ieee" as a style, I get

      <div class="csl-entry">
        <div class="csl-left-margin">[1]</div>
        <div class="csl-right-inline">T. H. Davenport, “Saving IT’s soul: Human-centered information management.,” <i>Harvard business review</i>, vol. 72, no. 2, pp. 119–31, 1994.</div>
      </div>
    

    a style of "chicago-author-date" however returns

    <div class="csl-entry">Davenport, Thomas H. 1994. “Saving IT’s Soul: Human-Centered Information Management.” <i>Harvard Business Review</i>, Harvard business review, 72 (2). ERIC: 119–31. https://eric.ed.gov/?id=EJ478837.</div>
    

    I think relying so closely on the exact return values of a foreign library is a risky endeavor. That's why I would suggest to use something like Jsoup for the alterations and ideally wrap the responsible parts of your code a little bit more explicitly.

    I will see if I can alter my version and also provide the Test case so that we can work against the same requirement.

  7. Andreas Purde reporter

    Dear Mark,

    thank you for the input. I temporary went back to text output as html has some more issues - there are CSL formats which also include a span which I might need to remove etc. I will pick up the ball again soon.

    Kind regards

    Andreas

  8. Andreas Purde reporter
    • changed status to open

    the included URL can be added as link automatically if provided in the BibTeX entry with the release

  9. Log in to comment