@iebh/reflib 2.6.4 → 2.6.5

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/modules/bibtex.js CHANGED
@@ -4,10 +4,12 @@ import Emitter from '../shared/emitter.js';
4
4
  * Example: "Roomruangwong2020"
5
5
  */
6
6
  function generateCitationKey(ref) {
7
- let author = ref.authors?.[0] || ref.author?.split(/,|\sand\s/)[0] || 'Anon';
8
- author = author.replace(/\s+/g, '').replace(/[^a-zA-Z]/g, ''); // remove spaces & non-letters
9
- let year = ref.year || new Date().getFullYear();
10
- return `${author}${year}`;
7
+ let authorLastName = 'Anon';
8
+ if (Array.isArray(ref.authors) && ref.authors.length > 0) {
9
+ authorLastName = ref.authors[0].split(',')[0].trim();
10
+ }
11
+ let year = ref.year || 'n.d.'; // fallback if no year
12
+ return `${authorLastName}${year}`;
11
13
  }
12
14
  /**
13
15
  * Lookup enum for the current parser mode we are in
@@ -217,7 +219,7 @@ export function writeStream(stream, options) {
217
219
  defaultType: 'Misc',
218
220
  delimeter: '\n',
219
221
  omitUnkown: false,
220
- omitFields: new Set(['key', 'recNumber', 'type']),
222
+ omitFields: new Set(['recNumber', 'type']),
221
223
  recNumberRNPrefix: true,
222
224
  recNumberKey: true,
223
225
  ...options,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iebh/reflib",
3
- "version": "2.6.4",
3
+ "version": "2.6.5",
4
4
  "description": "Reference / Citation reference library utilities",
5
5
  "scripts": {
6
6
  "lint": "eslint",