1 | const path = require("path");
|
2 | function styleCapabilities(txt) {
|
3 | var styleCap = {
|
4 | styleID: null,
|
5 | styleName: null,
|
6 | bibliography: false
|
7 | };
|
8 | var start = txt.indexOf("<id>");
|
9 | var end = txt.indexOf("</id>");
|
10 | if (start === -1 || end === -1) {
|
11 | throw new Error("File \"" + options.watch[0] + "\" does not contain a CSL style ID");
|
12 | }
|
13 | styleCap.styleID = txt.slice(start + 4, end);
|
14 | styleCap.styleName = path.basename(styleCap.styleID);
|
15 | start = txt.indexOf("<bibliography");
|
16 | end = txt.indexOf("</bibliography>");
|
17 | if (start > -1 && end > -1) {
|
18 | styleCap.bibliography = true;
|
19 | }
|
20 | var ibid = txt.indexOf("position=\"ibid");
|
21 | if (ibid === -1) {
|
22 | ibid = txt.indexOf("position=\'ibid");
|
23 | }
|
24 | if (ibid > -1) {
|
25 | styleCap.ibid = true;
|
26 | }
|
27 | var position = txt.indexOf("position=");
|
28 | if (position > -1) {
|
29 | styleCap.position = true;
|
30 | }
|
31 | var backref = txt.indexOf("first-reference-note-number");
|
32 | if (backref > -1) {
|
33 | styleCap.backref = true;
|
34 | }
|
35 | return styleCap;
|
36 | }
|
37 | module.exports = {
|
38 | styleCapabilities
|
39 | }
|