forked from larsgw/citation.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompiled.js
174 lines (153 loc) · 5.39 KB
/
compiled.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
"use strict";
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var core = require('@citation-js/core');
require('@citation-js/plugin-bibjson');
require('@citation-js/plugin-bibtex');
require('@citation-js/plugin-csl');
require('@citation-js/plugin-doi');
require('@citation-js/plugin-ris');
var citeproc = require('citeproc');
var name = require('@citation-js/name');
var date = require('@citation-js/date');
function clone(obj) {
var copy = {};
for (var key in obj) {
copy[key] = _typeof(obj[key]) === 'object' ? clone(obj[key]) : obj[key];
}
return copy;
}
var attr = {
getAttributedEntry: function getAttributedEntry(string, name, value) {
return string.replace(/^\s*<[a-z]+/i, "$& data-".concat(name, "=\"").concat(value, "\""));
},
getPrefixedEntry: function getPrefixedEntry(value, id) {
return attr.getAttributedEntry(value, 'csl-entry-id', id);
},
getWrappedEntry: function getWrappedEntry(value, source, affixes) {
var getAffix = function getAffix(source, affix) {
return typeof affix === 'function' ? affix(source) : affix == null ? affix : '';
};
if (affixes.prepend == null && affixes.append == null) {
return value;
}
var prefix = getAffix(source, affixes.prepend);
var suffix = getAffix(source, affixes.append);
var start = '';
var end = '';
var match = value.match(/^([^>]+>)([\s\S]+)(<[^<]+)$/i);
if (match) {
start = match[1];
value = match[2];
end = match[3];
}
return start + prefix + value + suffix + end;
}
};
function Cite(data, opts) {
if (!(this instanceof Cite)) {
return new Cite(data, opts);
}
var self = new core.Cite(data, opts);
this._options = self._options;
this.log = self.log;
this.data = self.data;
}
Cite.prototype = Object.create(core.Cite.prototype);
Cite.async = core.Cite.async;
Cite.validateOptions = core.Cite.validateOptions;
Cite.validateOutputOptions = core.Cite.validateOutputOptions;
Cite.input = core.plugins.input.chain;
Cite.inputAsync = core.plugins.input.chainAsync;
Cite.util = Object.assign({
attr: attr
}, core.util);
Cite.version = {
cite: core.version,
citeproc: citeproc.PROCESSOR_VERSION
};
var CSL = core.plugins.config.get('@csl');
Cite.CSL = {
engine: require('@citation-js/plugin-csl/lib/engines').fetchEngine,
item: function item(data) {
return function (id) {
return data.find(function (entry) {
return entry.id === id;
});
};
},
locale: function locale(lang) {
return CSL.styles.get(CSL.styles.has(lang) ? lang : 'en-US');
},
style: function style(_style) {
return CSL.templates.get(CSL.templates.has(_style) ? _style : 'apa');
},
register: {
addTemplate: CSL.templates.add.bind(CSL.templates),
getTemplate: CSL.templates.get.bind(CSL.templates),
hasTemplate: CSL.templates.has.bind(CSL.templates),
addLocale: CSL.locales.add.bind(CSL.locales),
getLocale: CSL.locales.get.bind(CSL.locales),
hasLocale: CSL.locales.has.bind(CSL.locales)
}
};
Cite.plugins = clone(core.plugins);
delete Cite.plugins.input.util.clean;
Cite.parse = Object.assign({
input: {
chain: core.plugins.input.chain,
chainAsync: core.plugins.input.chainAsync,
chainLink: core.plugins.input.chainLink,
chainLinkAsync: core.plugins.input.chainLinkAsync,
data: core.plugins.input.data,
dataAsync: core.plugins.input.dataAsync,
type: core.plugins.input.type,
async: {
chain: core.plugins.input.chainAsync,
chainLink: core.plugins.input.chainLinkAsync,
data: core.plugins.input.dataAsync
}
},
name: name.parse,
date: date.parse,
csl: core.plugins.input.util.clean,
bibjson: require('@citation-js/plugin-bibjson').parsers.json.record,
bibtex: function (bibtex) {
return {
json: bibtex.parsers.json.parse,
prop: bibtex.parsers.prop.parse,
text: bibtex.parsers.text.parse,
type: bibtex.parsers.type.parse
};
}(require('@citation-js/plugin-bibtex/lib/input')),
bibtxt: function (bibtxt) {
return {
text: bibtxt.parse,
textEntry: bibtxt.textEntry
};
}(require('@citation-js/plugin-bibtex/lib/input/bibtxt')),
doi: function (doi) {
return {
api: doi.parsers.api.parse,
id: doi.parsers.id.parse,
async: {
api: doi.parsers.api.parseAsync
}
};
}(require('@citation-js/plugin-doi')),
json: require('@citation-js/core/lib/plugin-common/input').parsers.json.parse
}, Cite.plugins.input);
Cite.get = Object.assign({
dict: Cite.plugins.dict,
name: name.format,
date: date.format,
bibtex: {
json: require('@citation-js/plugin-bibtex/lib/output/json')["default"],
label: require('@citation-js/plugin-bibtex/lib/output/label')["default"],
text: require('@citation-js/plugin-bibtex/lib/output/text')["default"],
type: require('@citation-js/plugin-bibtex/lib/output/type')["default"]
},
bibtxt: require('@citation-js/plugin-bibtex/lib/output/bibtxt')["default"],
json: require('@citation-js/core/lib/plugin-common/output')["default"].data,
label: require('@citation-js/core/lib/plugin-common/output')["default"].label
}, Cite.plugins.output);
module.exports = Cite;