Commits

Frank Bennett  committed b0d338e

Implement cite-group-delimiter

  • Participants
  • Parent commits c99ca5f

Comments (0)

Files changed (5)

File src/api_cite.js

         this.tmp.splice_delimiter = this.citation.opt["after-collapse-delimiter"];
     } else if (this.tmp.have_collapsed && this.opt.xclass === "in-text" && this.opt.update_mode !== CSL.NUMERIC) {
         this.tmp.splice_delimiter = ", ";
+    } else if (this.tmp.use_cite_group_delimiter) {
+        this.tmp.splice_delimiter = this.citation.opt.cite_group_delimiter;
     } else if (this.tmp.cite_locales[pos - 1]) {
         //
         // Must have a value to take effect.  Use zero width space to force empty delimiter.

File src/attributes.js

     }
 };
 
+CSL.Attributes["@cite-group-delimiter"] = function (state, arg) {
+    if (arg) {
+        state[state.tmp.area].opt.cite_group_delimiter = arg;
+    }
+};
+
 
 
 CSL.Attributes["@names-delimiter"] = function (state, arg) {

File src/node_citation.js

             // grouped sorts.
             // print("in cs:citation END");
             state.opt.grouped_sort = state.opt.xclass === "in-text" 
-                && state.citation.opt.collapse 
-                && state.citation.opt.collapse.length
+                && (state.citation.opt.collapse 
+                    && state.citation.opt.collapse.length)
+                || (state.citation.opt.cite_group_delimiter
+                    && state.citation.opt.cite_group_delimiter.length)
                 && state.opt.update_mode !== CSL.POSITION
                 && state.opt.update_mode !== CSL.NUMERIC;
             
                 && state.citation_sort.opt.sort_directions.length) {
                 
                 var firstkey = state.citation_sort.opt.sort_directions[0].slice();
-                // print("extending sort keys "+state.citation_sort.opt.sort_directions+" with "+firstkey);
+                //print("extending sort keys "+state.citation_sort.opt.sort_directions+" with "+firstkey);
                 state.citation_sort.opt.sort_directions = [firstkey].concat(state.citation_sort.opt.sort_directions);
                 // print("new key directions in effect: "+state.citation_sort.opt.sort_directions);
             }
         };
         CSL.debug("Using collation sort");
     } catch (e) {
+        CSL.debug("Using localeCompare sort");
         strcmp = function (a, b) {
             return a.toLocaleLowerCase().localeCompare(b.toLocaleLowerCase());
         };

File src/util_names_output.js

     }
     if ((this.item && this.item["suppress-author"] && this._first_creator_variable == this.variables[0])
         || (this.state[this.state.tmp.area].opt.collapse 
-            && this.state[this.state.tmp.area].opt.collapse.length)) {
+            && this.state[this.state.tmp.area].opt.collapse.length)
+        || (this.state[this.state.tmp.area].opt.cite_group_delimiter 
+            && this.state[this.state.tmp.area].opt.cite_group_delimiter.length)) {
 
         if (this.state.tmp.authorstring_request) {
             // Avoid running this on every call to getAmbiguousCite()?
             this.state.tmp.offset_characters = oldchars;
             this.state.registry.authorstrings[this.Item.id] = mystr;
         } else if (!this.state.tmp.just_looking
-            && !this.state.tmp.suppress_decorations) {
-
+                   && !this.state.tmp.suppress_decorations && (this.item["suppress-author"] || (this.state[this.state.tmp.area].opt.collapse && this.state[this.state.tmp.area].opt.collapse.length) || this.state[this.state.tmp.area].opt.cite_group_delimiter && this.state[this.state.tmp.area].opt.cite_group_delimiter)) {
             // XX1 print("RENDER: "+this.Item.id);
             mystr = "";
             myqueue = this.state.tmp.name_node.top.blobs.slice(-1)[0].blobs;
             }
             if (mystr === this.state.tmp.last_primary_names_string) {
             
-                // XX1 print("    CUT!");
-                this.state.tmp.name_node.top.blobs.pop();
-                this.state.tmp.name_node.children = [];
-                // If popped, avoid side-effects on character counting: we're only interested
-                // in things that actually render.
-                this.state.tmp.offset_characters = oldchars;
+                if (this.item["suppress-author"] || (this.state[this.state.tmp.area].opt.collapse && this.state[this.state.tmp.area].opt.collapse.length)) {
+                    // XX1 print("    CUT!");
+                    this.state.tmp.name_node.top.blobs.pop();
+                    this.state.tmp.name_node.children = [];
+                    // If popped, avoid side-effects on character counting: we're only interested
+                    // in things that actually render.
+                    this.state.tmp.offset_characters = oldchars;
+                }
+                // Needed
+                this.state.tmp.use_cite_group_delimiter = false;
             } else {
                 // XX1 print("remembering: "+mystr);
                 this.state.tmp.last_primary_names_string = mystr;
                     // A wild guess, but will usually be correct
                     this.state.tmp.term_predecessor = false;
                 }
-                // Arcane and probably unnecessarily complicated
+                // Arcane and probably unnecessarily complicated?
                 this.state.tmp.have_collapsed = false;
+                // Needed
+                if (this.state[this.state.tmp.area].opt.cite_group_delimiter && this.state[this.state.tmp.area].opt.cite_group_delimiter) {
+                    this.state.tmp.use_cite_group_delimiter = true;
+                }
             }
         }
     }