1 | Reflib
|
2 | ======
|
3 | Reference library processing for Node.
|
4 |
|
5 | This is a ported version of the original [Reflib for PHP](https://github.com/hash-bang/RefLib)
|
6 |
|
7 |
|
8 | API
|
9 | ===
|
10 |
|
11 | parse(content)
|
12 | --------------
|
13 | The main parser function. This will take a string or buffer to process and return an emitter which should call `ref` for each reference found.
|
14 |
|
15 | var reflib = require('reflib');
|
16 | reflib.parse('endnotexml', fs.readFileSync('./test/data/endnote.xml'))
|
17 | .on('error', function(err) {
|
18 | console.log('ERROR:', err);
|
19 | })
|
20 | .on('ref', function(ref) {
|
21 | console.log('FOUND A REFERENCE', ref);
|
22 | })
|
23 | .on('end', function() {
|
24 | console.log('All done');
|
25 | });
|
26 |
|
27 |
|
28 | output(options)
|
29 | ---------------
|
30 | Output a reference library.
|
31 |
|
32 | The options object must at least contain `stream` and `content` properties. Other options supported are:
|
33 |
|
34 | | Option | Type | Description |
|
35 | |------------------|------------------------|-------------------------------------------------------------------------------------------------|
|
36 | | stream | Stream.Writable stream | The stream object to output content into |
|
37 | | defaultType | String | Some libraries must have a reference type for each reference, if that is omitted use this value |
|
38 | | encode | Callback | Overridable callback to use on each reference output |
|
39 | | escape | Callback | Overridable callback to use when encoding text |
|
40 | | content | Array or Object or Callback | The reference library to output. If an array each item is used in turn, if an object a single item is output, if a callback this is called with the arguments (next, batchNo) until it returns null. The callback function can return a single object or an array |
|
41 |
|
42 |
|
43 | See the output tests of individual drivers for more examples.
|
44 |
|
45 |
|
46 | identify(path)
|
47 | --------------
|
48 | Function to return the supported driver from a file name.
|
49 |
|
50 | reflib.identify('./test/data/endnote.xml');
|
51 | // -> 'endnotexml'
|
52 |
|
53 |
|
54 | supported
|
55 | ---------
|
56 | A collection of all supported drivers.
|
57 |
|
58 | var reflib = require('reflib');
|
59 |
|
60 | console.log(reflib.supported)
|
61 | // e.g
|
62 | // {id: 'endnotexml', name: 'EndNote XML file', ext: ['.xml'], driver [object]}
|
63 |
|
64 |
|
65 | Reference format
|
66 | ================
|
67 | The following documents the individual reference format used by Reflib.
|
68 |
|
69 |
|
70 | Reference fields
|
71 | ----------------
|
72 | Each reference is made up of the following fields. Each field is optional and may or may not be supported by each Reflib driver.
|
73 |
|
74 | | Field | Type | Description |
|
75 | |-------------------|--------------------|--------------------------|
|
76 | | recNumber | Number | The sorting number of the reference |
|
77 | | type | String | A supported [reference type](#reference-types) |
|
78 | | title | String | The reference's main title |
|
79 | | titleSecondary | String | The reference's secondary title, this is usually the journal for most published papers |
|
80 | | authors | Array (of Strings) | An array of each Author in the originally specified format |
|
81 | | date | Date or String | Depending on how much information can be extracted this could either be a year (e.g. '2015'), a date (e.g. '12th Feb') or a full JS date (if [Moment](http://momentjs.com) understands its format) |
|
82 | | urls | Array (of Strings) | An array of each URL for the reference |
|
83 | | pages | String | The page reference, usually in the format `123-4` |
|
84 | | volume | String |
|
85 | | number | String |
|
86 | | isbn | String |
|
87 | | abstract | String |
|
88 | | label | String |
|
89 | | caption | String |
|
90 | | notes | String |
|
91 | | address | String |
|
92 | | researchNotes | String |
|
93 |
|
94 |
|
95 | Reference Types
|
96 | ---------------
|
97 | A reference type can be one of the following. Each is translated from and to its individual drivers own supported format (for example if using EndNoteXML 'dataset' is translated to 'Dataset.' with EndNote ID 59 automatically).
|
98 |
|
99 | aggregatedDatabase
|
100 | ancientText
|
101 | artwork
|
102 | audiovisualMaterial
|
103 | bill
|
104 | blog
|
105 | book
|
106 | bookSection
|
107 | case
|
108 | catalog
|
109 | chartOrTable
|
110 | classicalWork
|
111 | computerProgram
|
112 | conferencePaper
|
113 | conferenceProceedings
|
114 | dataset
|
115 | dictionary
|
116 | editedBook
|
117 | electronicArticle
|
118 | electronicBookSection
|
119 | encyclopedia
|
120 | equation
|
121 | figure
|
122 | filmOrBroadcast
|
123 | generic
|
124 | governmentDocument
|
125 | grant
|
126 | hearing
|
127 | journalArticle
|
128 | legalRuleOrRegulation
|
129 | magazineArticle
|
130 | manuscript
|
131 | map
|
132 | music
|
133 | newspaperArticle
|
134 | onlineDatabase
|
135 | onlineMultimedia
|
136 | pamphlet
|
137 | patent
|
138 | personalCommunication
|
139 | report
|
140 | serial
|
141 | standard
|
142 | statute
|
143 | thesis
|
144 | unpublished
|
145 | web
|