@iebh/reflib 2.3.4 → 2.4.0
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/README.md +3 -3
- package/lib/fields.js +1 -1
- package/lib/formats.js +1 -1
- package/modules/endnoteXml.js +4 -4
- package/modules/json.js +0 -1
- package/modules/medline.js +2 -2
- package/modules/ris.js +2 -2
- package/modules/shims/WritableStream-browser.js +1 -1
- package/package.json +11 -22
- package/.vscode/launch.json +0 -38
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
Reflib
|
|
2
2
|
======
|
|
3
3
|
Reference library processing for Node.
|
|
4
4
|
|
|
@@ -24,12 +24,12 @@ Compatibility
|
|
|
24
24
|
|
|
25
25
|
**Notes on different formats**:
|
|
26
26
|
|
|
27
|
-
* Medline seems to implement a totally different [publication type system](https://www.nlm.nih.gov/mesh/pubtypes.html) than others.
|
|
27
|
+
* Medline seems to implement a totally different [publication type system](https://www.nlm.nih.gov/mesh/pubtypes.html) than others. Reflib will attempt to guess the best match, storing the original type in the `medlineType` key. Should the citation library be exported _back_ to Medline / `.nbib` files this key will take precedence to avoid data loss
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
Reference Structure
|
|
31
31
|
===================
|
|
32
|
-
|
|
32
|
+
Reflib creates a simple Plain-Old-JavaScript-Object (POJO) for each reference it parses, or writes to a file format when given a collection of the same.
|
|
33
33
|
|
|
34
34
|
Each reference has the following standardized fields, these are translated from whatever internal format each module uses - e.g. the `TY` RIS field is automatically translated to `title`.
|
|
35
35
|
|
package/lib/fields.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Field definitions for
|
|
2
|
+
* Field definitions for Reflib citations
|
|
3
3
|
* @type {Object} An object lookup where each key represents a field within a citation
|
|
4
4
|
* @property {string} type A TypeScript compatible type for that field
|
|
5
5
|
* @property {array<string>} [value] Possible values if the type is restricted
|
package/lib/formats.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Lookup table of various citation file formats
|
|
3
|
-
* @type {array<Object>} A collection of
|
|
3
|
+
* @type {array<Object>} A collection of Reflib supported file formats
|
|
4
4
|
* @property {string} title The long form title of the format
|
|
5
5
|
* @property {string} titleShort Shorter title of the format
|
|
6
6
|
* @property {string} input Input format required by parser
|
package/modules/endnoteXml.js
CHANGED
|
@@ -264,9 +264,9 @@ export function writeStream(stream, options) {
|
|
|
264
264
|
|
|
265
265
|
|
|
266
266
|
/**
|
|
267
|
-
* Utility function to take the raw XML output object and translate it into a
|
|
267
|
+
* Utility function to take the raw XML output object and translate it into a Reflib object
|
|
268
268
|
* @param {Object} xRef Raw XML object to process
|
|
269
|
-
* @returns {Object} The translated
|
|
269
|
+
* @returns {Object} The translated Reflib object output
|
|
270
270
|
*/
|
|
271
271
|
export function translateRawToRef(xRef) {
|
|
272
272
|
let recOut = {
|
|
@@ -317,8 +317,8 @@ export function xmlUnescape(str) {
|
|
|
317
317
|
/**
|
|
318
318
|
* Lookup tables for this module
|
|
319
319
|
* @type {Object}
|
|
320
|
-
* @property {array<Object>} fields Field translations between
|
|
321
|
-
* @property {array<Object>} types Field translations between
|
|
320
|
+
* @property {array<Object>} fields Field translations between Reflib (`rl`) and the raw format (`raw`)
|
|
321
|
+
* @property {array<Object>} types Field translations between Reflib (`rl`) and the raw format types as raw text (`rawText`) and numeric ID (`rawId`)
|
|
322
322
|
*/
|
|
323
323
|
export let translations = {
|
|
324
324
|
// Field translations {{{
|
package/modules/json.js
CHANGED
|
@@ -15,7 +15,6 @@ export function readStream(stream) {
|
|
|
15
15
|
|
|
16
16
|
if (typeof stream.pipe === 'function') {
|
|
17
17
|
// On node.js
|
|
18
|
-
console.log('Parsing JSON with node.js library')
|
|
19
18
|
const nodeJSONStream = JSONStream.parse('*')
|
|
20
19
|
nodeJSONStream.on('data', ref => emitter.emit('ref', {
|
|
21
20
|
recNumber: recNumber++,
|
package/modules/medline.js
CHANGED
|
@@ -293,8 +293,8 @@ export function parseRef(refString, settings) {
|
|
|
293
293
|
/**
|
|
294
294
|
* Lookup tables for this module
|
|
295
295
|
* @type {Object}
|
|
296
|
-
* @property {array<Object>} fields Field translations between
|
|
297
|
-
* @property {array<Object>} types Field translations between
|
|
296
|
+
* @property {array<Object>} fields Field translations between Reflib (`rl`) and the raw format (`raw`)
|
|
297
|
+
* @property {array<Object>} types Field translations between Reflib (`rl`) and the raw format types as raw text (`rawText`) and numeric ID (`rawId`)
|
|
298
298
|
* @property {boolean} isArray Whether the field should append to any existing `rl` field and be treated like an array of data
|
|
299
299
|
* @property {number|boolean} [sort] Sort order when outputting, use boolean `false` to disable the field on output
|
|
300
300
|
* @property {boolean} [outputSkip=false] Dont output this field at all
|
package/modules/ris.js
CHANGED
|
@@ -178,8 +178,8 @@ export function parseRef(refString, settings) {
|
|
|
178
178
|
/**
|
|
179
179
|
* Lookup tables for this module
|
|
180
180
|
* @type {Object}
|
|
181
|
-
* @property {array<Object>} fields Field translations between
|
|
182
|
-
* @property {array<Object>} types Field translations between
|
|
181
|
+
* @property {array<Object>} fields Field translations between Reflib (`rl`) and the raw format (`raw`)
|
|
182
|
+
* @property {array<Object>} types Field translations between Reflib (`rl`) and the raw format types as raw text (`rawText`) and numeric ID (`rawId`)
|
|
183
183
|
* @property {boolean} isArray Whether the field should append to any existing `rl` field and be treated like an array of data
|
|
184
184
|
* @property {number|boolean} [sort] Sort order when outputting, use boolean `false` to disable the field on output
|
|
185
185
|
* @property {boolean} [outputRepeat=false] Whether to repeat the output field if multiple values are present, if disabled arrays are flattened into a string with newlines instead
|
|
@@ -6,8 +6,8 @@ export class WritableStream {
|
|
|
6
6
|
this.emitter = Emitter();
|
|
7
7
|
this.parser = new CacxParser({
|
|
8
8
|
collect: false,
|
|
9
|
+
reAttrSegment: /(?<key>[a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?<escape>["'])(?<val>.*?)\k<escape>)?/ig,
|
|
9
10
|
onTagOpen: (node) => {
|
|
10
|
-
console.log(node.tag, node.attrs);
|
|
11
11
|
const name = node.tag;
|
|
12
12
|
const attrs = node.attrs || {};
|
|
13
13
|
this.emitter.emit('opentag', name, attrs);
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iebh/reflib",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Reference / Citation reference library utilities",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"lint": "eslint
|
|
6
|
+
"lint": "eslint .",
|
|
7
7
|
"test": "mocha",
|
|
8
8
|
"test:browser": "cd test/browser && npm run dev"
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/IEBH/
|
|
12
|
+
"url": "https://github.com/IEBH/Reflib"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
15
15
|
"reflib",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
],
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"bugs": {
|
|
26
|
-
"url": "https://github.com/IEBH/
|
|
26
|
+
"url": "https://github.com/IEBH/Reflib/issues"
|
|
27
27
|
},
|
|
28
|
-
"homepage": "https://github.com/IEBH/
|
|
28
|
+
"homepage": "https://github.com/IEBH/Reflib",
|
|
29
29
|
"enginesStrict": true,
|
|
30
30
|
"engines": {
|
|
31
31
|
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
@@ -44,29 +44,18 @@
|
|
|
44
44
|
"JSONStream": "./modules/shims/JSONStream-browser.js"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@momsfriendlydevco/eslint-config": "^
|
|
48
|
-
"chai": "^
|
|
49
|
-
"eslint": "^
|
|
50
|
-
"mocha": "^10.
|
|
47
|
+
"@momsfriendlydevco/eslint-config": "^2.0.3",
|
|
48
|
+
"chai": "^5.1.1",
|
|
49
|
+
"eslint": "^9.9.0",
|
|
50
|
+
"mocha": "^10.7.3",
|
|
51
51
|
"mocha-logger": "^1.0.8",
|
|
52
52
|
"temp": "^0.9.4",
|
|
53
53
|
"vite-plugin-replace": "^0.1.1"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@iebh/cacx": "^1.0.
|
|
57
|
-
"htmlparser2": "^9.
|
|
56
|
+
"@iebh/cacx": "^1.0.2",
|
|
57
|
+
"htmlparser2": "^9.1.0",
|
|
58
58
|
"JSONStream": "^1.3.5",
|
|
59
59
|
"mitt": "^3.0.1"
|
|
60
|
-
},
|
|
61
|
-
"eslintConfig": {
|
|
62
|
-
"extends": "@momsfriendlydevco",
|
|
63
|
-
"env": {
|
|
64
|
-
"browser": true,
|
|
65
|
-
"es2021": true,
|
|
66
|
-
"mocha": true
|
|
67
|
-
},
|
|
68
|
-
"parserOptions": {
|
|
69
|
-
"ecmaVersion": "latest"
|
|
70
|
-
}
|
|
71
60
|
}
|
|
72
61
|
}
|
package/.vscode/launch.json
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "0.2.0",
|
|
3
|
-
"configurations": [
|
|
4
|
-
{
|
|
5
|
-
"type": "node",
|
|
6
|
-
"request": "launch",
|
|
7
|
-
"name": "Debug Vite Server",
|
|
8
|
-
"runtimeExecutable": "/home/connor/.nvm/versions/node/v20.12.2/bin/npm",
|
|
9
|
-
"runtimeArgs": ["run", "dev"],
|
|
10
|
-
"cwd": "${workspaceFolder}/test/browser",
|
|
11
|
-
"console": "integratedTerminal",
|
|
12
|
-
"env": {
|
|
13
|
-
"VITE_DEV_SERVER_URL": "http://localhost:3000"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"name": "Debug in Chrome",
|
|
18
|
-
"type": "chrome",
|
|
19
|
-
"request": "launch",
|
|
20
|
-
"url": "http://localhost:3000",
|
|
21
|
-
"webRoot": "${workspaceFolder}",
|
|
22
|
-
"sourceMaps": true,
|
|
23
|
-
"sourceMapPathOverrides": {
|
|
24
|
-
"/__vite-root/*": "${webRoot}/*",
|
|
25
|
-
"/@fs/*": "*",
|
|
26
|
-
"/@vite-root/*": "${webRoot}/*",
|
|
27
|
-
"/src/*": "${webRoot}/src/*",
|
|
28
|
-
"/modules/*": "${webRoot}/modules/*"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
],
|
|
32
|
-
"compounds": [
|
|
33
|
-
{
|
|
34
|
-
"name": "Debug Vite + Chrome",
|
|
35
|
-
"configurations": ["Debug Vite Server", "Debug in Chrome"]
|
|
36
|
-
}
|
|
37
|
-
]
|
|
38
|
-
}
|