monperrus / bibtexbrowser

Beautiful publication lists with bibtex and PHP (standalone or in Wordpress)
http://www.monperrus.net/martin/bibtexbrowser/
84 stars 53 forks source link

Cannot show correctly for URLs #40

Closed i2000s closed 8 years ago

i2000s commented 9 years ago

As I was rewriting some codes in the bibtexbrowser.php file to solve the bibtex link problem discussed in #39, I found URLs with dots/periods in the url cannot be shown correctly. For example, if I click the _[bibtex]_ link under a bibtex entry, there shows the following bibtex info:

@Article{Baldwin2014Quantum,
  Title                    = {Quantum process tomography of unitary and near-unitary maps},
  Author                   = {Baldwin, Charles H. and Kalev, Amir and Deutsch, Ivan H.},
  Journal                  = {Phys. Rev. A},
  Year                     = {2014},

  Month                    = {Jul},
  Pages                    = {012110},
  Volume                   = {90},

  Arxiv                    = {1404.2877},
  Doi                      = {10.1103/PhysRevA.90.012110},
  Gsid                     = {13589829371783546640},
  Issue                    = {1},
  Numpages                 = {10},
  Publisher                = {American Physical Society},
  Timestamp                = {2015.09.09},
  Url                      = {10.1103/PhysRevA.90.012110">http://link.aps.org/doi/10.1103/PhysRevA.90.012110}
}

Notice that the _Url_ entry has a value looking strange. Obviously, it uses the URL address for the pdf entry, while having the incompleted 10.1103/PhysRevA.90.012110"> as a part of the <a href="http://link.aps.org/doi/10.1103/PhysRevA.90.012110">...</a>.

Should this bug be fixed easily? Thanks.

i2000s commented 9 years ago

I think this occurs when the doi field is also a part of the url field. So, in function toEntryUnformatted(), it searches the url field and replaced with a hyperlink, and then the function searches the doi field and replace the keywords both in the current url link and doi field text with the link code. In the end, the searching string and then replacing with a link strategy messed up the bibtex code in output...

A quick fix is to switch the order of url and doi and others in the $hyperlinks array. Could it be better to limit the replacement operation only to the corresponding field where the text will be linked to a URL address? Thanks.

Update: the quick fix can be found in the code of #41 . But the URL link is replaced by the DOI link and did not really solve the problem.

monperrus commented 8 years ago

Looking at Url = {10.1103/PhysRevA.90.012110">http://link.aps.org/doi/10.1103/PhysRevA.90.012110}.

Is it the original bibtex field? or the one output by bibtexbrowser?

i2000s commented 8 years ago

That's the output from bibtexbrowser. The original one should be

Url                      = {http://link.aps.org/doi/10.1103/PhysRevA.90.012110}
monperrus commented 8 years ago

could you try the latest version?

i2000s commented 8 years ago

That works! See here. Thanks.

BTW, I added the arXiv entry in my forked master branch. Feel free to merge to your master branch, if you think it is useful.

monperrus commented 8 years ago

I added the arXiv entry in my forked master branch

Excellent. Could you create a pull request with this change only?

i2000s commented 8 years ago

I will do it when I got a chance later...