-
Notifications
You must be signed in to change notification settings - Fork 66
/
bibtex-tidy.d.ts
333 lines (332 loc) · 8.94 KB
/
bibtex-tidy.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
/**
* bibtex-tidy v1.14.0
* https://github.com/FlamingTempura/bibtex-tidy
*
* DO NOT EDIT THIS FILE. This file is automatically generated
* using `npm run build`. Edit files in './src' then rebuild.
**/
export type BibTeXTidyOptions = {
/**
* Help
*
* Show help
*/
help?: boolean;
/**
* Enable planned v2 CLI changes
*
* Input files will no longer be modified by default. Instead, you will need to specify `--modify`/`-m` option to overwrite the file, or `--output`/`-o` to output to a different file.
*/
v2?: string;
/**
* Output path
*
* Write output to specified path. When omitted (and -m/--modify is not used), the result will be printed to stdout.
*/
outputPath?: string;
/**
* Modify input files
*
* Overwrite the original input files with the tidied result. This is enabled by default but will be disabled by default in v2. For v1, use --no-modify to output to stdout instead of overwriting the input files.
*/
modify?: boolean;
/**
* Remove fields
*
* Remove specified fields from bibliography entries.
*/
omit?: string[];
/**
* Enclose values in braces
*
* Enclose all property values in braces. Quoted values will be converted to braces. For example, "Journal of Tea" will become {Journal of Tea}.
*/
curly?: boolean;
/**
* Use numeric values where possible
*
* Strip quotes and braces from numeric/month values. For example, {1998} will become 1998.
*/
numeric?: boolean;
/**
* Abbreviate months
*
* Convert all months to three letter abbreviations (jan, feb, etc).
*/
months?: boolean;
/**
* Indent with spaces
*
* Indent all fields with the specified number of spaces. Ignored if tab is set.
*/
space?: boolean | number;
/**
* Indent with tabs
*
* Indent all fields with a tab.
*/
tab?: boolean;
/**
* Align values
*
* Insert whitespace between fields and values so that values are visually aligned.
*/
align?: boolean | number;
/**
* Insert blank lines
*
* Insert an empty line between each entry.
*/
blankLines?: boolean;
/**
* Sort bibliography entries
*
* Sort entries by the specified field names (citation key is used if no fields are specified). For descending order, prefix the field with a dash (-).
* Multiple fields may be specified to sort everything by first field, then by the second field whenever the first field for entries are equal, etc.
* The following additional fields are also permitted: key (entry citation key), type (sorts by the type of entry, e.g. article), and special (ensures that @string, @preamble, @set, and @xdata entries are first).
*/
sort?: boolean | string[];
/**
* Check for duplicates
*
* Warn if duplicates are found, which are entries where DOI, abstract, or author and title are the same.
*/
duplicates?: boolean | ("doi" | "key" | "abstract" | "citation")[];
/**
* Merge duplicate entries
*
* Merge duplicates entries. Use the duplicates option to determine how duplicates are identified. There are different ways to merge:
* - first: only keep the original entry
* - last: only keep the last found duplicate
* - combine: keep original entry and merge in fields of duplicates if they do not already exist
* - overwrite: keep original entry and merge in fields of duplicates, overwriting existing fields if they exist
*/
merge?: boolean | "first" | "last" | "combine" | "overwrite";
/**
* Strip double-braced values
*
* Where an entire value is enclosed in double braces, remove the extra braces. For example, {{Journal of Tea}} will become {Journal of Tea}.
*/
stripEnclosingBraces?: boolean;
/**
* Drop all caps
*
* Where values are all caps, make them title case. For example, {JOURNAL OF TEA} will become {Journal of Tea}. Roman numerals will be left unchanged.
*/
dropAllCaps?: boolean;
/**
* Escape special characters
*
* Escape special characters, such as umlaut. This ensures correct typesetting with latex. Enabled by default.
*/
escape?: boolean;
/**
* Sort fields
*
* Sort the fields within entries.
* If no fields are specified fields will be sorted by: title, shorttitle, author, year, month, day, journal, booktitle, location, on, publisher, address, series, volume, number, pages, doi, isbn, issn, url, urldate, copyright, category, note, metadata
*/
sortFields?: boolean | string[];
/**
* Sort properties
*
* Alias of sort fields (legacy)
*/
sortProperties?: boolean | string[];
/**
* Remove comments
*
* Remove all comments from the bibtex source.
*/
stripComments?: boolean;
/**
* Trailing commas
*
* End the last key value pair in each entry with a comma.
*/
trailingCommas?: boolean;
/**
* Encode URLs
*
* Replace invalid URL characters with percent encoded values.
*/
encodeUrls?: boolean;
/**
* Tidy comments
*
* Remove whitespace surrounding comments.
*/
tidyComments?: boolean;
/**
* Remove empty fields
*
* Remove any fields that have empty values.
*/
removeEmptyFields?: boolean;
/**
* Remove duplicate fields
*
* Only allow one of each field in each entry. Enabled by default.
*/
removeDuplicateFields?: boolean;
/**
* Generate citation keys [Experimental]
*
* For all entries replace the key with a new key of the form <author><year><title>. A JabRef citation pattern can be provided. This is an experimental option that may change without warning.
*/
generateKeys?: boolean | string;
/**
* Maximum authors
*
* Truncate authors if above a given number into "and others".
*/
maxAuthors?: number;
/**
* Lowercase fields
*
* Lowercase field names and entry type. Enabled by default.
*/
lowercase?: boolean;
/**
* Enclose values in double braces
*
* Enclose the given fields in double braces, such that case is preserved during BibTeX compilation.
*/
enclosingBraces?: boolean | string[];
/**
* Remove braces
*
* Remove any curly braces within the value, unless they are part of a command.
*/
removeBraces?: boolean | string[];
/**
* Wrap values
*
* Wrap long values at the given column
*/
wrap?: boolean | number;
/**
* Version
*
* Show bibtex-tidy version.
*/
version?: boolean;
/**
* Quiet
*
* Suppress logs on stdout.
*/
quiet?: boolean;
/**
* Backup
*
* Make a backup <filename>.original. Enabled by default (unless --modify is explicitly provided or outputting to a different file/stdio). Deprecated but provided for backward compatibility.
*/
backup?: boolean;
};
export type Options = Omit<BibTeXTidyOptions, "help" | "version" | "quiet" | "backup">;
export type DuplicateRule = Exclude<BibTeXTidyOptions["duplicates"], boolean | undefined>[number];
declare class RootNode {
children: (TextNode | BlockNode)[];
type: "root";
constructor(children?: (TextNode | BlockNode)[]);
}
declare class TextNode {
parent: RootNode;
text: string;
type: "text";
constructor(parent: RootNode, text: string);
}
declare class BlockNode {
parent: RootNode;
type: "block";
command: string;
block?: CommentNode | PreambleNode | StringNode | EntryNode;
constructor(parent: RootNode);
}
declare class CommentNode {
parent: BlockNode;
raw: string;
braces: number;
parens: number;
type: "comment";
constructor(parent: BlockNode, raw: string, braces: number, parens: number);
}
declare class PreambleNode {
parent: BlockNode;
raw: string;
braces: number;
parens: number;
type: "preamble";
constructor(parent: BlockNode, raw: string, braces: number, parens: number);
}
declare class StringNode {
parent: BlockNode;
raw: string;
braces: number;
parens: number;
type: "string";
constructor(parent: BlockNode, raw: string, braces: number, parens: number);
}
declare class EntryNode {
parent: BlockNode;
wrapType: "{" | "(";
type: "entry";
key?: string;
keyEnded?: boolean;
fields: FieldNode[];
constructor(parent: BlockNode, wrapType: "{" | "(");
}
declare class FieldNode {
parent: EntryNode;
name: string;
type: "field";
/** Each value is concatenated */
value: ConcatNode;
constructor(parent: EntryNode, name?: string);
}
declare class ConcatNode {
parent: FieldNode;
type: "concat";
concat: (LiteralNode | BracedNode | QuotedNode)[];
canConsumeValue: boolean;
constructor(parent: FieldNode);
}
declare class LiteralNode {
parent: ConcatNode;
value: string;
type: "literal";
constructor(parent: ConcatNode, value: string);
}
declare class BracedNode {
parent: ConcatNode;
type: "braced";
value: string;
/** Used to count opening and closing braces */
depth: number;
constructor(parent: ConcatNode);
}
declare class QuotedNode {
parent: ConcatNode;
type: "quoted";
value: string;
/** Used to count opening and closing braces */
depth: number;
constructor(parent: ConcatNode);
}
export type Warning = ({
code: "MISSING_KEY";
} | {
code: "DUPLICATE_ENTRY";
rule: DuplicateRule;
}) & {
message: string;
};
export type BibTeXTidyResult = {
bibtex: string;
warnings: Warning[];
count: number;
};
export declare function tidy(input: string, options_?: Options): BibTeXTidyResult;
export declare function getEntries(ast: RootNode): EntryNode[];
export {};