citation-js 0.6.5 → 0.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/citation.js CHANGED
@@ -5664,7 +5664,7 @@ var lexer = _moo["default"].states({
5664
5664
  text: /[^{$}\s~\\]+/
5665
5665
  }),
5666
5666
  namesLiteral: _objectSpread(_objectSpread({
5667
- and: /\s+and\s+/,
5667
+ and: /\s+[aA][nN][dD]\s+/,
5668
5668
  comma: ',',
5669
5669
  hyphen: '-',
5670
5670
  equals: '='
@@ -7938,6 +7938,12 @@ function bibliography(data) {
7938
7938
  },{"./attr.js":77,"./engines.js":80,"@citation-js/core":10}],79:[function(require,module,exports){
7939
7939
  "use strict";
7940
7940
 
7941
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
7942
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7943
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7944
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7945
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7946
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7941
7947
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
7942
7948
  Object.defineProperty(exports, "__esModule", {
7943
7949
  value: true
@@ -7950,6 +7956,28 @@ function _interopRequireDefault(obj) {
7950
7956
  "default": obj
7951
7957
  };
7952
7958
  }
7959
+ function prepareCiteItem(citeItem) {
7960
+ return _typeof(citeItem) === 'object' ? citeItem : {
7961
+ id: citeItem
7962
+ };
7963
+ }
7964
+ function prepareCitation(citation) {
7965
+ if (citation.citationItems) {
7966
+ return citation;
7967
+ }
7968
+ return {
7969
+ citationItems: [].concat(citation).map(prepareCiteItem),
7970
+ properties: {
7971
+ noteIndex: 0
7972
+ }
7973
+ };
7974
+ }
7975
+ function prepareCitations(context) {
7976
+ if (!context) {
7977
+ return [];
7978
+ }
7979
+ return context.map(prepareCitation);
7980
+ }
7953
7981
  function citation(data) {
7954
7982
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7955
7983
  var _options$template = options.template,
@@ -7964,22 +7992,11 @@ function citation(data) {
7964
7992
  var entries = options.entry ? [].concat(options.entry) : ids;
7965
7993
  data = _core.util.downgradeCsl(data);
7966
7994
  var citeproc = (0, _engines["default"])(data, template, lang, format);
7967
- citeproc.updateItems(ids);
7968
- var _options$citationsPre = options.citationsPre,
7969
- citationsPre = _options$citationsPre === void 0 ? [] : _options$citationsPre,
7970
- _options$citationsPos = options.citationsPost,
7971
- citationsPost = _options$citationsPos === void 0 ? [] : _options$citationsPos;
7972
- var citation = citeproc.previewCitationCluster({
7973
- citationItems: entries.map(function (id) {
7974
- return _typeof(id) === 'object' ? id : {
7975
- id: id
7976
- };
7977
- }),
7978
- properties: {
7979
- noteIndex: 0
7980
- }
7981
- }, citationsPre, citationsPost, format);
7982
- return citation;
7995
+ var before = prepareCitations(options.citationsPre);
7996
+ var citation = prepareCitation(entries);
7997
+ var after = prepareCitations(options.citationsPost);
7998
+ var output = citeproc.rebuildProcessorState([].concat(_toConsumableArray(before), [citation], _toConsumableArray(after)), format, []);
7999
+ return output[before.length][2];
7983
8000
  }
7984
8001
 
7985
8002
  },{"./engines.js":80,"@citation-js/core":10}],80:[function(require,module,exports){
@@ -8332,6 +8349,15 @@ var formats = {
8332
8349
  "extends": '@else/url'
8333
8350
  }
8334
8351
  },
8352
+ '@doi/short-url': {
8353
+ parse: function parse(url) {
8354
+ return url.replace(/^(\s*)/, '$1https://');
8355
+ },
8356
+ parseType: {
8357
+ dataType: 'String',
8358
+ predicate: /^\s*((?:dx\.)?doi\.org\/(10.\d{4,9}\/[-._;()/:A-Z0-9]+))\s*$/i
8359
+ }
8360
+ },
8335
8361
  '@doi/id': {
8336
8362
  parse: id.parse,
8337
8363
  parseType: {