commit f02ae027c5effb6555918ffcf04523e94f40b07f
parent 53a838c3d676d0ddc949a586cb930e63c4b19198
Author: Simon Kornblith <simon@simonster.com>
Date: Sun, 21 Aug 2011 21:31:27 +0000
Allow page numbers > 1 character to be entered inline
Diffstat:
1 file changed, 29 insertions(+), 14 deletions(-)
diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js
@@ -153,21 +153,36 @@ var Zotero_QuickFormat = new function () {
var str = _getEditorContent();
var haveConditions = false;
+ const specifiedLocatorRe = /,? *(pp|p)(?:\. *| +)([0-9\-]+) *$/;
+ const yearPageLocatorRe = /,? *([0-9]+) *((B[. ]*C[. ]*|B[. ]*)|[AC][. ]*|A[. ]*D[. ]*|C[. ]*E[. ]*)?,? *(?:([0-9\-]+))?$/i;
+ const creatorSplitRe = /(?:,| *(?:and|\&)) +/;
+ const charRe = /[\w\u007F-\uFFFF]/;
+ const numRe = /^[0-9\-]+$/;
+ const etAl = " et al.";
+
+ var m,
+ year = false,
+ isBC = false,
+ dateID = false;
+
+ curLocator = false;
+ curLocatorLabel = false;
+
+ // check for adding a number onto a previous page number
+ if(numRe.test(str)) {
+ // add to previous cite
+ var node = _getCurrentEditorTextNode();
+ var prevNode = node.previousSibling;
+ if(prevNode && prevNode.citationItem && prevNode.citationItem.locator) {
+ prevNode.citationItem.locator += str;
+ prevNode.value = _buildBubbleString(prevNode.citationItem);
+ node.nodeValue = "";
+ _clearEntryList();
+ return;
+ }
+ }
+
if(str && str.length > 1) {
- const specifiedLocatorRe = /,? *(pp|p)(?:\. *| +)([0-9\-]+) *$/;
- const yearPageLocatorRe = /,? *([0-9]+) *((B[. ]*C[. ]*|B[. ]*)|[AC][. ]*|A[. ]*D[. ]*|C[. ]*E[. ]*)?,? *(?:([0-9\-]+))?$/i;
- const creatorSplitRe = /(?:,| *(?:and|\&)) +/;
- const charRe = /[\w\u007F-\uFFFF]/;
- const etAl = " et al.";
-
- var m,
- year = false,
- isBC = false,
- dateID = false;
-
- curLocator = false;
- curLocatorLabel = false;
-
// check for specified locator
m = specifiedLocatorRe.exec(str);
if(m) {