From 5aae6bc9ce5cfd6ed4b5bbedef2b0a221b0c46ba Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 21 Mar 2009 20:08:57 +0000 Subject: [PATCH] Hack to wrap URLs and DOIs in HTML bibliography output in links -- regexps might need to be improved --- chrome/content/zotero/xpcom/csl.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/chrome/content/zotero/xpcom/csl.js b/chrome/content/zotero/xpcom/csl.js index 69e445995..a147c2a68 100644 --- a/chrome/content/zotero/xpcom/csl.js +++ b/chrome/content/zotero/xpcom/csl.js @@ -407,6 +407,14 @@ Zotero.CSL.prototype.formatBibliography = function(itemSet, format) { if(format == "HTML") { var coins = Zotero.OpenURL.createContextObject(item.zoteroItem, "1.0"); + // Wrap URLs in links, in a very unsophisticated manner + // + // This should be done earlier when the data is still in variables + // + // Ignore URLs preceded by '>', since these are likely already links + string = string.replace(/([^>])(https?:\/\/[^\s]+)([\.">:])/g, '$1$2$3'); + string = string.replace(/(doi:[ ]*)([0-9][^\s]+[0-9])/g, '$1$2'); + var span = (coins ? '  ' : ''); if(this.class == "note" && isCitation) {