Fix incorrect linking of URLs without trailing punctuation in HTML bibliographies
This commit is contained in:
parent
0b05cb34a8
commit
7a4864caf2
|
@ -407,13 +407,11 @@ Zotero.CSL.prototype.formatBibliography = function(itemSet, format) {
|
||||||
if(format == "HTML") {
|
if(format == "HTML") {
|
||||||
var coins = Zotero.OpenURL.createContextObject(item.zoteroItem, "1.0");
|
var coins = Zotero.OpenURL.createContextObject(item.zoteroItem, "1.0");
|
||||||
|
|
||||||
// Wrap URLs in <a href=""> links, in a very unsophisticated manner
|
// Wrap URLs and DOIs in HTML links
|
||||||
//
|
//
|
||||||
// This should be done earlier when the data is still in variables
|
// This should be handled when the values are still in variables
|
||||||
//
|
// (and presumably will be in the new engine)
|
||||||
// Ignore URLs preceded by '>', since these are likely already links
|
string = Zotero.Utilities.prototype.autoLink(string);
|
||||||
string = string.replace(/([^>])(https?:\/\/[^\s]+)([\."'>:\]\)\s])/g, '$1<a href="$2">$2</a>$3');
|
|
||||||
string = string.replace(/(doi:[ ]*)(10\.[^\s]+[0-9a-zA-Z])/g, '$1<a href="http://dx.doi.org/$2">$2</a>');
|
|
||||||
|
|
||||||
var span = (coins ? ' <span class="Z3988" title="'+coins.replace("&", "&", "g")+'"> </span>' : '');
|
var span = (coins ? ' <span class="Z3988" title="'+coins.replace("&", "&", "g")+'"> </span>' : '');
|
||||||
|
|
||||||
|
|
|
@ -203,6 +203,27 @@ Zotero.Utilities.prototype.unescapeHTML = function(/**String*/ str) {
|
||||||
return nsISUHTML.unescape(str);
|
return nsISUHTML.unescape(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap URLs and DOIs in <a href=""> links in plain text
|
||||||
|
*
|
||||||
|
* Ignore URLs preceded by '>', just in case there are already links
|
||||||
|
*/
|
||||||
|
Zotero.Utilities.prototype.autoLink = function (str) {
|
||||||
|
// "http://www.google.com."
|
||||||
|
// "http://www.google.com. "
|
||||||
|
// "<http://www.google.com>" (and other characters, with or without a space after)
|
||||||
|
str = str.replace(/([^>])(https?:\/\/[^\s]+)([\."'>:\]\)](\s|$))/g, '$1<a href="$2">$2</a>$3');
|
||||||
|
// "http://www.google.com"
|
||||||
|
// "http://www.google.com "
|
||||||
|
str = str.replace(/([^">])(https?:\/\/[^\s]+)(\s|$)/g, '$1<a href="$2">$2</a>$3');
|
||||||
|
|
||||||
|
// DOI
|
||||||
|
str = str.replace(/(doi:[ ]*)(10\.[^\s]+[0-9a-zA-Z])/g, '$1<a href="http://dx.doi.org/$2">$2</a>');
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a text string for HTML/XUL markup and returns an array of parts. Currently only finds
|
* Parses a text string for HTML/XUL markup and returns an array of parts. Currently only finds
|
||||||
* HTML links (<a> tags)
|
* HTML links (<a> tags)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user