Project

General

Profile

« Previous | Next » 

Revision 60181

[Library|Trunk]

Citations:
- update library and use citation-js
- allow download for bibtex and ris formats
- update bibtext cls

Result landing: update checks for no index tag

View differences:

modules/uoa-services-library/trunk/ng-openaire-library/src/app/landingPages/landing-utils/citeThis/citeThis.component.ts
10 10
import {Citation, CitationData} from './citation.class';
11 11
import {ResultLandingInfo} from "../../../utils/entities/resultLandingInfo";
12 12
import {DOCUMENT} from "@angular/common";
13
import {EnvProperties} from "../../../utils/properties/env-properties";
14
import {properties} from "../../../../../environments/environment";
13 15

  
14
declare var CSL: any;
15
declare var Sys: any;
16
declare var UIkit: any;
17

  
16
declare var Cite: any;
17
// Based on https://citation.js.org/api/tutorial-getting_started.html browser release
18 18
//<citeThis ></citeThis>
19 19
@Component({
20 20
  selector: 'citeThis',
......
38 38
          <span class="uk-margin-small-left">COPY</span>
39 39
        </button>
40 40
      </div>
41
      <div *ngIf="properties.environment == 'development'" class="uk-margin-small-top">
42
        <mat-form-field class="matSelectionFormField uk-width-1-1">
43
          <mat-label>Or select file format to download</mat-label>
44
          <mat-select class="matSelection" id="fileformats" name="fileformatsSelect" [(ngModel)]="selectedFormat"
45
                      (ngModelChange)="formatChanged()"
46
                      [disableOptionCentering]="true"
47
                      panelClass="matSelectionPanel">
48
            <mat-option *ngFor=" let  format of citation.fileFormats let i = index"
49
                        [value]="format">{{format + " (" +citation.fileSuffix[i] + ")"}}</mat-option>
50
          </mat-select>
51
        </mat-form-field>
52
       
53
       <!-- <div *ngIf="selectedFormat">
54
          <div id="citation" class="box-content uk-margin-small-top uk-overflow-auto uk-padding-small" [innerHTML]="fileText"></div>
55
        </div>-->
56
        <button class="  uk-button uk-button-primary uk-button-small copy uk-margin-small-top uk-icon uk-float-right"
57
                title="Copy to clipboard" [disabled]="!selectedFormat" (click)="downloadFile()">
58
          <span class="custom-icon " uk-icon="download"></span>
59
          <span class="uk-margin-small-left">Download</span>
60
        </button>
61
      </div>
41 62
    </div>
42 63
  `
43 64
})
44 65
export class CiteThisComponent implements OnInit, OnDestroy {
45
  private sub: any;
46 66
  public selectedStyle: string = null;
67
  public selectedFormat: string = null;
68
  public fileText: string;
69
  properties:EnvProperties;
47 70
  public citationText: string;
48 71
  public citation: Citation = new Citation();
49
  // public cite: any;
50 72
  @Input() result: ResultLandingInfo;
51 73
  @Input() id: string;
52 74
  @Input() type: string = "article";
53
  public citeproc;
54
  public data;
75
  public data:CitationData;
55 76
  public clipboard;
56 77
  timeout;
78
  cite;citeConfig;
57 79
  constructor( @Inject(DOCUMENT) private document, private rendererFactory: RendererFactory2){
58

  
59

  
60 80
}
61 81
  ngOnInit() {
82
    this.properties = properties;
62 83
    try{
63
    if (!this.document.getElementById('citeThisScript')) {
64
      const renderer = this.rendererFactory.createRenderer(this.document, {
65
        id: '-1',
66
        encapsulation: ViewEncapsulation.None,
67
        styles: [],
68
        data: {}
69
      });
70
      const head = this.document.head;
71
      if (head === null) {
72
        throw new Error('<head> not found within DOCUMENT.');
84
      if (!this.document.getElementById('citationjs')) {
85
        const renderer = this.rendererFactory.createRenderer(this.document, {
86
          id: '-1',
87
          encapsulation: ViewEncapsulation.None,
88
          styles: [],
89
          data: {}
90
        });
91
        const head = this.document.head;
92
        if (head === null) {
93
          throw new Error('<head> not found within DOCUMENT.');
94
        }
95
        const script = renderer.createElement('script');
96
        renderer.setAttribute(script, "id", "citationjs");
97
        renderer.setAttribute(script, "src", "assets/common-assets/citation-0.4.0-9.min.js");
98
        renderer.setAttribute(script, "type", "text/javascript");
99
        renderer.appendChild(head, script);
100
        this.timeout = setTimeout(() => {
101
          const script2 = renderer.createElement('script');
102
          renderer.setAttribute(script2, "type", "text/javascript");
103
          renderer.setProperty(script2,  "text","const Cite = require('citation-js')");
104
          renderer.appendChild(head, script2);
105
        }, 300);
73 106
      }
74
      const script = renderer.createElement('script');
75
      renderer.setAttribute(script, "id", "citeThisScript");
76
      renderer.setAttribute(script, "src", "assets/common-assets/citeproc.js");
77
      renderer.setAttribute(script, "type", "text/javascript");
78
      renderer.appendChild(head, script);
79
    }
80 107
    this.timeout = setTimeout(() => {
108
      this.citeConfig = Cite.plugins.config.get('csl');
109
      this.cite = new Cite();
81 110
      this.parseData();
82 111
      this.selectedStyle = this.citation.templates[0];
83
      this.updateCitation();
112
      this.selectedFormat = this.citation.fileFormats[0];
113
      this.styleChanged();
114
      this.formatChanged();
84 115
      this.createClipboard();
85 116
    }, 800);
86 117

  
......
119 150
      }
120 151
    }
121 152
    citationData.id = this.id;
122
    if (this.result.types != undefined && this.result.types.length > 0 && this.result.types[0]) {
123
      citationData.type = this.result.types[0].toLowerCase();
124
    }
153
    citationData.type =  this.mapTypes();
125 154
    if (this.result.title) {
126 155
      citationData.title = this.result.title;
127 156
    }
......
178 207
    
179 208
    
180 209
    this.data = citationData;
181
    // console.log(this.data);
210
    this.cite.set(this.data);
182 211
    
183 212
  }
184
  
213
  private mapTypes(){
214
    if (this.result.types != undefined && this.result.types.length > 0) {
215
      if(this.result.types.indexOf("Article") != -1) {
216
        return "article";
217
      }else if(this.result.types.indexOf("Conference object") != -1){
218
        return "paper-conference";
219
      }else if( this.result.types[0]){
220
        return this.result.types[0].toLowerCase();
221
      }
222
    }
223
    return "";
224
  }
185 225
  styleChanged() {
186
    this.updateCitation();
226
    this.citationText  = this.get(this.selectedStyle);
187 227
    
188 228
  }
189
  
190
  updateCitation() {
191
    var Sys =
192
      function Sys(lang, data) {
193
        this.lang = lang;
194
        this.data = data;
195
        this.changeName = function (name) {
196
          this.lastName = name;
197
        };
198
        this.retrieveLocale = function (lang) {
199
          
200
          return this.lang;
201
        }
202
        this.retrieveItem = function (id) {
203
          return this.data;
204
        }
205
      };
229
  formatChanged() {
230
    this.fileText = this.get(this.selectedFormat, false);
231
  }
232
  downloadFile(){
233
    if (typeof document !== 'undefined') {
234
      var url = window.URL.createObjectURL(new Blob([this.fileText]));
235
      var a = window.document.createElement('a');
236
      window.document.body.appendChild(a);
237
      a.setAttribute('style', 'display: none');
238
      a.href = url;
239
      a.download = this.selectedFormat + this.citation.fileSuffix[this.citation.fileFormats.indexOf(this.selectedFormat)];
240
      a.click();
241
      window.URL.revokeObjectURL(url);
242
      a.remove(); // remove the element
243
    }
244
  }
245

  
246
  get(style:string, isBibliography:boolean = true){
206 247
    try {
207
      var citeproc = new CSL.Engine(new Sys(this.citation.locale, this.data), this.citation[(this.selectedStyle == "0") ? this.citation.templates[0] : this.selectedStyle]);
208
      citeproc.updateItems([this.data.id]);
209
      this.citationText = citeproc.makeBibliography();
210
      this.citationText = ((this.citationText != null) && (this.citationText.length > 1) && (this.citationText[1].length > 0)) ? this.citationText[1][0] : '';
248
      if (!isBibliography  && style != "bibtex") {
249
        return this.getFormat(style);
250
      } else {
251
        return this.getBibliography(style);
252
      }
211 253
    }catch (e) {
254
      console.error(e);
255
      return "";
256
    }
257
  }
212 258

  
259
  /**
260
   * Supports formats bibtex, bibtxt, ris
261
   * @param format
262
   */
263
  getFormat(format:string) {
264
    return this.cite.format(format, {
265
      format: 'text'
266
    });
267
  }
268

  
269
  /**
270
   * Based on this and citeproc library https://citation.js.org/api/tutorial-plugins.html
271
   * if the template doesn;t exist add the CSL xml and the library will produce the citation
272
   * @param template
273
   */
274

  
275
  getBibliography(template:string) {
276
    if (!this.citeConfig.templates.get(template)) {
277
      this.citeConfig.templates.add(template, this.citation[template]);
213 278
    }
214
    
279
    return this.cite.format('bibliography', {
280
      format: 'text',
281
      template: template,
282
      lang: 'en-US'
283
    });
215 284
  }
216
  
217 285
}
modules/uoa-services-library/trunk/ng-openaire-library/src/app/landingPages/landing-utils/citeThis/citation.class.ts
1 1
export class Citation{
2 2
  public templates:string[]=["bibtex","chicago","ieee","science","apa","cell","harvard","mla","nature","acm","frontiers", "ama"];
3

  
3
  public fileFormats:string[]=["bibtex", "ris"];
4
  public fileSuffix:string[]=[".bib", ".ris"];
4 5
  //https://github.com/citation-style-language/styles
5
  bibtex:string =`<?xml version="1.0" encoding="utf-8"?> <style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only" default-locale="en-US"> <info> <title>BibTeX generic citation style</title> <id>http://www.zotero.org/styles/bibtex</id> <link href="http://www.zotero.org/styles/bibtex" rel="self"/> <link href="http://www.bibtex.org/" rel="documentation"/> <author> <name>Markus Schaffner</name> </author> <contributor> <name>Richard Karnesky</name> <email>karnesky+zotero@gmail.com</email> <uri>http://arc.nucapt.northwestern.edu/Richard_Karnesky</uri> </contributor> <category citation-format="author-date"/> <category field="generic-base"/> <updated>2012-09-14T21:22:32+00:00</updated> <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights> </info> <macro name="zotero2bibtexType"> <choose> <if type="bill book graphic legal_case legislation motion_picture report song" match="any"> <text value="book"/> </if> <else-if type="chapter paper-conference" match="any"> <text value="inbook"/> </else-if> <else-if type="article article-journal article-magazine article-newspaper" match="any"> <text value="article"/> </else-if> <else-if type="thesis" match="any"> <text value="phdthesis"/> </else-if> <else-if type="manuscript" match="any"> <text value="unpublished"/> </else-if> <else-if type="paper-conference" match="any"> <text value="inproceedings"/> </else-if> <else-if type="report" match="any"> <text value="techreport"/> </else-if> <else> <text value="misc"/> </else> </choose> </macro> <macro name="citeKey"> <group delimiter="_"> <text macro="author-short" text-case="lowercase"/> <text macro="issued-year"/> </group> </macro> <macro name="author-short"> <names variable="author"> <name form="short" delimiter="_" delimiter-precedes-last="always"/> <substitute> <names variable="editor"/> <names variable="translator"/> <choose> <if type="bill book graphic legal_case legislation motion_picture report song" match="any"> <text variable="title" form="short"/> </if> <else> <text variable="title" form="short"/> </else> </choose> </substitute> </names> </macro> <macro name="issued-year"> <date variable="issued"> <date-part name="year"/> </date> </macro> <macro name="issued-month"> <date variable="issued"> <date-part name="month" form="short" strip-periods="true"/> </date> </macro> <macro name="author"> <names variable="author"> <name sort-separator=", " delimiter=" and " delimiter-precedes-last="always" name-as-sort-order="all"/> <label form="long" text-case="capitalize-first"/> </names> </macro> <macro name="editor-translator"> <names variable="editor translator" delimiter=", "> <name sort-separator=", " delimiter=" and " delimiter-precedes-last="always" name-as-sort-order="all"/> <label form="long" text-case="capitalize-first"/> </names> </macro> <macro name="title"> <text variable="title"/> </macro> <macro name="number"> <text variable="issue"/> <text variable="number"/> </macro> <macro name="container-title"> <choose> <if type="chapter paper-conference" match="any"> <text variable="container-title" prefix=" booktitle={" suffix="}"/> </if> <else> <text variable="container-title" prefix=" journal={" suffix="}"/> </else> </choose> </macro> <macro name="publisher"> <choose> <if type="thesis"> <text variable="publisher" prefix=" school={" suffix="}"/> </if> <else-if type="report"> <text variable="publisher" prefix=" institution={" suffix="}"/> </else-if> <else> <text variable="publisher" prefix=" publisher={" suffix="}"/> </else> </choose> </macro> <macro name="pages"> <text variable="page"/> </macro> <macro name="edition"> <text variable="edition"/> </macro> <citation et-al-min="10" et-al-use-first="10" disambiguate-add-year-suffix="true" disambiguate-add-names="false" disambiguate-add-givenname="false" collapse="year"> <sort> <key macro="author"/> <key variable="issued"/> </sort> <layout delimiter="_"> <text macro="citeKey"/> </layout> </citation> <bibliography hanging-indent="false" et-al-min="10" et-al-use-first="10"> <sort> <key macro="author"/> <key variable="issued"/> </sort> <layout> <text macro="zotero2bibtexType" prefix=" @"/> <group prefix="{" suffix="}" delimiter=", "> <text macro="citeKey"/> <text variable="publisher-place" prefix=" place={" suffix="}"/> <!--Fix This--> <text variable="chapter-number" prefix=" chapter={" suffix="}"/> <!--Fix This--> <text macro="edition" prefix=" edition={" suffix="}"/> <!--Is this in CSL? <text variable="type" prefix=" type={" suffix="}"/>--> <text variable="collection-title" prefix=" series={" suffix="}"/> <text macro="title" prefix=" title={" suffix="}"/> <text variable="volume" prefix=" volume={" suffix="}"/> <!--Not in CSL<text variable="rights" prefix=" rights={" suffix="}"/>--> <text variable="ISBN" prefix=" ISBN={" suffix="}"/> <text variable="ISSN" prefix=" ISSN={" suffix="}"/> <!--Not in CSL <text variable="LCCN" prefix=" callNumber={" suffix="}"/>--> <text variable="archive_location" prefix=" archiveLocation={" suffix="}"/> <text variable="URL" prefix=" url={" suffix="}"/> <text variable="DOI" prefix=" DOI={" suffix="}"/> <text variable="abstract" prefix=" abstractNote={" suffix="}"/> <text variable="note" prefix=" note={" suffix="}"/> <text macro="number" prefix=" number={" suffix="}"/> <text macro="container-title"/> <text macro="publisher"/> <text macro="author" prefix=" author={" suffix="}"/> <text macro="editor-translator" prefix=" editor={" suffix="}"/> <text macro="issued-year" prefix=" year={" suffix="}"/> <text macro="issued-month" prefix=" month={" suffix="}"/> <text macro="pages" prefix=" pages={" suffix="}"/> <text variable="collection-title" prefix=" collection={" suffix="}"/> </group> </layout> </bibliography> </style> `;
6
  bibtex:string =`<?xml version="1.0" encoding="UTF-8"?><style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only" default-locale="en-US"><info><title>BibTeX generic citation style</title><id>http://www.zotero.org/styles/bibtex</id><link href="http://www.zotero.org/styles/bibtex" rel="self" /><link href="http://www.bibtex.org/" rel="documentation" /><author><name>Markus Schaffner</name></author><contributor><name>Richard Karnesky</name><email>karnesky+zotero@gmail.com</email><uri>http://arc.nucapt.northwestern.edu/Richard_Karnesky</uri></contributor><category citation-format="author-date" /><category field="generic-base" /><updated>2012-09-14T21:22:32+00:00</updated><rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights></info><macro name="zotero2bibtexType"><choose><if type="bill book graphic legal_case legislation motion_picture report song" match="any"><text value="book" /></if><else-if type="chapter" match="any"><text value="inbook" /></else-if><else-if type="article article-journal article-magazine article-newspaper" match="any"><text value="article" /></else-if><else-if type="thesis" match="any"><text value="phdthesis" /></else-if><else-if type="manuscript" match="any"><text value="unpublished" /></else-if><else-if type="paper-conference" match="any"><text value="inproceedings" /></else-if><else-if type="report" match="any"><text value="techreport" /></else-if><else><text value="misc" /></else></choose></macro><macro name="citeKey"><group delimiter="_"><text macro="author-short" text-case="lowercase" /><text macro="issued-year" /></group></macro><macro name="author-short"><names variable="author"><name form="short" delimiter="_" delimiter-precedes-last="always" /><substitute><names variable="editor" /><names variable="translator" /><choose><if type="bill book graphic legal_case legislation motion_picture report song" match="any"><text variable="title" form="short" /></if><else><text variable="title" form="short" /></else></choose></substitute></names></macro><macro name="issued-year"><date variable="issued"><date-part name="year" /></date></macro><macro name="issued-month"><date variable="issued"><date-part name="month" form="short" strip-periods="true" /></date></macro><macro name="author"><names variable="author"><name sort-separator=", " delimiter=" and " delimiter-precedes-last="always" name-as-sort-order="all" /></names></macro><macro name="editor-translator"><names variable="editor translator" delimiter=", "><name sort-separator=", " delimiter=" and " delimiter-precedes-last="always" name-as-sort-order="all" /></names></macro><macro name="title"><text variable="title" /></macro><macro name="number"><text variable="issue" /><text variable="number" /></macro><macro name="container-title"><choose><if type="chapter paper-conference" match="any"><text variable="container-title" prefix=" booktitle={" suffix="}" /></if><else><text variable="container-title" prefix=" journal={" suffix="}" /></else></choose></macro><macro name="publisher"><choose><if type="thesis"><text variable="publisher" prefix=" school={" suffix="}" /></if><else-if type="report"><text variable="publisher" prefix=" institution={" suffix="}" /></else-if><else><text variable="publisher" prefix=" publisher={" suffix="}" /></else></choose></macro><macro name="pages"><text variable="page" /></macro><macro name="edition"><text variable="edition" /></macro><citation et-al-min="11" et-al-use-first="10" disambiguate-add-year-suffix="true" disambiguate-add-names="false" disambiguate-add-givenname="false" collapse="year"><sort><key macro="author" /><key variable="issued" /></sort><layout delimiter="_"><text macro="citeKey" /></layout></citation><bibliography hanging-indent="false" et-al-min="11" et-al-use-first="10"><sort><key macro="author" /><key variable="issued" /></sort><layout><text macro="zotero2bibtexType" prefix=" @" /><group prefix="{" suffix=" }" delimiter=", "><text macro="citeKey" /><text variable="publisher-place" prefix=" place={" suffix="}" /><!--Fix This--><text variable="chapter-number" prefix=" chapter={" suffix="}" /><!--Fix This--><text macro="edition" prefix=" edition={" suffix="}" /><!--Is this in CSL? <text variable="type" prefix=" type={" suffix="}"/>--><text variable="collection-title" prefix=" series={" suffix="}" /><text macro="title" prefix=" title={" suffix="}" /><text variable="volume" prefix=" volume={" suffix="}" /><!--Not in CSL<text variable="rights" prefix=" rights={" suffix="}"/>--><text variable="ISBN" prefix=" ISBN={" suffix="}" /><text variable="ISSN" prefix=" ISSN={" suffix="}" /><!--Not in CSL <text variable="LCCN" prefix=" callNumber={" suffix="}"/>--><text variable="archive_location" prefix=" archiveLocation={" suffix="}" /><text variable="URL" prefix=" url={" suffix="}" /><text variable="DOI" prefix=" DOI={" suffix="}" /><text variable="abstract" prefix=" abstractNote={" suffix="}" /><text variable="note" prefix=" note={" suffix="}" /><text macro="number" prefix=" number={" suffix="}" /><text macro="container-title" /><text macro="publisher" /><text macro="author" prefix=" author={" suffix="}" /><text macro="editor-translator" prefix=" editor={" suffix="}" /><text macro="issued-year" prefix=" year={" suffix="}" /><text macro="issued-month" prefix=" month={" suffix="}" /><text macro="pages" prefix=" pages={" suffix="}" /><text variable="collection-title" prefix=" collection={" suffix="}" /></group></layout></bibliography></style>`;
6 7
  ieee:string =`<?xml version="1.0" encoding="utf-8"?> <style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only"> <info> <title>IEEE</title> <id>http://www.zotero.org/styles/ieee</id> <link href="http://www.zotero.org/styles/ieee" rel="self"/> <link href="http://www.ieee.org/documents/style_manual.pdf" rel="documentation"/> <link href="http://www.ieee.org/documents/auinfo07.pdf" rel="documentation"/> <author> <name>Michael Berkowitz</name> <email>mberkowi@gmu.edu</email> </author> <contributor> <name>Julian Onions</name> <email>julian.onions@gmail.com</email> </contributor> <contributor> <name>Rintze Zelle</name> <uri>http://twitter.com/rintzezelle</uri> </contributor> <contributor> <name>Stephen Frank</name> <uri>http://www.zotero.org/sfrank</uri> </contributor> <contributor> <name>Sebastian Karcher</name> </contributor> <category citation-format="numeric"/> <category field="engineering"/> <category field="generic-base"/> <updated>2016-10-06T15:32:30+00:00</updated> <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights> </info> <locale xml:lang="en"> <terms> <term name="chapter" form="short">ch.</term> <term name="presented at">presented at the</term> <term name="available at">available</term> </terms> </locale> <!-- Macros --> <macro name="edition"> <choose> <if type="bill book chapter graphic legal_case legislation motion_picture paper-conference report song" match="any"> <choose> <if is-numeric="edition"> <group delimiter=" "> <number variable="edition" form="ordinal"/> <text term="edition" form="short"/> </group> </if> <else> <text variable="edition" text-case="capitalize-first" suffix="."/> </else> </choose> </if> </choose> </macro> <macro name="issued"> <choose> <if type="article-journal report" match="any"> <date variable="issued"> <date-part name="month" form="short" suffix=" "/> <date-part name="year" form="long"/> </date> </if> <else-if type=" bill book chapter graphic legal_case legislation motion_picture paper-conference song thesis" match="any"> <date variable="issued"> <date-part name="year" form="long"/> </date> </else-if> <else> <date variable="issued"> <date-part name="day" form="numeric-leading-zeros" suffix="-"/> <date-part name="month" form="short" suffix="-" strip-periods="true"/> <date-part name="year" form="long"/> </date> </else> </choose> </macro> <macro name="author"> <names variable="author"> <name and="text" et-al-min="7" et-al-use-first="1" initialize-with=". "/> <label form="short" prefix=", " text-case="capitalize-first"/> <et-al font-style="italic"/> <substitute> <names variable="editor"/> <names variable="translator"/> </substitute> </names> </macro> <macro name="editor"> <names variable="editor"> <name initialize-with=". " delimiter=", " and="text"/> <label form="short" prefix=", " text-case="capitalize-first"/> </names> </macro> <macro name="locators"> <group delimiter=", "> <text macro="edition"/> <group delimiter=" "> <text term="volume" form="short"/> <number variable="volume" form="numeric"/> </group> <group delimiter=" "> <number variable="number-of-volumes" form="numeric"/> <text term="volume" form="short" plural="true"/> </group> <group delimiter=" "> <text term="issue" form="short"/> <number variable="issue" form="numeric"/> </group> </group> </macro> <macro name="title"> <choose> <if type="bill book graphic legal_case legislation motion_picture song" match="any"> <text variable="title" font-style="italic"/> </if> <else> <text variable="title" quotes="true"/> </else> </choose> </macro> <macro name="publisher"> <choose> <if type=" bill book chapter graphic legal_case legislation motion_picture paper-conference song" match="any"> <group delimiter=": "> <text variable="publisher-place"/> <text variable="publisher"/> </group> </if> <else> <group delimiter=", "> <text variable="publisher"/> <text variable="publisher-place"/> </group> </else> </choose> </macro> <macro name="event"> <choose> <if type="paper-conference speech" match="any"> <choose> <!-- Published Conference Paper --> <if variable="container-title"> <group delimiter=", "> <group delimiter=" "> <text term="in"/> <text variable="container-title" font-style="italic"/> </group> <text variable="event-place"/> </group> </if> <!-- Unpublished Conference Paper --> <else> <group delimiter=", "> <group delimiter=" "> <text term="presented at"/> <text variable="event"/> </group> <text variable="event-place"/> </group> </else> </choose> </if> </choose> </macro> <macro name="access"> <choose> <if type="webpage"> <choose> <if variable="URL"> <group delimiter=". "> <text term="online" prefix="[" suffix="]" text-case="capitalize-first"/> <group delimiter=": "> <text term="available at" text-case="capitalize-first"/> <text variable="URL"/> </group> <group prefix="[" suffix="]" delimiter=": "> <text term="accessed" text-case="capitalize-first"/> <date variable="accessed"> <date-part name="day" form="numeric-leading-zeros" suffix="-"/> <date-part name="month" form="short" suffix="-" strip-periods="true"/> <date-part name="year" form="long"/> </date> </group> </group> </if> </choose> </if> </choose> </macro> <macro name="page"> <group> <label variable="page" form="short" suffix=" "/> <text variable="page"/> </group> </macro> <macro name="citation-locator"> <group delimiter=" "> <choose> <if locator="page"> <label variable="locator" form="short"/> </if> <else> <label variable="locator" form="short" text-case="capitalize-first"/> </else> </choose> <text variable="locator"/> </group> </macro> <!-- Citation --> <citation collapse="citation-number"> <sort> <key variable="citation-number"/> </sort> <layout delimiter=", "> <group prefix="[" suffix="]" delimiter=", "> <text variable="citation-number"/> <text macro="citation-locator"/> </group> </layout> </citation> <!-- Bibliography --> <bibliography entry-spacing="0" second-field-align="flush"> <layout suffix="."> <!-- Citation Number --> <text variable="citation-number" prefix="[" suffix="]"/> <!-- Author(s) --> <text macro="author" suffix=", "/> <!-- Rest of Citation --> <choose> <!-- Specific Formats --> <if type="article-journal"> <group delimiter=", "> <text macro="title"/> <text variable="container-title" font-style="italic" form="short"/> <text macro="locators"/> <text macro="page"/> <text macro="issued"/> </group> </if> <else-if type="paper-conference speech" match="any"> <group delimiter=", "> <text macro="title"/> <text macro="event"/> <text macro="issued"/> <text macro="locators"/> <text macro="page"/> </group> </else-if> <else-if type="report"> <group delimiter=", "> <text macro="title"/> <text macro="publisher"/> <group delimiter=" "> <text variable="genre"/> <text variable="number"/> </group> <text macro="issued"/> </group> </else-if> <else-if type="thesis"> <group delimiter=", "> <text macro="title"/> <text variable="genre"/> <text macro="publisher"/> <text macro="issued"/> </group> </else-if> <else-if type="webpage post-weblog" match="any"> <group delimiter=", " suffix=". "> <text macro="title"/> <text variable="container-title" font-style="italic"/> <text macro="issued"/> </group> <text macro="access"/> </else-if> <else-if type="patent"> <group delimiter=", "> <text macro="title"/> <text variable="number"/> <text macro="issued"/> </group> </else-if> <!-- Generic/Fallback Formats --> <else-if type="bill book graphic legal_case legislation motion_picture report song" match="any"> <group delimiter=", " suffix=". "> <text macro="title"/> <text macro="locators"/> </group> <group delimiter=", "> <text macro="publisher"/> <text macro="issued"/> <text macro="page"/> </group> </else-if> <else-if type="article-magazine article-newspaper broadcast interview manuscript map patent personal_communication song speech thesis webpage" match="any"> <group delimiter=", "> <text macro="title"/> <text variable="container-title" font-style="italic"/> <text macro="locators"/> <text macro="publisher"/> <text macro="page"/> <text macro="issued"/> </group> </else-if> <else-if type="chapter paper-conference" match="any"> <group delimiter=", " suffix=", "> <text macro="title"/> <group delimiter=" "> <text term="in"/> <text variable="container-title" font-style="italic"/> </group> <text macro="locators"/> </group> <text macro="editor" suffix=" "/> <group delimiter=", "> <text macro="publisher"/> <text macro="issued"/> <text macro="page"/> </group> </else-if> <else> <group delimiter=", " suffix=". "> <text macro="title"/> <text variable="container-title" font-style="italic"/> <text macro="locators"/> </group> <group delimiter=", "> <text macro="publisher"/> <text macro="page"/> <text macro="issued"/> </group> </else> </choose> </layout> </bibliography> </style> `;
7 8
  chicago:string =`<?xml version="1.0" encoding="utf-8"?> <style xmlns="http://purl.org/net/xbiblio/csl" class="note" version="1.0" demote-non-dropping-particle="display-and-sort" page-range-format="chicago"> <info> <title>Chicago Manual of Style 16th edition (full note)</title> <id>http://www.zotero.org/styles/chicago-fullnote-bibliography</id> <link href="http://www.zotero.org/styles/chicago-fullnote-bibliography" rel="self"/> <link href="http://www.chicagomanualofstyle.org/tools_citationguide.html" rel="documentation"/> <author> <name>Julian Onions</name> <email>julian.onions@gmail.com</email> </author> <contributor> <name>Simon Kornblith</name> <email>simon@simonster.com</email> </contributor> <contributor> <name>Elena Razlogova</name> <email>elena.razlogova@gmail.com</email> </contributor> <contributor> <name>Frank Bennett</name> <email>biercenator@gmail.com</email> </contributor> <contributor> <name>Andrew Dunning</name> <email>andrew.dunning@utoronto.ca</email> </contributor> <category citation-format="note"/> <category field="generic-base"/> <summary>Chicago format with full notes and bibliography</summary> <updated>2016-11-03T13:30:08+00:00</updated> <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights> </info> <locale xml:lang="en"> <terms> <term name="editor" form="verb-short">ed.</term> <term name="translator" form="verb-short">trans.</term> <term name="translator" form="short">trans.</term> <term name="editortranslator" form="verb-short"> <single>ed. and trans.</single> <multiple>ed. and trans.</multiple> </term> <term name="editortranslator" form="verb"> <single>Edited and translated by</single> <multiple>Edited and translated by</multiple> </term> <term name="translator" form="short">trans.</term> </terms> </locale> <macro name="editor-translator"> <group delimiter=", "> <group delimiter=" "> <choose> <if variable="container-author reviewed-author" match="any"> <group> <names variable="container-author reviewed-author"> <label form="verb-short" text-case="lowercase" suffix=" "/> <name and="text" delimiter=", "/> </names> </group> </if> </choose> </group> <names variable="editor translator" delimiter=", "> <label form="verb-short" text-case="lowercase" suffix=" "/> <name and="text" delimiter=", "/> </names> </group> </macro> <macro name="secondary-contributors-note"> <choose> <if type="chapter paper-conference" match="none"> <text macro="editor-translator"/> </if> </choose> </macro> <macro name="container-contributors-note"> <choose> <if type="chapter paper-conference" match="any"> <text macro="editor-translator"/> </if> </choose> </macro> <macro name="secondary-contributors"> <choose> <if type="chapter paper-conference" match="none"> <names variable="editor translator" delimiter=". "> <label form="verb" text-case="capitalize-first" suffix=" "/> <name and="text" delimiter=", "/> </names> </if> </choose> </macro> <macro name="container-contributors"> <choose> <if type="chapter paper-conference" match="any"> <group delimiter=", "> <choose> <if variable="author"> <choose> <if variable="container-author" match="any"> <names variable="container-author"> <label form="verb-short" text-case="lowercase" suffix=" "/> <name and="text" delimiter=", "/> </names> </if> </choose> <!--This includes page numers after the container author, e.g. for Introductions --> <choose> <if variable="container-author author" match="all"> <group delimiter=". "> <text variable="page"/> <names variable="editor translator" delimiter=", "> <label form="verb" suffix=" "/> <name and="text" delimiter=", "/> </names> </group> </if> <else> <names variable="editor translator" delimiter=", "> <label form="verb" text-case="lowercase" suffix=" "/> <name and="text" delimiter=", "/> </names> </else> </choose> </if> </choose> </group> </if> </choose> </macro> <macro name="recipient-note"> <names variable="recipient" delimiter=", "> <label form="verb" text-case="lowercase" suffix=" "/> <name and="text" delimiter=", "/> </names> </macro> <macro name="contributors-note"> <group delimiter=" "> <names variable="author"> <name and="text" sort-separator=", " delimiter=", "/> <label form="short" prefix=", "/> <substitute> <names variable="editor"/> <names variable="translator"/> </substitute> </names> <text macro="recipient-note"/> </group> </macro> <macro name="editor"> <names variable="editor"> <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/> <label form="short" prefix=", "/> </names> </macro> <macro name="translator"> <names variable="translator"> <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/> <label form="verb-short" prefix=", "/> </names> </macro> <macro name="recipient"> <group delimiter=" "> <choose> <if type="personal_communication"> <choose> <if variable="genre"> <text variable="genre" text-case="capitalize-first"/> </if> <else> <text term="letter" text-case="capitalize-first"/> </else> </choose> </if> </choose> <text macro="recipient-note"/> </group> </macro> <macro name="contributors"> <group delimiter=". "> <names variable="author"> <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/> <substitute> <text macro="editor"/> <text macro="translator"/> </substitute> </names> <text macro="recipient"/> </group> </macro> <macro name="recipient-short"> <names variable="recipient"> <label form="verb" text-case="lowercase" suffix=" "/> <name form="short" and="text" delimiter=", "/> </names> </macro> <macro name="contributors-short"> <group delimiter=" "> <names variable="author"> <name form="short" and="text" delimiter=", "/> <substitute> <names variable="editor"/> <names variable="translator"/> </substitute> </names> <text macro="recipient-short"/> </group> </macro> <macro name="contributors-sort"> <names variable="author"> <name name-as-sort-order="all" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/> <substitute> <names variable="editor"/> <names variable="translator"/> <text macro="title"/> </substitute> </names> </macro> <macro name="interviewer-note"> <names variable="interviewer" delimiter=", "> <label form="verb" text-case="lowercase" suffix=" "/> <name and="text" delimiter=", "/> </names> </macro> <macro name="interviewer"> <names variable="interviewer" delimiter=", "> <label form="verb" text-case="capitalize-first" suffix=" "/> <name and="text" delimiter=", "/> </names> </macro> <macro name="title-note"> <choose> <if variable="title" match="none"> <text variable="genre"/> </if> <else-if type="book graphic motion_picture song" match="any"> <text variable="title" text-case="title" font-style="italic"/> <group delimiter=" " prefix=", "> <text term="version"/> <text variable="version"/> </group> </else-if> <else-if type="legal_case interview patent" match="any"> <text variable="title"/> </else-if> <else-if variable="reviewed-author"> <text variable="title" font-style="italic" prefix="review of "/> </else-if> <else> <text variable="title" text-case="title" quotes="true"/> </else> </choose> </macro> <macro name="title"> <choose> <if variable="title" match="none"> <choose> <if type="personal_communication" match="none"> <text variable="genre" text-case="capitalize-first"/> </if> </choose> </if> <else-if type="book graphic motion_picture song" match="any"> <text variable="title" text-case="title" font-style="italic"/> <group prefix=" (" suffix=")" delimiter=" "> <text term="version"/> <text variable="version"/> </group> </else-if> <else-if variable="reviewed-author"> <group delimiter=", "> <text variable="title" font-style="italic" prefix="Review of "/> <names variable="reviewed-author"> <label form="verb-short" text-case="lowercase" suffix=" "/> <name and="text" delimiter=", "/> </names> </group> </else-if> <else-if type="bill legislation legal_case interview patent" match="any"> <text variable="title"/> </else-if> <else> <text variable="title" text-case="title" quotes="true"/> </else> </choose> </macro> <macro name="title-short"> <choose> <if variable="title" match="none"> <choose> <if type="interview"> <text term="interview"/> </if> <else-if type="manuscript speech" match="any"> <text variable="genre" form="short"/> </else-if> <else-if type="personal_communication"> <text macro="issued"/> </else-if> </choose> </if> <else-if type="book graphic motion_picture song" match="any"> <text variable="title" text-case="title" form="short" font-style="italic"/> </else-if> <else-if type="legal_case" variable="title-short" match="all"> <text variable="title" font-style="italic" form="short"/> </else-if> <else-if type="patent interview" match="any"> <text variable="title" form="short"/> </else-if> <else-if type="legal_case bill legislation" match="any"> <text variable="title"/> </else-if> <else> <text variable="title" text-case="title" form="short" quotes="true"/> </else> </choose> </macro> <macro name="date-disambiguate"> <choose> <if disambiguate="true"> <text macro="issued"/> </if> </choose> </macro> <macro name="description-note"> <group delimiter=", "> <text macro="interviewer-note"/> <text variable="medium"/> <choose> <if variable="title" match="none"/> <else-if type="manuscript thesis speech" match="any"/> <else-if type="patent"> <group delimiter=" "> <text variable="authority"/> <text variable="number"/> </group> </else-if> <else> <text variable="genre"/> </else> </choose> </group> </macro> <macro name="description"> <group delimiter=", "> <group delimiter=". "> <text macro="interviewer"/> <text variable="medium" text-case="capitalize-first"/> </group> <choose> <if variable="title" match="none"/> <else-if type="thesis speech" match="any"/> <else-if type="patent"> <group delimiter=" "> <text variable="authority"/> <text variable="number"/> </group> </else-if> <else> <text variable="genre" text-case="capitalize-first"/> </else> </choose> </group> </macro> <macro name="container-title-note"> <group delimiter=" "> <choose> <if type="chapter paper-conference" match="any"> <text term="in"/> </if> </choose> <choose> <if type="bill legislation legal_case" match="none"> <text variable="container-title" text-case="title" font-style="italic"/> </if> </choose> </group> </macro> <macro name="container-title"> <group delimiter=" "> <choose> <if type="chapter paper-conference" match="any"> <text term="in" text-case="capitalize-first"/> </if> </choose> <choose> <if type="bill legislation legal_case" match="none"> <text variable="container-title" text-case="title" font-style="italic"/> </if> </choose> </group> </macro> <macro name="collection-title"> <choose> <if match="none" type="article-journal"> <choose> <if match="none" is-numeric="collection-number"> <group delimiter=", "> <text variable="collection-title" text-case="title"/> <text variable="collection-number"/> </group> </if> <else> <group delimiter=" "> <text variable="collection-title" text-case="title"/> <text variable="collection-number"/> </group> </else> </choose> </if> </choose> </macro> <macro name="collection-title-journal"> <choose> <if type="article-journal"> <group delimiter=" "> <text variable="collection-title"/> <text variable="collection-number"/> </group> </if> </choose> </macro> <macro name="edition-note"> <choose> <if type="book chapter graphic motion_picture paper-conference report song" match="any"> <choose> <if is-numeric="edition"> <group delimiter=" "> <number variable="edition" form="ordinal"/> <text term="edition" form="short"/> </group> </if> <else> <text variable="edition"/> </else> </choose> </if> </choose> </macro> <macro name="edition"> <choose> <if type="book chapter graphic motion_picture paper-conference report song" match="any"> <choose> <if is-numeric="edition"> <group delimiter=" "> <number variable="edition" form="ordinal"/> <text term="edition" form="short"/> </group> </if> <else> <text variable="edition" text-case="capitalize-first" suffix="."/> </else> </choose> </if> </choose> </macro> <macro name="locators-note-join-with-space"> <choose> <if type="article-journal" variable="volume" match="all"> <choose> <if match="none" variable="collection-title"> <text macro="locators-note"/> </if> </choose> </if> </choose> </macro> <macro name="locators-note-join-with-comma"> <choose> <if type="article-journal" match="none"> <text macro="locators-note"/> </if> <else-if type="article-journal"> <choose> <if variable="volume" match="none"> <text macro="locators-note"/> </if> <else-if match="any" variable="collection-title"> <text macro="locators-note"/> </else-if> </choose> </else-if> </choose> </macro> <macro name="locators-note"> <choose> <if type="article-journal"> <group delimiter=", "> <text macro="collection-title-journal"/> <number variable="volume"/> <group delimiter=" "> <text term="issue" form="short"/> <number variable="issue"/> </group> </group> </if> <else-if type="bill legislation legal_case" match="any"> <text macro="legal-cites"/> </else-if> <else-if type="book chapter graphic motion_picture paper-conference report song" match="any"> <group delimiter=", "> <text macro="edition-note"/> <group delimiter=" "> <text term="volume" form="short"/> <number variable="volume" form="numeric"/> </group> <choose> <if variable="locator" match="none"> <group delimiter=" "> <number variable="number-of-volumes" form="numeric"/> <text term="volume" form="short" plural="true"/> </group> </if> </choose> </group> </else-if> </choose> </macro> <macro name="legal-cites"> <choose> <if type="legal_case" match="any"> <group delimiter=" "> <choose> <if variable="container-title"> <text variable="volume"/> <text variable="container-title"/> <group delimiter=" "> <!--change to label variable="section" as that becomes available --> <text term="section" form="symbol"/> <text variable="section"/> </group> <text variable="page"/> </if> <else> <text variable="number" prefix="No. "/> </else> </choose> </group> </if> <else-if type="bill legislation" match="any"> <group delimiter=", "> <choose> <if variable="number"> <!--There's a public law number--> <text variable="number" prefix="Pub. L. No. "/> <group delimiter=" "> <!--change to label variable="section" as that becomes available --> <text term="section" form="symbol"/> <text variable="section"/> </group> <group delimiter=" "> <text variable="volume"/> <text variable="container-title"/> <text variable="page-first"/> </group> </if> <else> <group delimiter=" "> <text variable="volume"/> <text variable="container-title"/> <!--change to label variable="section" as that becomes available --> <text term="section" form="symbol"/> <text variable="section"/> </group> </else> </choose> </group> </else-if> </choose> </macro> <macro name="locators-join-with-space"> <choose> <if type="article-journal" variable="volume" match="all"> <choose> <if match="none" variable="collection-title"> <text macro="locators"/> </if> </choose> </if> </choose> </macro> <macro name="locators-join-with-comma"> <choose> <if type="bill chapter legislation legal_case paper-conference" match="any"> <text macro="locators"/> </if> <else-if type="article-journal"> <choose> <if variable="volume" match="none"> <text macro="locators"/> </if> <else-if match="any" variable="collection-title"> <text macro="locators"/> </else-if> </choose> </else-if> </choose> </macro> <macro name="locators-join-with-period"> <choose> <if type="bill legislation legal_case article-journal chapter paper-conference" match="none"> <text macro="locators"/> </if> </choose> </macro> <macro name="locators"> <choose> <if type="article-journal"> <group delimiter=", "> <text macro="collection-title-journal"/> <number variable="volume"/> <group delimiter=" "> <text term="issue" form="short"/> <number variable="issue"/> </group> </group> </if> <else-if type="bill legislation legal_case" match="any"> <text macro="legal-cites"/> </else-if> <else-if type="book graphic motion_picture report song" match="any"> <group delimiter=". "> <text macro="edition"/> <group delimiter=" "> <text term="volume" form="short" text-case="capitalize-first"/> <number variable="volume" form="numeric"/> </group> <group delimiter=" "> <number variable="number-of-volumes" form="numeric"/> <text term="volume" form="short" plural="true"/> </group> </group> </else-if> <else-if type="chapter paper-conference" match="any"> <group delimiter=". "> <text macro="edition"/> <choose> <if variable="page" match="none"> <group delimiter=" "> <text term="volume" form="short" text-case="capitalize-first"/> <number variable="volume" form="numeric"/> </group> </if> </choose> </group> </else-if> </choose> </macro> <macro name="locators-newspaper"> <choose> <if type="article-newspaper"> <group delimiter=", "> <group delimiter=" "> <number variable="edition"/> <text term="edition"/> </group> <group delimiter=" "> <text term="section" form="short"/> <text variable="section"/> </group> </group> </if> </choose> </macro> <macro name="event-note"> <text variable="event"/> </macro> <macro name="event"> <choose> <if variable="title"> <group delimiter=" "> <text term="presented at"/> <text variable="event"/> </group> </if> <else> <group delimiter=" "> <text term="presented at" text-case="capitalize-first"/> <text variable="event"/> </group> </else> </choose> </macro> <macro name="originally-published"> <group delimiter=", "> <group delimiter=": "> <text variable="original-publisher-place"/> <text variable="original-publisher"/> </group> <date variable="original-date" form="text" date-parts="year"/> </group> </macro> <macro name="reprint-note"> <!--needs localization--> <choose> <if variable="original-date issued" match="all"> <choose> <!--for whatever reason in notes, when we have both original and new publishers, reprint doesn't appear--> <if variable="original-publisher original-publisher-place" match="none"> <text value="repr."/> </if> </choose> </if> </choose> </macro> <macro name="reprint"> <!--needs localization--> <choose> <if variable="original-date issued" match="all"> <text value="reprint" text-case="capitalize-first"/> </if> </choose> </macro> <macro name="publisher"> <choose> <if type="thesis"> <text variable="publisher"/> </if> <else-if type="speech"> <text variable="event-place"/> </else-if> <else> <group delimiter=": "> <text variable="publisher-place"/> <text variable="publisher"/> </group> </else> </choose> </macro> <macro name="issued"> <choose> <if variable="issued"> <choose> <if type="graphic report" match="any"> <date variable="issued" form="text"/> </if> <else-if type="legal_case"> <group delimiter=" "> <text variable="authority"/> <choose> <if variable="container-title" match="any"> <!--Only print year for cases published in reporters--> <date variable="issued" form="numeric" date-parts="year"/> </if> <else> <date variable="issued" form="text"/> </else> </choose> </group> </else-if> <else-if type="book bill chapter graphic legislation motion_picture paper-conference report song thesis" match="any"> <date variable="issued"> <date-part name="year"/> </date> </else-if> <else-if type="patent"> <group delimiter=", "> <group delimiter=" "> <!--Needs Localization--> <text value="filed"/> <date variable="submitted" form="text"/> </group> <group delimiter=" "> <choose> <if variable="issued submitted" match="all"> <text term="and"/> </if> </choose> <!--Needs Localization--> <text value="issued"/> <date variable="issued" form="text"/> </group> </group> </else-if> <else> <date variable="issued" form="text"/> </else> </choose> </if> <else-if variable="status"> <text variable="status"/> </else-if> <else-if variable="accessed URL" match="all"/> <else> <text term="no date" form="short"/> </else> </choose> </macro> <macro name="point-locators-subsequent"> <choose> <if type="legal_case" variable="locator" match="all"> <choose> <if locator="page"> <group delimiter=":"> <number variable="volume"/> <text variable="locator"/> </group> </if> <else> <group delimiter=" "> <label variable="locator" form="short"/> <text variable="locator"/> </group> </else> </choose> </if> <else-if variable="locator"> <choose> <if locator="page" match="none"> <group delimiter=" "> <choose> <if type="book graphic motion_picture report song" match="any"> <choose> <if variable="volume"> <group delimiter=", "> <group delimiter=" "> <text term="volume" form="short"/> <number variable="volume" form="numeric"/> </group> <label variable="locator" form="short"/> </group> </if> <else> <label variable="locator" form="short"/> </else> </choose> </if> <else> <label variable="locator" form="short"/> </else> </choose> <text variable="locator"/> </group> </if> <else-if type="book graphic motion_picture report song" match="any"> <group delimiter=":"> <number variable="volume" form="numeric"/> <text variable="locator"/> </group> </else-if> <else> <text variable="locator"/> </else> </choose> </else-if> </choose> </macro> <macro name="point-locators-join-with-colon"> <choose> <if type="article-journal"> <choose> <if variable="locator page" match="any"> <choose> <if variable="volume issue" match="any"> <text macro="point-locators"/> </if> </choose> </if> </choose> </if> </choose> </macro> <macro name="point-locators-join-with-comma"> <choose> <if type="article-journal" match="none"> <text macro="point-locators"/> </if> <else-if variable="volume issue" match="none"> <text macro="point-locators"/> </else-if> </choose> </macro> <macro name="point-locators"> <choose> <if variable="locator" match="none"> <choose> <if type="article-journal chapter paper-conference" match="any"> <text variable="page"/> </if> </choose> </if> <else-if type="article-journal"> <group delimiter=" "> <choose> <if locator="page" match="none"> <label variable="locator" form="short" suffix=" "/> </if> </choose> <text variable="locator"/> </group> </else-if> <else-if type="legal_case"/> <else> <group delimiter=" "> <choose> <if locator="page" match="none"> <label variable="locator" form="short"/> </if> </choose> <text variable="locator"/> </group> </else> </choose> </macro> <macro name="locators-chapter"> <choose> <if type="chapter paper-conference" match="any"> <choose> <if variable="author container-author" match="all"/> <else> <choose> <if variable="page"> <number variable="volume" suffix=":"/> <text variable="page"/> </if> </choose> </else> </choose> </if> </choose> </macro> <macro name="locators-journal-join-with-colon"> <choose> <if type="article-journal"> <choose> <if variable="volume issue" match="any"> <text variable="page"/> </if> </choose> </if> </choose> </macro> <macro name="locators-journal-join-with-comma"> <choose> <if type="article-journal"> <choose> <if variable="volume issue" match="none"> <text variable="page"/> </if> </choose> </if> </choose> </macro> <macro name="archive-note"> <choose> <if type="thesis"> <group delimiter=" "> <text variable="archive"/> <text variable="archive_location" prefix="(" suffix=")"/> </group> </if> <else> <group delimiter=", "> <text variable="archive_location"/> <text variable="archive"/> <text variable="archive-place"/> </group> </else> </choose> </macro> <macro name="archive"> <choose> <if type="thesis"> <group delimiter=" "> <text variable="archive"/> <text variable="archive_location" prefix="(" suffix=")"/> </group> </if> <else> <group delimiter=". "> <text variable="archive_location" text-case="capitalize-first"/> <text variable="archive"/> <text variable="archive-place"/> </group> </else> </choose> </macro> <macro name="issue-note-join-with-space"> <choose> <if type="article-journal bill legislation legal_case manuscript thesis" variable="publisher-place publisher" match="any"> <!--Chicago doesn't use publisher/place for Newspapers and we want the date delimited by a comma--> <choose> <if type="article-newspaper" match="none"> <choose> <if type="article-journal" match="none"> <text macro="issue-note"/> </if> <else-if variable="issue volume" match="any"> <text macro="issue-note"/> </else-if> </choose> </if> </choose> </if> </choose> </macro> <macro name="issue-note-join-with-comma"> <choose> <if type="article-journal bill legislation legal_case manuscript thesis" variable="publisher-place publisher" match="none"> <text macro="issue-note"/> </if> <else-if type="article-newspaper"> <text macro="issue-note"/> </else-if> <else-if type="article-journal"> <choose> <if variable="volume issue" match="none"> <text macro="issue-note"/> </if> </choose> </else-if> </choose> </macro> <macro name="issue-note"> <choose> <if type="bill legislation legal_case" match="any"> <text macro="issued" prefix="(" suffix=")"/> </if> <else-if type="article-journal"> <choose> <if variable="volume issue" match="any"> <text macro="issued" prefix="(" suffix=")"/> </if> <else> <text macro="issued"/> </else> </choose> </else-if> <else-if type="article-newspaper"> <text macro="issued"/> </else-if> <else-if variable="publisher-place event-place publisher genre" match="any"> <group prefix="(" suffix=")" delimiter=", "> <choose> <if variable="title" match="none"/> <else-if type="manuscript thesis speech" match="any"> <text variable="genre"/> </else-if> </choose> <text macro="event-note"/> <group delimiter="; "> <text macro="originally-published"/> <group delimiter=", "> <text macro="reprint-note"/> <text macro="publisher"/> </group> </group> <text macro="issued"/> </group> </else-if> <else> <text macro="issued"/> </else> </choose> </macro> <macro name="issue-join-with-space"> <choose> <if type="article-journal" match="any"> <choose> <if variable="issue volume" match="any"> <text macro="issue"/> </if> </choose> </if> <else-if type="bill legislation legal_case" match="any"> <text macro="issue"/> </else-if> </choose> </macro> <macro name="issue-join-with-period"> <choose> <if type="article-journal bill legislation legal_case" match="none"> <choose> <if type="speech" variable="publisher publisher-place" match="any"> <text macro="issue"/> </if> </choose> </if> </choose> </macro> <macro name="issue-join-with-comma"> <choose> <if type="bill legislation legal_case" match="none"> <choose> <if type="article-journal" match="none"> <choose> <if type="speech" variable="publisher publisher-place" match="none"> <text macro="issue"/> </if> </choose> </if> <else-if variable="volume issue" match="none"> <text macro="issue"/> </else-if> </choose> </if> </choose> </macro> <macro name="issue"> <choose> <if type="bill legislation legal_case" match="any"> <text macro="issued" prefix="(" suffix=")"/> </if> <else-if type="article-journal"> <choose> <if variable="issue volume" match="any"> <text macro="issued" prefix="(" suffix=")"/> </if> <else> <text macro="issued"/> </else> </choose> </else-if> <else-if type="speech"> <group delimiter=", "> <group delimiter=" "> <choose> <if variable="title" match="none"/> <else> <text variable="genre" text-case="capitalize-first"/> </else> </choose> <text macro="event"/> </group> <text variable="event-place"/> <text macro="issued"/> </group> </else-if> <!--Chicago doesn't use publisher/place for Newspapers --> <else-if type="article-newspaper"> <text macro="issued"/> </else-if> <else-if variable="publisher-place publisher" match="any"> <group delimiter=", "> <choose> <if type="thesis"> <text variable="genre" text-case="capitalize-first"/> </if> </choose> <group delimiter=". "> <text macro="originally-published"/> <group delimiter=", "> <text macro="reprint"/> <text macro="publisher"/> </group> </group> <text macro="issued"/> </group> </else-if> <else> <text macro="issued"/> </else> </choose> </macro> <macro name="access-note"> <group delimiter=", "> <choose> <if type="graphic report" match="any"> <text macro="archive-note"/> </if> <else-if type="article-journal bill book chapter legal_case legislation motion_picture paper-conference" match="none"> <text macro="archive-note"/> </else-if> </choose> <choose> <if variable="issued" match="none"> <group delimiter=" "> <text term="accessed"/> <date variable="accessed" form="text"/> </group> </if> </choose> <choose> <if type="legal_case" match="none"> <choose> <if variable="DOI"> <text variable="DOI" prefix="doi:"/> </if> <else> <text variable="URL"/> </else> </choose> </if> </choose> </group> </macro> <macro name="access"> <group delimiter=". "> <choose> <if type="graphic report" match="any"> <text macro="archive"/> </if> <else-if type="article-journal bill book chapter legal_case legislation motion_picture paper-conference" match="none"> <text macro="archive"/> </else-if> </choose> <choose> <if variable="issued" match="none"> <group delimiter=" "> <text term="accessed" text-case="capitalize-first"/> <date variable="accessed" form="text"/> </group> </if> </choose> <choose> <if type="legal_case" match="none"> <choose> <if variable="DOI"> <text variable="DOI" prefix="doi:"/> </if> <else> <text variable="URL"/> </else> </choose> </if> </choose> </group> </macro> <macro name="case-locator-subsequent"> <choose> <if type="legal_case"> <group delimiter=" "> <text variable="volume"/> <text variable="container-title"/> </group> </if> </choose> </macro> <macro name="case-pinpoint-subsequent"> <choose> <if type="legal_case"> <group delimiter=" "> <choose> <if locator="page"> <text term="at"/> <text variable="locator"/> </if> <else> <label variable="locator"/> <text variable="locator"/> </else> </choose> </group> </if> </choose> </macro> <citation et-al-min="4" et-al-use-first="1" disambiguate-add-names="true"> <layout suffix="." delimiter="; "> <choose> <if position="ibid-with-locator"> <group delimiter=", "> <text term="ibid"/> <text macro="point-locators-subsequent"/> </group> </if> <else-if position="ibid"> <text term="ibid"/> </else-if> <else-if position="subsequent"> <group delimiter=", "> <text macro="contributors-short"/> <group delimiter=" "> <group delimiter=", "> <text macro="title-short"/> <!--if title & author are the same: --> <text macro="date-disambiguate"/> <text macro="case-locator-subsequent"/> </group> <text macro="case-pinpoint-subsequent"/> </group> <choose> <if match="none" type="legal_case"> <text macro="point-locators-subsequent"/> </if> </choose> </group> </else-if> <else> <group delimiter=", "> <group delimiter=": "> <group delimiter=", "> <group delimiter=" "> <group delimiter=", "> <group delimiter=" "> <group delimiter=", "> <group delimiter=", "> <text macro="contributors-note"/> <text macro="title-note"/> </group> <text macro="description-note"/> <text macro="secondary-contributors-note"/> <text macro="container-title-note"/> <text macro="container-contributors-note"/> </group> <text macro="locators-note-join-with-space"/> </group> <text macro="locators-note-join-with-comma"/> <text macro="collection-title"/> <text macro="issue-note-join-with-comma"/> </group> <text macro="issue-note-join-with-space"/> </group> <text macro="locators-newspaper"/> <text macro="point-locators-join-with-comma"/> </group> <text macro="point-locators-join-with-colon"/> </group> <text macro="access-note"/> </group> </else> </choose> </layout> </citation> <bibliography hanging-indent="true" et-al-min="11" et-al-use-first="7" subsequent-author-substitute="&#8212;&#8212;&#8212;" entry-spacing="0"> <sort> <key macro="contributors-sort"/> <key variable="title"/> <key variable="genre"/> <key variable="issued"/> </sort> <layout suffix="."> <group delimiter=". "> <group delimiter=": "> <group delimiter=", "> <group delimiter=" "> <group delimiter=". "> <group delimiter=" "> <group delimiter=", "> <group delimiter=". "> <group delimiter=". "> <text macro="contributors"/> <text macro="title"/> </group> <text macro="description"/> <text macro="secondary-contributors"/> <group delimiter=", "> <text macro="container-title"/> <text macro="container-contributors"/> </group> <text macro="locators-join-with-period"/> </group> <text macro="locators-join-with-comma"/> <text macro="locators-chapter"/> </group> <text macro="locators-join-with-space"/> </group> <text macro="collection-title"/> <text macro="issue-join-with-period"/> </group> <text macro="issue-join-with-space"/> </group> <text macro="issue-join-with-comma"/> <text macro="locators-journal-join-with-comma"/> <text macro="locators-newspaper"/> </group> <text macro="locators-journal-join-with-colon"/> </group> <text macro="access"/> </group> </layout> </bibliography> </style> `;
8 9
  science:string ='<?xml version="1.0" encoding="utf-8"?> <style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only" default-locale="en-US"> <info> <title>Science</title> <id>http://www.zotero.org/styles/science</id> <link href="http://www.zotero.org/styles/science" rel="self"/> <link href="http://www.sciencemag.org/about/authors/prep/res/refs.dtl" rel="documentation"/> <author> <name>Julian Onions</name> <email>julian.onions@gmail.com</email> </author> <contributor> <name>Sebastian Karcher</name> </contributor> <contributor> <name>Greg Barendt</name> </contributor> <category citation-format="numeric"/> <category field="science"/> <issn>0036-8075</issn> <eissn>1095-9203</eissn> <summary>The Science journal style.</summary> <updated>2014-08-28T01:36:46+00:00</updated> <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights> </info> <macro name="editor"> <names variable="editor" delimiter=", "> <name initialize-with=". " delimiter=", " delimiter-precedes-last="always"/> <label form="short" prefix=", " text-case="capitalize-first"/> </names> </macro> <macro name="author"> <names variable="author"> <name sort-separator=", " initialize-with=". " delimiter=", " delimiter-precedes-last="always"/> <label form="short" prefix=", " text-case="capitalize-first"/> <et-al font-style="italic"/> <substitute> <names variable="editor"/> </substitute> </names> </macro> <macro name="access"> <choose> <if variable="page" match="none"> <text macro="access-value"/> </if> <else-if is-numeric="page" match="none"> <text macro="access-value"/> </else-if> </choose> </macro> <macro name="access-value"> <choose> <if variable="DOI"> <text variable="DOI" prefix=", doi:"/> </if> <else> <group prefix=" (" suffix=")"> <text value="available at "/> <text variable="URL"/> </group> </else> </choose> </macro> <macro name="title"> <choose> <if type="bill book graphic legal_case legislation motion_picture report song" match="any"> <text variable="title" font-style="italic"/> </if> <else> <text variable="title"/> </else> </choose> </macro> <macro name="article-details"> <group delimiter=", "> <group delimiter=". "> <text macro="title"/> <text form="short" variable="container-title" font-style="italic"/> <text variable="volume" font-weight="bold"/> </group> <text variable="page"/> </group> <text macro="issued" prefix=" (" suffix=")"/> <text macro="access"/> </macro> <macro name="publisher"> <group delimiter=", "> <text variable="publisher"/> <text variable="publisher-place"/> </group> </macro> <macro name="pages"> <label variable="page" form="short" suffix=" "/> <text variable="page" form="short"/> </macro> <macro name="issued"> <date variable="issued" delimiter=" "> <date-part name="year"/> </date> </macro> <macro name="edition"> <choose> <if is-numeric="edition"> <group delimiter=" "> <text term="edition" form="short"/> <number variable="edition" form="numeric"/> </group> </if> <else> <text variable="edition" suffix="."/> </else> </choose> </macro> <citation collapse="citation-number"> <sort> <key variable="citation-number"/> </sort> <layout prefix="(" suffix=")" delimiter=", "> <text variable="citation-number" font-style="italic"/> </layout> </citation> <bibliography et-al-min="6" et-al-use-first="1" second-field-align="flush"> <layout suffix="."> <text variable="citation-number" suffix=". "/> <group delimiter=", "> <text macro="author"/> <choose> <if type="thesis"> <group delimiter=" "> <group delimiter=", "> <group> <!-- Always print, even if no university given --> <text value="thesis"/> </group> <text macro="publisher"/> </group> <text macro="issued" prefix="(" suffix=")"/> </group> </if> <else-if type="bill book graphic legal_case legislation motion_picture song chapter paper-conference" match="any"> <group delimiter=" "> <choose> <if type="chapter paper-conference" match="any"> <group delimiter=", "> <group delimiter=" "> <text term="in"/> <text variable="container-title" font-style="italic"/> </group> <text macro="editor"/> </group> </if> <else> <text macro="title"/> </else> </choose> <group prefix="(" suffix=")" delimiter="; "> <group delimiter=", "> <text macro="publisher"/> <text macro="edition"/> <text macro="issued"/> </group> <text variable="URL"/> </group> </group> <group delimiter=" of "> <group> <label variable="volume" form="short" suffix=" "/> <number variable="volume"/> </group> <text variable="collection-title" font-style="italic"/> </group> <choose> <if type="chapter paper-conference" match="any"> <text macro="pages"/> </if> </choose> </else-if> <else-if type="article-journal"> <choose> <if variable="page"> <choose> <if is-numeric="page" match="none"> <group> <group delimiter=", "> <text variable="container-title" form="short" font-style="italic"/> <group> <text term="in press"/> </group> </group> <text macro="access"/> </group> </if> <else> <text macro="article-details"/> </else> </choose> </if> <else> <text macro="article-details"/> </else> </choose> </else-if> <else-if type="report"> <group> <group delimiter=", "> <text variable="title" quotes="true"/> <text variable="collection-title" font-style="italic"/> </group> <group prefix=" (" suffix=")" delimiter=", "> <group delimiter=" "> <text variable="genre" form="short"/> <number variable="number"/> </group> <text variable="publisher"/> <text variable="publisher-place"/> <text macro="issued"/> </group> </group> <text macro="pages"/> <text macro="access"/> </else-if> <else> <group> <group delimiter=", "> <text macro="editor"/> <group delimiter=". "> <text macro="title"/> <text form="short" variable="container-title" font-style="italic"/> <text variable="volume" font-weight="bold"/> </group> </group> <text macro="issued" prefix=" (" suffix=")"/> </group> <text macro="pages"/> <text macro="access"/> </else> </choose> </group> </layout> </bibliography> </style>';
modules/uoa-services-library/trunk/ng-openaire-library/src/app/landingPages/result/resultLanding.component.ts
567 567
    this.citeThisClicked = true;
568 568
    this.citeModal.cancelButton = false;
569 569
    this.citeModal.okButton = false;
570
    this.citeModal.alertTitle = "Cite this " + this.getTypeName() + " to";
570
    this.citeModal.alertTitle = "Cite this " + this.getTypeName();
571 571
    this.citeModal.open();
572 572
  }
573 573
  addNoIndexFilter() {
574 574
    try {
575
      if(this.properties.environment != "production") {
575
      if(!(this.properties.environment == "production" || this.properties.environment == "development") ) {
576 576
        return ;
577 577
      }else {
578
       let addFilter =  !(!this.resultLandingInfo.underCurationMessage &&
578
       let allow =  !!(!this.resultLandingInfo.underCurationMessage &&
579 579
          ((this.resultLandingInfo.fundedByProjects && this.resultLandingInfo.fundedByProjects.length > 0)
580 580
            || this.resultLandingInfo.journal
581
            || (this.resultLandingInfo.otherSubjects && this.resultLandingInfo.otherSubjects.size > 0)
582 581
            || (this.resultLandingInfo.classifiedSubjects && this.resultLandingInfo.classifiedSubjects.size > 0)
583 582
            || (this.resultLandingInfo.organizations && this.resultLandingInfo.organizations.length > 0)
584 583
            || this.resultLandingInfo.bioentities || (this.resultLandingInfo.references && this.resultLandingInfo.references.length > 0)
......
587 586
            || (this.resultLandingInfo.supplementaryResearchResults && this.resultLandingInfo.supplementaryResearchResults.length > 0)
588 587
            || (this.resultLandingInfo.supplementedByResearchResults && this.resultLandingInfo.supplementedByResearchResults.length > 0)
589 588
          ));
590
        if(addFilter) {
589
        if(!allow) {
591 590
          this._meta.updateTag({content: 'noindex'}, "name='robots'");
592 591
        }
593 592
      }
modules/uoa-services-library/trunk/ng-openaire-library/src/assets/citeproc.js
1
/*
2
 * Copyright (c) 2009-2016 Frank Bennett
3
 *
4
 * 	This program is free software: you can redistribute it and/or
5
 * 	modify it under EITHER
6
 *
7
 *       * the terms of the Common Public Attribution License (CPAL) as
8
 * 	    published by the Open Source Initiative, either version 1 of
9
 * 	    the CPAL, or (at your option) any later version; OR
10
 *
11
 *       * the terms of the GNU Affero General Public License (AGPL)
12
 *         as published by the Free Software Foundation, either version
13
 *         3 of the AGPL, or (at your option) any later version.
14
 *
15
 * 	This program is distributed in the hope that it will be useful,
16
 * 	but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
 * 	Affero General Public License for more details.
19
 *
20
 * 	You should have received copies of the Common Public Attribution
21
 *     License and of the GNU Affero General Public License along with
22
 *     this program.  If not, see <https://opensource.org/licenses/> or
23
 *     <http://www.gnu.org/licenses/> respectively.
24
 */
25

  
26
var CSL = {
27
    PROCESSOR_VERSION: "1.1.178",
28
    CONDITION_LEVEL_TOP: 1,
29
    CONDITION_LEVEL_BOTTOM: 2,
30
    PLAIN_HYPHEN_REGEX: /(?:[^\\]-|\u2013)/,
31
    LOCATOR_LABELS_REGEXP: new RegExp("^((art|ch|subch|col|fig|l|n|no|op|p|pp|para|subpara|pt|r|sec|subsec|sv|sch|tit|vrs|vol)\\.)\\s+(.*)"),
32
    STATUTE_SUBDIV_GROUPED_REGEX: /((?:^| )(?:art|bk|ch|subch|col|fig|fol|l|n|no|op|p|pp|para|subpara|pt|r|sec|subsec|sv|sch|tit|vrs|vol)\. *)/g,
33
    STATUTE_SUBDIV_PLAIN_REGEX: /(?:(?:^| )(?:art|bk|ch|subch|col|fig|fol|l|n|no|op|p|pp|para|subpara|pt|r|sec|subsec|sv|sch|tit|vrs|vol)\. *)/,
34
    STATUTE_SUBDIV_STRINGS: {
35
        "art.": "article",
36
        "bk.": "book",
37
        "ch.": "chapter",
38
        "subch.": "subchapter",
39
        "p.": "page",
40
        "pp.": "page",
41
        "para.": "paragraph",
42
        "subpara.": "subparagraph",
43
        "pt.": "part",
44
        "r.": "rule",
45
        "sec.": "section",
46
        "subsec.": "subsection",
47
        "sch.": "schedule",
48
        "tit.": "title",
49
        "col.": "column",
50
        "fig.": "figure",
51
        "fol.": "folio",
52
        "l.": "line",
53
        "n.": "note",
54
        "no.": "issue",
55
        "op.": "opus",
56
        "sv.": "sub-verbo",
57
        "vrs.": "verse",
58
        "vol.": "volume"
59
    },
60
    STATUTE_SUBDIV_STRINGS_REVERSE: {
61
        "article": "art.",
62
        "book": "bk.",
63
        "chapter": "ch.",
64
        "subchapter": "subch.",
65
        "page": "p.",
66
        "paragraph": "para.",
67
        "subparagraph": "subpara.",
68
        "part": "pt.",
69
        "rule": "r.",
70
        "section": "sec.",
71
        "subsection": "subsec.",
72
        "schedule": "sch.",
73
        "title": "tit.",
74
        "column": "col.",
75
        "figure": "fig.",
76
        "folio": "fol.",
77
        "line": "l.",
78
        "note": "n.",
79
        "issue": "no.",
80
        "opus": "op.",
81
        "sub-verbo": "sv.",
82
        "sub verbo": "sv.",
83
        "verse": "vrs.",
84
        "volume": "vol."
85
    },
86
    LOCATOR_LABELS_MAP: {
87
        "art": "article",
88
        "bk": "book",
89
        "ch": "chapter",
90
        "subch": "subchapter",
91
        "col": "column",
92
        "fig": "figure",
93
        "fol": "folio",
94
        "l": "line",
95
        "n": "note",
96
        "no": "issue",
97
        "op": "opus",
98
        "p": "page",
99
        "pp": "page",
100
        "para": "paragraph",
101
        "subpara": "subparagraph",
102
        "pt": "part",
103
        "r": "rule",
104
		"sec": "section",
105
		"subsec": "subsection",
106
		"sv": "sub-verbo",
107
        "sch": "schedule",
108
        "tit": "title",
109
        "vrs": "verse",
110
        "vol": "volume"
111
    },
112
    MODULE_MACROS: {
113
        "juris-pretitle": true,
114
        "juris-title": true,
115
        "juris-pretitle-short": true,
116
        "juris-title-short": true,
117
        "juris-main": true,
118
        "juris-main-short": true,
119
        "juris-tail": true,
120
        "juris-tail-short": true,
121
        "juris-locator": true
122
    },
123
    MODULE_TYPES: {
124
        "legal_case": true,
125
        "legislation": true,
126
        "bill": true,
127
        "hearing": true,
128
        "gazette": true,
129
        "report": true,
130
        "regulation": true,
131
        "standard": true
132
    },
133
    NestedBraces: [
134
        ["(", "["],
135
        [")", "]"]
136
    ],
137
    checkNestedBrace: function(state) {
138
        if (state.opt.xclass === "note") {
139
            this.depth = 0;
140
            this.update = function(str) {
141
                var str = str ? str : '';
142
                var lst = str.split(/([\(\)])/);
143
                for (var i=1,ilen=lst.length;i<ilen;i += 2) {
144
                    if (lst[i] === '(') {
145
                        if (1 === (this.depth % 2)) {
146
                            lst[i] = '['
147
                        }
148
                        this.depth += 1;
149
                    } else if (lst[i] === ')') {
150
                        if (0 === (this.depth % 2)) {
151
                            lst[i] = ']'
152
                        }
153
                        this.depth -= 1;
154
                    }
155
                }
156
                var ret = lst.join("");
157
                return ret;
158
            }
159
        } else {
160
            this.update = function(str) {
161
                return str;
162
            }
163
        };
164
    },
165
    MULTI_FIELDS: ["event", "publisher", "publisher-place", "event-place", "title", "container-title", "collection-title", "authority","genre","title-short","medium","jurisdiction","archive","archive-place"],
166
    LangPrefsMap: {
167
        "title":"titles",
168
        "title-short":"titles",
169
        "event":"titles",
170
        "genre":"titles",
171
        "medium":"titles",
172
        "container-title":"journals",
173
        "collection-title":"journals",
174
        "archive":"journals",
175
        "publisher":"publishers",
176
        "authority":"publishers",
177
        "publisher-place": "places",
178
        "event-place": "places",
179
        "archive-place": "places",
180
        "jurisdiction": "places",
181
        "number": "number",
182
        "edition":"number",
183
        "issue":"number",
184
        "volume":"number"
185
    },
186
    AbbreviationSegments: function () {
187
        this["container-title"] = {};
188
        this["collection-title"] = {};
189
        this["institution-entire"] = {};
190
        this["institution-part"] = {};
191
        this.nickname = {};
192
        this.number = {};
193
        this.title = {};
194
        this.place = {};
195
        this.hereinafter = {};
196
        this.classic = {};
197
        this["container-phrase"] = {};
198
        this["title-phrase"] = {};
199
    },
200
    FIELD_CATEGORY_REMAP: {
201
        "title": "title",
202
        "container-title": "container-title",
203
        "collection-title": "collection-title",
204
        "number": "number",
205
        "place": "place",
206
        "archive": "collection-title",
207
        "title-short": "title",
208
        "genre": "title",
209
        "event": "title",
210
        "medium": "title",
211
		"archive-place": "place",
212
		"publisher-place": "place",
213
		"event-place": "place",
214
		"jurisdiction": "place",
215
		"language-name": "place",
216
		"language-name-original": "place",
217
        "call-number": "number",
218
        "chapter-number": "number",
219
        "collection-number": "number",
220
        "edition": "number",
221
        "page": "number",
222
        "issue": "number",
223
        "locator": "number",
224
        "number-of-pages": "number",
225
        "number-of-volumes": "number",
226
        "volume": "number",
227
        "citation-number": "number",
228
        "publisher": "institution-part"
229
    },
230
    parseLocator: function(item) {
231
        if (this.opt.development_extensions.locator_date_and_revision) {
232
            if (item.locator) {
233
                item.locator = "" + item.locator;
234
                var idx = item.locator.indexOf("|");
235
                if (idx > -1) {
236
                    var raw_locator = item.locator;
237
                    item.locator = raw_locator.slice(0, idx);
238
                    raw_locator = raw_locator.slice(idx + 1);
239
                    var m = raw_locator.match(/^([0-9]{4}-[0-9]{2}-[0-9]{2}).*/);
240
                    if (m) {
241
                        item["locator-date"] = this.fun.dateparser.parseDateToObject(m[1]);
242
                        raw_locator = raw_locator.slice(m[1].length);
243
                    }
244
                    item["locator-extra"] = raw_locator.replace(/^\s+/, "").replace(/\s+$/, "");
245
                }
246
            }
247
        }
248
        if (item.locator) {
249
            item.locator = ("" + item.locator).replace(/\s+$/, '');
250
        }
251
        return item;
252
    },
253
    normalizeLocaleStr: function(str) {
254
        if (!str) return;
255
        var lst = str.split('-');
256
        lst[0] = lst[0].toLowerCase();
257
        if (lst[1]) {
258
            lst[1] = lst[1].toUpperCase();
259
        }
260
        return lst.join("-");
261
    },
262
    parseNoteFieldHacks: function(Item, validFieldsForType, allowDateOverride) {
263
        if ("string" !== typeof Item.note) return;
264
        var elems = [];
265
        var lines = Item.note.split('\n');
266
        var lastline = "";
267
        for (var i=0, ilen=lines.length; i<ilen; i++) {
268
            var line = lines[i];
269
            var elems = [];
270
            var m = line.match(CSL.NOTE_FIELDS_REGEXP);
271
            if (m) {
272
                var splt = line.split(CSL.NOTE_FIELDS_REGEXP);
273
                for (var j=0,jlen=(splt.length-1);j<jlen;j++) {
274
                    elems.push(splt[j]);
275
                    elems.push(m[j]);
276
                }
277
                elems.push(splt[splt.length-1])
278
                for (var j=1,jlen=elems.length;j<jlen;j += 2) {
279
                    if (elems[j-1].trim() && (i>0 || j>1) && !elems[j-1].match(CSL.NOTE_FIELD_REGEXP)) {
280
                        break
281
                    } else {
282
                        elems[j] = '\n' + elems[j].slice(2,-1).trim() + '\n';
283
                    }
284
                }
285
                lines[i] = elems.join('');
286
            }
287
        }
288
        lines = lines.join('\n').split('\n');
289
        var offset = 0;
290
        var names = {};
291
        for (var i=0,ilen=lines.length;i<ilen;i++) {
292
            var line = lines[i];
293
            var mm = line.match(CSL.NOTE_FIELD_REGEXP);
294
            if (!line.trim()) {
295
                continue;
296
            } else if (!mm) {
297
                if (i === 0) {
298
                    continue;
299
                } else {
300
                    offset = i;
301
                    break;
302
                }
303
            }
304
            var key = mm[1];
305
            var val = mm[2].replace(/^\s+/, "").replace(/\s+$/, "");
306
            if (key === "type") {
307
                Item.type = val;
308
                lines[i] = "";
309
            } else if (CSL.DATE_VARIABLES.indexOf(key) > -1) {
310
                if (allowDateOverride) {
311
                    Item[key] = {raw: val};
312
                    if (!validFieldsForType || (validFieldsForType[key] && val.match(/^[0-9]{4}(?:-[0-9]{1,2}(?:-[0-9]{1,2})*)*$/))) {
313
                        lines[i] = "";
314
                    }
315
                }
316
            } else if (!Item[key]) {
317
                if (CSL.NAME_VARIABLES.indexOf(key) > -1) {
318
                    if (!names[key]) {
319
                        names[key] = [];
320
                    }
321
                    var lst = val.split(/\s*\|\|\s*/);
322
                    if (lst.length === 1) {
323
                        names[key].push({literal:lst[0]});
324
                    } else if (lst.length === 2) {
325
                        var name = {family:lst[0],given:lst[1]};
326
                        CSL.parseParticles(name);
327
                        names[key].push(name);
328
                    }
329
                } else {
330
                    Item[key] = val;
331
                }
332
                if (!validFieldsForType || validFieldsForType[key]) {
333
                    lines[i] = "";
334
                }
335
            }
336
        }
337
        for (var key in names) {
338
            Item[key] = names[key];
339
        }
340
        if (validFieldsForType) {
341
            if (lines[offset].trim()) {
342
                lines[offset] = '\n' + lines[offset]
343
            }
344
            for (var i=offset-1;i>-1;i--) {
345
                if (!lines[i].trim()) {
346
                    lines = lines.slice(0, i).concat(lines.slice(i + 1));
347
                }
348
            }
349
        }
350
        Item.note = lines.join("\n").trim();
351
    },
352
    GENDERS: ["masculine", "feminine"],
353
    ERROR_NO_RENDERED_FORM: 1,
354
    PREVIEW: "Just for laughs.",
355
    ASSUME_ALL_ITEMS_REGISTERED: 2,
356
    START: 0,
357
    END: 1,
358
    SINGLETON: 2,
359
    SEEN: 6,
360
    SUCCESSOR: 3,
361
    SUCCESSOR_OF_SUCCESSOR: 4,
362
    SUPPRESS: 5,
363
    SINGULAR: 0,
364
    PLURAL: 1,
365
    LITERAL: true,
366
    BEFORE: 1,
367
    AFTER: 2,
368
    DESCENDING: 1,
369
    ASCENDING: 2,
370
    ONLY_FIRST: 1,
371
    ALWAYS: 2,
372
    ONLY_LAST: 3,
373
    FINISH: 1,
374
    POSITION_FIRST: 0,
375
    POSITION_SUBSEQUENT: 1,
376
    POSITION_IBID: 2,
377
    POSITION_IBID_WITH_LOCATOR: 3,
378
    MARK_TRAILING_NAMES: true,
379
    POSITION_TEST_VARS: ["position", "first-reference-note-number", "near-note"],
380
    AREAS: ["citation", "citation_sort", "bibliography", "bibliography_sort"],
381
    CITE_FIELDS: ["first-reference-note-number", "locator", "locator-extra"],
382
    MINIMAL_NAME_FIELDS: ["literal", "family"],
383
    SWAPPING_PUNCTUATION: [".", "!", "?", ":", ","],
384
    TERMINAL_PUNCTUATION: [":", ".", ";", "!", "?", " "],
385
    NONE: 0,
386
    NUMERIC: 1,
387
    POSITION: 2,
388
    COLLAPSE_VALUES: ["citation-number", "year", "year-suffix"],
389
    DATE_PARTS: ["year", "month", "day"],
390
    DATE_PARTS_ALL: ["year", "month", "day", "season"],
391
    DATE_PARTS_INTERNAL: ["year", "month", "day", "year_end", "month_end", "day_end"],
392
    NAME_PARTS: ["non-dropping-particle", "family", "given", "dropping-particle", "suffix", "literal"],
393
    DECORABLE_NAME_PARTS: ["given", "family", "suffix"],
394
    DISAMBIGUATE_OPTIONS: [
395
        "disambiguate-add-names",
396
        "disambiguate-add-givenname",
397
        "disambiguate-add-year-suffix"
398
    ],
399
    GIVENNAME_DISAMBIGUATION_RULES: [
400
        "all-names",
401
        "all-names-with-initials",
402
        "primary-name",
403
        "primary-name-with-initials",
404
        "by-cite"
405
    ],
406
    NAME_ATTRIBUTES: [
407
        "and",
408
        "delimiter-precedes-last",
409
        "delimiter-precedes-et-al",
410
        "initialize-with",
411
        "initialize",
412
        "name-as-sort-order",
413
        "sort-separator",
414
        "et-al-min",
415
        "et-al-use-first",
416
        "et-al-subsequent-min",
417
        "et-al-subsequent-use-first",
418
        "form",
419
        "prefix",
420
        "suffix",
421
        "delimiter"
422
    ],
423
    PARALLEL_MATCH_VARS: ["container-title"],
424
    PARALLEL_TYPES: ["bill","gazette","regulation","legislation","legal_case","treaty","article-magazine","article-journal"],
425
    PARALLEL_COLLAPSING_MID_VARSET: ["volume", "issue", "container-title", "section", "collection-number"],
426
    LOOSE: 0,
427
    STRICT: 1,
428
    TOLERANT: 2,
429
    PREFIX_PUNCTUATION: /[.;:]\s*$/,
430
    SUFFIX_PUNCTUATION: /^\s*[.;:,\(\)]/,
431
    NUMBER_REGEXP: /(?:^\d+|\d+$)/,
432
    NAME_INITIAL_REGEXP: /^([A-Z\u0590-\u05ff\u00c0-\u017f\u0400-\u042f\u0600-\u06ff\u0370\u0372\u0376\u0386\u0388-\u03ab\u03e2\u03e4\u03e6\u03e8\u03ea\u03ec\u03ee\u03f4\u03f7\u03fd-\u03ff])([a-zA-Z\u00c0-\u017f\u0400-\u052f\u0600-\u06ff\u0370-\u03ff\u1f00-\u1fff]*|)/,
433
    ROMANESQUE_REGEXP: /[-0-9a-zA-Z\u0590-\u05d4\u05d6-\u05ff\u0080-\u017f\u0400-\u052f\u0370-\u03ff\u1f00-\u1fff\u0600-\u06ff\u200c\u200d\u200e\u0218\u0219\u021a\u021b\u202a-\u202e]/,
434
    ROMANESQUE_NOT_REGEXP: /[^a-zA-Z\u0590-\u05ff\u00c0-\u017f\u0400-\u052f\u0370-\u03ff\u1f00-\u1fff\u0600-\u06ff\u200c\u200d\u200e\u0218\u0219\u021a\u021b\u202a-\u202e]/g,
435
    STARTSWITH_ROMANESQUE_REGEXP: /^[&a-zA-Z\u0590-\u05d4\u05d6-\u05ff\u00c0-\u017f\u0400-\u052f\u0370-\u03ff\u1f00-\u1fff\u0600-\u06ff\u200c\u200d\u200e\u0218\u0219\u021a\u021b\u202a-\u202e]/,
436
    ENDSWITH_ROMANESQUE_REGEXP: /[.;:&a-zA-Z\u0590-\u05d4\u05d6-\u05ff\u00c0-\u017f\u0400-\u052f\u0370-\u03ff\u1f00-\u1fff\u0600-\u06ff\u200c\u200d\u200e\u0218\u0219\u021a\u021b\u202a-\u202e]$/,
437
    ALL_ROMANESQUE_REGEXP: /^[a-zA-Z\u0590-\u05ff\u00c0-\u017f\u0400-\u052f\u0370-\u03ff\u1f00-\u1fff\u0600-\u06ff\u200c\u200d\u200e\u0218\u0219\u021a\u021b\u202a-\u202e]+$/,
438
    VIETNAMESE_SPECIALS: /[\u00c0-\u00c3\u00c8-\u00ca\u00cc\u00cd\u00d2-\u00d5\u00d9\u00da\u00dd\u00e0-\u00e3\u00e8-\u00ea\u00ec\u00ed\u00f2-\u00f5\u00f9\u00fa\u00fd\u0101\u0103\u0110\u0111\u0128\u0129\u0168\u0169\u01a0\u01a1\u01af\u01b0\u1ea0-\u1ef9]/,
439
    VIETNAMESE_NAMES: /^(?:(?:[.AaBbCcDdEeGgHhIiKkLlMmNnOoPpQqRrSsTtUuVvXxYy \u00c0-\u00c3\u00c8-\u00ca\u00cc\u00cd\u00d2-\u00d5\u00d9\u00da\u00dd\u00e0-\u00e3\u00e8-\u00ea\u00ec\u00ed\u00f2-\u00f5\u00f9\u00fa\u00fd\u0101\u0103\u0110\u0111\u0128\u0129\u0168\u0169\u01a0\u01a1\u01af\u01b0\u1ea0-\u1ef9]{2,6})(\s+|$))+$/,
440
    NOTE_FIELDS_REGEXP: /\{:(?:[\-_a-z]+|[A-Z]+):[^\}]+\}/g,
441
    NOTE_FIELD_REGEXP: /^([\-_a-z]+|[A-Z]+):\s*([^\}]+)$/,
442
	PARTICLE_GIVEN_REGEXP: /^([^ ]+(?:\u02bb |\u2019 | |\' ) *)(.+)$/,
443
	PARTICLE_FAMILY_REGEXP: /^([^ ]+(?:\-|\u02bb|\u2019| |\') *)(.+)$/,
444
    DISPLAY_CLASSES: ["block", "left-margin", "right-inline", "indent"],
445
    NAME_VARIABLES: [
446
        "author",
447
        "editor",
448
        "translator",
449
        "contributor",
450
        "collection-editor",
451
        "composer",
452
        "container-author",
453
        "director",
454
        "editorial-director",
455
        "interviewer",
456
        "original-author",
457
        "recipient"
458
    ],
459
    NUMERIC_VARIABLES: [
460
        "call-number",
461
        "chapter-number",
462
        "collection-number",
463
        "edition",
464
        "page",
465
        "issue",
466
        "locator",
467
        "number",
468
        "number-of-pages",
469
        "number-of-volumes",
470
        "volume",
471
        "citation-number"
472
    ],
473
    DATE_VARIABLES: [
474
        "locator-date",
475
        "issued",
476
        "event-date",
477
        "accessed",
478
        "container",
479
        "original-date",
480
        "publication-date",
481
        "original-date",
482
        "available-date",
483
        "submitted"
484
    ],
485
    TITLE_FIELD_SPLITS: function(seg) {
486
        var keys = ["title", "short", "main", "sub"];
487
        var ret = {};
488
        for (var i=0,ilen=keys.length;i<ilen;i++) {
489
            ret[keys[i]] = seg + "title" + (keys[i] === "title" ? "" : "-" + keys[i]);
490
        }
491
        return ret;
492
    },
493
    TAG_USEALL: function (str) {
494
        var ret, open, close, end;
495
        ret = [""];
496
        open = str.indexOf("<");
497
        close = str.indexOf(">");
498
        while (open > -1 && close > -1) {
499
            if (open > close) {
500
                end = open + 1;
501
            } else {
502
                end = close + 1;
503
            }
504
            if (open < close && str.slice(open + 1, close).indexOf("<") === -1) {
505
                ret[ret.length - 1] += str.slice(0, open);
506
                ret.push(str.slice(open, close + 1));
507
                ret.push("");
508
                str = str.slice(end);
509
            } else {
510
                ret[ret.length - 1] += str.slice(0, close + 1);
511
                str = str.slice(end);
512
            }
513
            open = str.indexOf("<");
514
            close = str.indexOf(">");
515
        }
516
        ret[ret.length - 1] += str;
517
        return ret;
518
    },
519
    demoteNoiseWords: function (state, fld, drop_or_demote) {
520
        var SKIP_WORDS = state.locale[state.opt.lang].opts["leading-noise-words"];
521
        if (fld && drop_or_demote) {
522
            fld = fld.split(/\s+/);
523
            fld.reverse();
524
            var toEnd = [];
525
            for (var j  = fld.length - 1; j > -1; j += -1) {
526
                if (SKIP_WORDS.indexOf(fld[j].toLowerCase()) > -1) {
527
                    toEnd.push(fld.pop());
528
                } else {
529
                    break;
530
                }
531
            }
532
            fld.reverse();
533
            var start = fld.join(" ");
534
            var end = toEnd.join(" ");
535
            if ("drop" === drop_or_demote || !end) {
536
                fld = start;
537
            } else if ("demote" === drop_or_demote) {
538
                fld = [start, end].join(", ");
539
            }
540
        }
541
        return fld;
542
    },
543
    extractTitleAndSubtitle: function (Item) {
544
        var segments = ["", "container-"];
545
        for (var i=0,ilen=segments.length;i<ilen;i++) {
546
            var seg = segments[i];
547
            var title = CSL.TITLE_FIELD_SPLITS(seg);
548
            var langs = [false];
549
            if (Item.multi) {
550
                for (var lang in Item.multi._keys[title.short]) {
551
                    langs.push(lang);
552
                }
553
            }
554
            for (var j=0,jlen=langs.length;j<ilen;j++) {
555
                var lang = langs[j];
556
                var vals = {};
557
                if (lang) {
558
                    if (Item.multi._keys[title.title]) {
559
                        vals[title.title] = Item.multi._keys[title.title][lang];
560
                    }
561
                    if (Item.multi._keys[title["short"]]) {
562
                        vals[title["short"]] = Item.multi._keys[title["short"]][lang];
563
                    }
564
                } else {
565
                    vals[title.title] = Item[title.title];
566
                    vals[title["short"]] = Item[title["short"]];
567
                }
568
                vals[title.main] = vals[title.title];
569
                vals[title.sub] = false;
570
                if (vals[title.title] && vals[title["short"]]) {
571
                    var shortTitle = vals[title["short"]];
572
                    var offset = shortTitle.length;
573
                    if (vals[title.title].slice(0,offset) === shortTitle && vals[title.title].slice(offset).match(/^\s*:/)) {
574
                        vals[title.main] = vals[title.title].slice(0,offset).replace(/\s+$/,"");
575
                        vals[title.sub] = vals[title.title].slice(offset).replace(/^\s*:\s*/,"");
576
                    }
577
                }
578
                if (lang) {
579
                    for (var key in vals) {
580
                        if (!Item.multi._keys[key]) {
581
                            Item.multi._keys[key] = {};
582
                        }
583
                        Item.multi._keys[key][lang] = vals[key];
584
                    }
585
                } else {
586
                    for (var key in vals) {
587
                        Item[key] = vals[key];
588
                    }
589
                }
590
            }
591
        }
592
    },
593
    titlecaseSentenceOrNormal: function(state, Item, seg, lang, sentenceCase) {
594
        var title = CSL.TITLE_FIELD_SPLITS(seg);
595
        var vals = {};
596
        if (lang && Item.multi) {
597
            if (Item.multi._keys[title.title]) {
598
                vals[title.title] = Item.multi._keys[title.title][lang];
599
            }
600
            if (Item.multi._keys[title.main]) {
601
                vals[title.main] = Item.multi._keys[title.main][lang];
602
            }
603
            if (Item.multi._keys[title.sub]) {
604
                vals[title.sub] = Item.multi._keys[title.sub][lang];
605
            }
606
        } else {
607
            vals[title.title] = Item[title.title];
608
            vals[title.main] = Item[title.main];
609
            vals[title.sub] = Item[title.sub];
610
        }
611
        if (vals[title.main] && vals[title.sub]) {
612
            var mainTitle = vals[title.main];
613
            var subTitle = vals[title.sub];
614
            if (sentenceCase) {
615
                mainTitle = CSL.Output.Formatters.sentence(state, mainTitle);
616
                subTitle = CSL.Output.Formatters.sentence(state, subTitle);
617
            } else {
618
                subTitle = CSL.Output.Formatters["capitalize-first"](state, subTitle);
619
            }
620
            return [mainTitle, subTitle].join(vals[title.title].slice(mainTitle.length, -1 * subTitle.length));
621
        } else {
622
            if (sentenceCase) {
623
                return CSL.Output.Formatters.sentence(state, vals[title.title]);
624
            } else {
625
                return vals[title.title];
626
            }
627
        }
628
    },
629
    getSafeEscape: function(state) {
630
        if (["bibliography", "citation"].indexOf(state.tmp.area) > -1) {
631
            var callbacks = [];
632
            if (state.opt.development_extensions.thin_non_breaking_space_html_hack && state.opt.mode === "html") {
633
                callbacks.push(function (txt) {
634
                    return txt.replace(/\u202f/g, '<span style="white-space:nowrap">&thinsp;</span>');
635
                });
636
            }
637
            if (callbacks.length) {
638
                return function (txt) {
639
                    for (var i = 0, ilen = callbacks.length; i < ilen; i += 1) {
640
                        txt = callbacks[i](txt);
641
                    }
642
                    return CSL.Output.Formats[state.opt.mode].text_escape(txt);
643
                }
644
            } else {
645
                return CSL.Output.Formats[state.opt.mode].text_escape;
646
            }
647
        } else {
648
            return function (txt) { return txt; };
649
        }
650
    },
651
    SKIP_WORDS: ["about","above","across","afore","after","against","along","alongside","amid","amidst","among","amongst","anenst","apropos","apud","around","as","aside","astride","at","athwart","atop","barring","before","behind","below","beneath","beside","besides","between","beyond","but","by","circa","despite","down","during","except","for","forenenst","from","given","in","inside","into","lest","like","modulo","near","next","notwithstanding","of","off","on","onto","out","over","per","plus","pro","qua","sans","since","than","through"," thru","throughout","thruout","till","to","toward","towards","under","underneath","until","unto","up","upon","versus","vs.","v.","vs","v","via","vis-à-vis","with","within","without","according to","ahead of","apart from","as for","as of","as per","as regards","aside from","back to","because of","close to","due to","except for","far from","inside of","instead of","near to","next to","on to","out from","out of","outside of","prior to","pursuant to","rather than","regardless of","such as","that of","up to","where as","or", "yet", "so", "for", "and", "nor", "a", "an", "the", "de", "d'", "von", "van", "c", "et", "ca"],
652
    FORMAT_KEY_SEQUENCE: [
653
        "@strip-periods",
654
        "@font-style",
655
        "@font-variant",
656
        "@font-weight",
657
        "@text-decoration",
658
        "@vertical-align",
659
        "@quotes"
660
    ],
661
    INSTITUTION_KEYS: [
662
        "font-style",
663
        "font-variant",
664
        "font-weight",
665
        "text-decoration",
666
        "text-case"
667
    ],
668
    SUFFIX_CHARS: "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z",
669
    ROMAN_NUMERALS: [
670
        [ "", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix" ],
671
        [ "", "x", "xx", "xxx", "xl", "l", "lx", "lxx", "lxxx", "xc" ],
672
        [ "", "c", "cc", "ccc", "cd", "d", "dc", "dcc", "dccc", "cm" ],
673
        [ "", "m", "mm", "mmm", "mmmm", "mmmmm"]
674
    ],
675
    CREATORS: [
676
        "author",
677
        "editor",
678
        "contributor",
679
        "translator",
680
        "recipient",
681
        "interviewer",
682
        "composer",
683
        "original-author",
684
        "container-author",
685
        "collection-editor"
686
    ],
687
    LANGS: {
688
        "af-ZA":"Afrikaans",
689
        "ar":"Arabic",
690
        "bg-BG":"Bulgarian",
691
        "ca-AD":"Catalan",
692
        "cs-CZ":"Czech",
693
        "da-DK":"Danish",
694
        "de-AT":"Austrian",
695
        "de-CH":"German (CH)",
696
        "de-DE":"German (DE)",
697
        "el-GR":"Greek",
698
        "en-GB":"English (GB)",
699
        "en-US":"English (US)",
700
        "es-ES":"Spanish",
701
        "et-EE":"Estonian",
702
        "eu":"European",
703
        "fa-IR":"Persian",
704
        "fi-FI":"Finnish",
705
        "fr-CA":"French (CA)",
706
        "fr-FR":"French (FR)",
707
        "he-IL":"Hebrew",
708
        "hr-HR":"Croatian",
709
        "hu-HU":"Hungarian",
710
        "is-IS":"Icelandic",
711
        "it-IT":"Italian",
712
        "ja-JP":"Japanese",
713
        "km-KH":"Khmer",
714
        "ko-KR":"Korean",
715
        "lt-LT":"Lithuanian",
716
        "lv-LV":"Latvian",
717
        "mn-MN":"Mongolian",
718
        "nb-NO":"Norwegian (Bokmål)",
719
        "nl-NL":"Dutch",
720
        "nn-NO":"Norwegian (Nynorsk)",
721
        "pl-PL":"Polish",
722
        "pt-BR":"Portuguese (BR)",
723
        "pt-PT":"Portuguese (PT)",
724
        "ro-RO":"Romanian",
725
        "ru-RU":"Russian",
726
        "sk-SK":"Slovak",
727
        "sl-SI":"Slovenian",
728
        "sr-RS":"Serbian",
729
        "sv-SE":"Swedish",
730
        "th-TH":"Thai",
731
        "tr-TR":"Turkish",
732
        "uk-UA":"Ukranian",
733
        "vi-VN":"Vietnamese",
734
        "zh-CN":"Chinese (CN)",
735
        "zh-TW":"Chinese (TW)"
736
    },
737
    LANG_BASES: {
738
        af: "af_ZA",
739
        ar: "ar",
740
        bg: "bg_BG",
741
        ca: "ca_AD",
742
        cs: "cs_CZ",
743
        da: "da_DK",
744
        de: "de_DE",
745
        el: "el_GR",
746
        en: "en_US",
747
        es: "es_ES",
748
        et: "et_EE",
749
        eu: "eu",
750
        fa: "fa_IR",
751
        fi: "fi_FI",
752
        fr: "fr_FR",
753
        he: "he_IL",
754
        hr: "hr-HR",
755
        hu: "hu_HU",
756
        is: "is_IS",
757
        it: "it_IT",
758
        ja: "ja_JP",
759
        km: "km_KH",
760
        ko: "ko_KR",
761
        lt: "lt_LT",
762
        lv: "lv-LV",
763
        mn: "mn_MN",
764
        nb: "nb_NO",
765
        nl: "nl_NL",
766
        nn: "nn-NO",
767
        pl: "pl_PL",
768
        pt: "pt_PT",
769
        ro: "ro_RO",
770
        ru: "ru_RU",
771
        sk: "sk_SK",
772
        sl: "sl_SI",
773
        sr: "sr_RS",
774
        sv: "sv_SE",
775
        th: "th_TH",
776
        tr: "tr_TR",
777
        uk: "uk_UA",
778
        vi: "vi_VN",
779
        zh: "zh_CN"
780
    },
781
    SUPERSCRIPTS: {
782
        "\u00AA": "\u0061",
783
        "\u00B2": "\u0032",
784
        "\u00B3": "\u0033",
785
        "\u00B9": "\u0031",
786
        "\u00BA": "\u006F",
787
        "\u02B0": "\u0068",
788
        "\u02B1": "\u0266",
789
        "\u02B2": "\u006A",
790
        "\u02B3": "\u0072",
791
        "\u02B4": "\u0279",
792
        "\u02B5": "\u027B",
793
        "\u02B6": "\u0281",
794
        "\u02B7": "\u0077",
795
        "\u02B8": "\u0079",
796
        "\u02E0": "\u0263",
797
        "\u02E1": "\u006C",
798
        "\u02E2": "\u0073",
799
        "\u02E3": "\u0078",
800
        "\u02E4": "\u0295",
801
        "\u1D2C": "\u0041",
802
        "\u1D2D": "\u00C6",
803
        "\u1D2E": "\u0042",
804
        "\u1D30": "\u0044",
805
        "\u1D31": "\u0045",
806
        "\u1D32": "\u018E",
807
        "\u1D33": "\u0047",
808
        "\u1D34": "\u0048",
809
        "\u1D35": "\u0049",
810
        "\u1D36": "\u004A",
811
        "\u1D37": "\u004B",
812
        "\u1D38": "\u004C",
813
        "\u1D39": "\u004D",
814
        "\u1D3A": "\u004E",
815
        "\u1D3C": "\u004F",
816
        "\u1D3D": "\u0222",
817
        "\u1D3E": "\u0050",
818
        "\u1D3F": "\u0052",
819
        "\u1D40": "\u0054",
820
        "\u1D41": "\u0055",
821
        "\u1D42": "\u0057",
822
        "\u1D43": "\u0061",
823
        "\u1D44": "\u0250",
824
        "\u1D45": "\u0251",
825
        "\u1D46": "\u1D02",
826
        "\u1D47": "\u0062",
827
        "\u1D48": "\u0064",
828
        "\u1D49": "\u0065",
829
        "\u1D4A": "\u0259",
830
        "\u1D4B": "\u025B",
831
        "\u1D4C": "\u025C",
832
        "\u1D4D": "\u0067",
833
        "\u1D4F": "\u006B",
834
        "\u1D50": "\u006D",
835
        "\u1D51": "\u014B",
836
        "\u1D52": "\u006F",
837
        "\u1D53": "\u0254",
838
        "\u1D54": "\u1D16",
839
        "\u1D55": "\u1D17",
840
        "\u1D56": "\u0070",
841
        "\u1D57": "\u0074",
842
        "\u1D58": "\u0075",
843
        "\u1D59": "\u1D1D",
844
        "\u1D5A": "\u026F",
845
        "\u1D5B": "\u0076",
846
        "\u1D5C": "\u1D25",
847
        "\u1D5D": "\u03B2",
848
        "\u1D5E": "\u03B3",
849
        "\u1D5F": "\u03B4",
850
        "\u1D60": "\u03C6",
851
        "\u1D61": "\u03C7",
852
        "\u2070": "\u0030",
853
        "\u2071": "\u0069",
854
        "\u2074": "\u0034",
855
        "\u2075": "\u0035",
856
        "\u2076": "\u0036",
857
        "\u2077": "\u0037",
858
        "\u2078": "\u0038",
859
        "\u2079": "\u0039",
860
        "\u207A": "\u002B",
861
        "\u207B": "\u2212",
862
        "\u207C": "\u003D",
863
        "\u207D": "\u0028",
864
        "\u207E": "\u0029",
865
        "\u207F": "\u006E",
866
        "\u2120": "\u0053\u004D",
867
        "\u2122": "\u0054\u004D",
868
        "\u3192": "\u4E00",
869
        "\u3193": "\u4E8C",
870
        "\u3194": "\u4E09",
871
        "\u3195": "\u56DB",
872
        "\u3196": "\u4E0A",
873
        "\u3197": "\u4E2D",
874
        "\u3198": "\u4E0B",
875
        "\u3199": "\u7532",
876
        "\u319A": "\u4E59",
877
        "\u319B": "\u4E19",
878
        "\u319C": "\u4E01",
879
        "\u319D": "\u5929",
880
        "\u319E": "\u5730",
881
        "\u319F": "\u4EBA",
882
        "\u02C0": "\u0294",
883
        "\u02C1": "\u0295",
884
        "\u06E5": "\u0648",
885
        "\u06E6": "\u064A"
886
    },
887
    SUPERSCRIPTS_REGEXP: new RegExp("[\u00AA\u00B2\u00B3\u00B9\u00BA\u02B0\u02B1\u02B2\u02B3\u02B4\u02B5\u02B6\u02B7\u02B8\u02E0\u02E1\u02E2\u02E3\u02E4\u1D2C\u1D2D\u1D2E\u1D30\u1D31\u1D32\u1D33\u1D34\u1D35\u1D36\u1D37\u1D38\u1D39\u1D3A\u1D3C\u1D3D\u1D3E\u1D3F\u1D40\u1D41\u1D42\u1D43\u1D44\u1D45\u1D46\u1D47\u1D48\u1D49\u1D4A\u1D4B\u1D4C\u1D4D\u1D4F\u1D50\u1D51\u1D52\u1D53\u1D54\u1D55\u1D56\u1D57\u1D58\u1D59\u1D5A\u1D5B\u1D5C\u1D5D\u1D5E\u1D5F\u1D60\u1D61\u2070\u2071\u2074\u2075\u2076\u2077\u2078\u2079\u207A\u207B\u207C\u207D\u207E\u207F\u2120\u2122\u3192\u3193\u3194\u3195\u3196\u3197\u3198\u3199\u319A\u319B\u319C\u319D\u319E\u319F\u02C0\u02C1\u06E5\u06E6]", "g"),
888
    UPDATE_GROUP_CONTEXT_CONDITION: function (state, termtxt, valueTerm) {
889
        if (state.tmp.group_context.tip.condition) {
890
            if (state.tmp.group_context.tip.condition.test) {
891
                var testres;
892
                if (state.tmp.group_context.tip.condition.test === "empty-label") {
893
                    testres = !termtxt;
894
                } else if (state.tmp.group_context.tip.condition.test === "comma-safe") {
895
                    var empty = !termtxt;
896
                    var alpha = termtxt.slice(0,1).match(CSL.ALL_ROMANESQUE_REGEXP);
897
                    var num = state.tmp.just_did_number;
898
                    if (empty) {
899
                        testres = true;
900
                    } else if (num) {
901
                        if (alpha && !valueTerm) {
902
                            testres = true;
903
                        } else {
904
                            testres = false;
905
                        }
906
                    } else {
907
                        if (alpha && !valueTerm) {
908
                            testres = true;
909
                        } else {
910
                            testres = false;
911
                        }
912
                    }
913
                }
914
                if (testres) {
915
                    state.tmp.group_context.tip.force_suppress = false;
916
                } else {
917
                    state.tmp.group_context.tip.force_suppress = true;
918
                }
919
                if (state.tmp.group_context.tip.condition.not) {
920
                    state.tmp.group_context.tip.force_suppress = !state.tmp.group_context.tip.force_suppress;
921
                }
922
            }
923
        } else {
924
            if (termtxt.slice(-1).match(/[0-9]/)) {
925
                state.tmp.just_did_number = true;
926
            } else {
927
                state.tmp.just_did_number = false;
928
            }
929
        }
930
    },
931
    locale: {},
932
    locale_opts: {},
933
    locale_dates: {}
934
};
935
if (typeof require !== "undefined" && typeof module !== 'undefined' && "exports" in module) {
936
    var CSL_IS_NODEJS = true;
937
    exports.CSL = CSL;
938
}
939
CSL.TERMINAL_PUNCTUATION_REGEXP = new RegExp("^([" + CSL.TERMINAL_PUNCTUATION.slice(0, -1).join("") + "])(.*)");
940
CSL.CLOSURES = new RegExp(".*[\\]\\)]");
941
if ("undefined" === typeof console) {
942
    CSL.debug = function (str) {
943
        dump("CSL: " + str + "\n");
944
    };
945
    CSL.error = function (str) {
946
        dump("CSL error: " + str + "\n");
947
    };
948
} else {
949
    CSL.debug = function (str) {
950
        console.log("CSL: " + str);
951
    };
952
    CSL.error = function (str) {
953
        console.log("CSL error: " + str);
954
    };
955
}
956
CSL.XmlJSON = function (dataObj) {
957
    this.dataObj = dataObj;
958
    this.institution = {
959
        name:"institution",
960
        attrs:{
961
            "institution-parts":"long",
962
            "delimiter":", ",
963
            "substitute-use-first":"1",
964
            "use-last":"1"
965
        },
966
        children:[
967
            {
968
                name:"institution-part",
969
                attrs:{
970
                    name:"long"
971
                },
972
                children:[]
973
            }
974
        ]
975
    };
976
};
977
CSL.XmlJSON.prototype.clean = function (json) {
978
    return json;
979
};
980
CSL.XmlJSON.prototype.getStyleId = function (myjson, styleName) {
981
    var tagName = 'id';
982
    if (styleName) {
983
        tagName = 'title';
984
    }
985
    var ret = "";
986
    var children = myjson.children;
987
    for (var i=0,ilen=children.length;i<ilen;i++) {
988
        if (children[i].name === 'info') {
989
            var grandkids = children[i].children;
990
            for (var j=0,jlen=grandkids.length;j<jlen;j++) {
991
                if (grandkids[j].name === tagName) {
992
                    ret = grandkids[j].children[0];
993
                }
994
            }
995
        }
996
    }
997
    return ret;
998
};
999
CSL.XmlJSON.prototype.children = function (myjson) {
1000
    if (myjson && myjson.children.length) {
1001
        return myjson.children.slice();
1002
    } else {
1003
        return false;
1004
    }
1005
};
1006
CSL.XmlJSON.prototype.nodename = function (myjson) {
1007
    return myjson ? myjson.name : null;
1008
};
1009
CSL.XmlJSON.prototype.attributes = function (myjson) {
1010
    var ret = {};
1011
    for (var attrname in myjson.attrs) {
1012
        ret["@"+attrname] = myjson.attrs[attrname];
1013
    }
1014
    return ret;
1015
};
1016
CSL.XmlJSON.prototype.content = function (myjson) {
1017
    var ret = "";
1018
    if (!myjson || !myjson.children) {
1019
        return ret;
1020
    }
1021
    for (var i=0, ilen=myjson.children.length; i < ilen; i += 1) {
1022
        if ("string" === typeof myjson.children[i]) {
1023
            ret += myjson.children[i];
1024
        }
1025
    }
1026
    return ret;
1027
};
1028
CSL.XmlJSON.prototype.namespace = {}
1029
CSL.XmlJSON.prototype.numberofnodes = function (myjson) {
1030
    if (myjson && "number" == typeof myjson.length) {
1031
        return myjson.length;
1032
    } else {
1033
        return 0;
1034
    }
1035
};
1036
CSL.XmlJSON.prototype.getAttributeValue = function (myjson,name,namespace) {
1037
    var ret = "";
1038
    if (namespace) {
1039
        name = namespace+":"+name;
1040
    }
1041
    if (myjson) {
1042
        if (myjson.attrs) {
1043
            if (myjson.attrs[name]) {
1044
                ret = myjson.attrs[name];
1045
            } else {
1046
                ret = "";
1047
            }
1048
        }
1049
    }
1050
    return ret;
1051
}
1052
CSL.XmlJSON.prototype.getNodeValue = function (myjson,name) {
1053
    var ret = "";
1054
    if (name){
1055
        for (var i=0, ilen=myjson.children.length; i < ilen; i += 1) {
1056
            if (myjson.children[i].name === name) {
1057
                if (myjson.children[i].children.length) {
1058
                    ret = myjson.children[i];
1059
                } else {
1060
                    ret = "";
1061
                }
1062
            }
1063
        }
1064
    } else if (myjson) {
1065
        ret = myjson;
1066
    }
1067
    if (ret && ret.children && ret.children.length == 1 && "string" === typeof ret.children[0]) {
1068
        ret = ret.children[0];
1069
    }
1070
    return ret;
1071
}
1072
CSL.XmlJSON.prototype.setAttributeOnNodeIdentifiedByNameAttribute = function (myjson,nodename,partname,attrname,val) {
1073
    var pos, len, xml, nodes, node;
1074
    if (attrname.slice(0,1) === '@'){
1075
        attrname = attrname.slice(1);
1076
    }
1077
    for (var i=0,ilen=myjson.children.length; i<ilen; i += 1) {
1078
        if (myjson.children[i].name === nodename && myjson.children[i].attrs.name === partname) {
1079
            myjson.children[i].attrs[attrname] = val;
1080
        }
1081
    }
1082
}
1083
CSL.XmlJSON.prototype.deleteNodeByNameAttribute = function (myjson,val) {
1084
    var i, ilen;
1085
    for (i = 0, ilen = myjson.children.length; i < ilen; i += 1) {
1086
        if (!myjson.children[i] || "string" === typeof myjson.children[i]) {
1087
            continue;
1088
        }
1089
        if (myjson.children[i].attrs.name == val) {
1090
            myjson.children = myjson.children.slice(0,i).concat(myjson.children.slice(i+1));
1091
        }
1092
    }
1093
}
1094
CSL.XmlJSON.prototype.deleteAttribute = function (myjson,attrname) {
1095
    var i, ilen;
1096
    if ("undefined" !== typeof myjson.attrs[attrname]) {
1097
        myjson.attrs.pop(attrname);
1098
    }
1099
}
1100
CSL.XmlJSON.prototype.setAttribute = function (myjson,attr,val) {
1101
    myjson.attrs[attr] = val;
1102
    return false;
1103
}
1104
CSL.XmlJSON.prototype.nodeCopy = function (myjson,clone) {
1105
    if (!clone) {
1106
        var clone = {};
1107
    }
1108
    if ("object" === typeof clone && "undefined" === typeof clone.length) {
1109
        for (var key in myjson) {
1110
            if ("string" === typeof myjson[key]) {
1111
                clone[key] = myjson[key];
1112
            } else if ("object" === typeof myjson[key]) {
1113
                if ("undefined" === typeof myjson[key].length) {
1114
                    clone[key] = this.nodeCopy(myjson[key],{});
1115
                } else {
1116
                    clone[key] = this.nodeCopy(myjson[key],[]);
1117
                }
1118
            }
1119
        }
1120
    } else {
1121
        for (var i=0,ilen=myjson.length;i<ilen; i += 1) {
1122
            if ("string" === typeof myjson[i]) {
1123
                clone[i] = myjson[i];
1124
            } else {
1125
                clone[i] = this.nodeCopy(myjson[i],{});
1126
            }
1127
        }
1128
    }
1129
    return clone;
1130
}
1131
CSL.XmlJSON.prototype.getNodesByName = function (myjson,name,nameattrval,ret) {
1132
    var nodes, node, pos, len;
1133
    if (!ret) {
1134
        var ret = [];
1135
    }
1136
    if (!myjson || !myjson.children) {
1137
        return ret;
1138
    }
1139
    if (name === myjson.name) {
1140
        if (nameattrval) {
1141
            if (nameattrval === myjson.attrs.name) {
1142
                ret.push(myjson);
1143
            }
1144
        } else {
1145
            ret.push(myjson);
1146
        }
1147
    }
1148
    for (var i=0,ilen=myjson.children.length;i<ilen;i+=1){
1149
        if ("object" !== typeof myjson.children[i]) {
1150
            continue;
1151
        }
1152
        this.getNodesByName(myjson.children[i],name,nameattrval,ret);
1153
    }
1154
    return ret;
1155
}
1156
CSL.XmlJSON.prototype.nodeNameIs = function (myjson,name) {
1157
    if (typeof myjson === "undefined") {
1158
        return false;
1159
    }
1160
    if (name == myjson.name) {
1161
        return true;
1162
    }
1163
    return false;
1164
}
1165
CSL.XmlJSON.prototype.makeXml = function (myjson) {
1166
    if ("string" === typeof myjson) {
1167
        if (myjson.slice(0, 1) === "<") {
1168
            myjson = this.jsonStringWalker.walkToObject(myjson);
1169
        } else {
1170
            myjson = JSON.parse(myjson);
1171
        }
1172
    }
1173
    return myjson;
1174
};
1175
CSL.XmlJSON.prototype.insertChildNodeAfter = function (parent,node,pos,datejson) {
1176
    for (var i=0,ilen=parent.children.length;i<ilen;i+=1) {
1177
        if (node === parent.children[i]) {
1178
            parent.children = parent.children.slice(0,i).concat([datejson]).concat(parent.children.slice(i+1));
1179
            break;
1180
        }
1181
    }
1182
    return parent;
1183
};
1184
CSL.XmlJSON.prototype.insertPublisherAndPlace = function(myjson) {
1185
    if (myjson.name === "group") {
1186
        var useme = true;
1187
        var mustHaves = ["publisher","publisher-place"];
1188
        for (var i=0,ilen=myjson.children.length;i<ilen;i+=1) {
1189
            var haveVarname = mustHaves.indexOf(myjson.children[i].attrs.variable);
1190
            var isText = myjson.children[i].name === "text";
1191
            if (isText && haveVarname > -1 && !myjson.children[i].attrs.prefix && !myjson.children[i].attrs.suffix) {
1192
                mustHaves = mustHaves.slice(0,haveVarname).concat(mustHaves.slice(haveVarname+1));
1193
            } else {
1194
                useme = false;
1195
                break;
1196
            }
1197
        }
1198
        if (useme && !mustHaves.length) {
1199
            myjson.attrs["has-publisher-and-publisher-place"] = true;
1200
       }
1201
    }
1202
    for (var i=0,ilen=myjson.children.length;i<ilen;i+=1) {
1203
        if ("object" === typeof myjson.children[i]) {
1204
            this.insertPublisherAndPlace(myjson.children[i]);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff