@retorquere/bibtex-parser 12.1.13 → 13.0.2
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 +14 -10
- package/dist/esm/crossref.d.ts.map +1 -0
- package/dist/esm/crossref.js.map +1 -1
- package/dist/esm/fields.d.ts.map +1 -0
- package/dist/esm/fields.js.map +1 -1
- package/dist/{types → esm}/index.d.ts +41 -12
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +27 -3
- package/dist/esm/index.js.map +3 -3
- package/dist/{types → esm}/jabref.d.ts +9 -21
- package/dist/esm/jabref.d.ts.map +1 -0
- package/dist/esm/jabref.js +2 -3
- package/dist/esm/jabref.js.map +3 -3
- package/dist/esm/merge.d.ts.map +1 -0
- package/dist/esm/merge.js.map +1 -1
- package/dist/esm/prepositions.d.ts.map +1 -0
- package/dist/esm/prepositions.js.map +1 -1
- package/dist/{types → esm}/sentence-case.d.ts +1 -0
- package/dist/esm/sentence-case.d.ts.map +1 -0
- package/dist/esm/sentence-case.js +126 -28
- package/dist/esm/sentence-case.js.map +3 -3
- package/dist/esm/tokenizer.d.ts.map +1 -0
- package/dist/esm/tokenizer.js.map +1 -1
- package/dist/esm/verbatim.d.ts +90 -0
- package/dist/esm/verbatim.d.ts.map +1 -0
- package/dist/esm/verbatim.js +10 -0
- package/dist/esm/verbatim.js.map +3 -3
- package/dist/esm/yield.d.ts.map +1 -0
- package/dist/esm/yield.js.map +1 -1
- package/dist/wasm/bibtex_parser.d.ts +12 -9
- package/dist/wasm/bibtex_parser.js +13 -23
- package/dist/wasm/bibtex_parser_bg.wasm +0 -0
- package/dist/wasm/bibtex_parser_bg.wasm.d.ts +2 -3
- package/dist/wasm/english.json +27 -0
- package/dist/wasm/index.d.ts +105 -29
- package/dist/wasm/index.js +54 -51
- package/dist/wasm/jabref.d.ts +9 -21
- package/dist/wasm/jabref.js +3 -3
- package/package.json +25 -26
- package/dist/cjs/crossref.js +0 -201
- package/dist/cjs/crossref.js.map +0 -7
- package/dist/cjs/fields.js +0 -7186
- package/dist/cjs/fields.js.map +0 -7
- package/dist/cjs/index.js +0 -1126
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/jabref.js +0 -135
- package/dist/cjs/jabref.js.map +0 -7
- package/dist/cjs/merge.js +0 -37
- package/dist/cjs/merge.js.map +0 -7
- package/dist/cjs/prepositions.js +0 -111
- package/dist/cjs/prepositions.js.map +0 -7
- package/dist/cjs/sentence-case.js +0 -98
- package/dist/cjs/sentence-case.js.map +0 -7
- package/dist/cjs/tokenizer.js +0 -194
- package/dist/cjs/tokenizer.js.map +0 -7
- package/dist/cjs/verbatim.js +0 -403
- package/dist/cjs/verbatim.js.map +0 -7
- package/dist/cjs/yield.js +0 -26
- package/dist/cjs/yield.js.map +0 -7
- package/dist/types/crossref.d.ts.map +0 -1
- package/dist/types/fields.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/jabref.d.ts.map +0 -1
- package/dist/types/merge.d.ts.map +0 -1
- package/dist/types/prepositions.d.ts.map +0 -1
- package/dist/types/sentence-case.d.ts.map +0 -1
- package/dist/types/tokenizer.d.ts.map +0 -1
- package/dist/types/verbatim.d.ts +0 -66
- package/dist/types/verbatim.d.ts.map +0 -1
- package/dist/types/yield.d.ts.map +0 -1
- /package/dist/{types → esm}/crossref.d.ts +0 -0
- /package/dist/{types → esm}/fields.d.ts +0 -0
- /package/dist/{types → esm}/merge.d.ts +0 -0
- /package/dist/{types → esm}/prepositions.d.ts +0 -0
- /package/dist/{types → esm}/tokenizer.d.ts +0 -0
- /package/dist/{types → esm}/yield.d.ts +0 -0
package/README.md
CHANGED
|
@@ -12,10 +12,10 @@ Documentation is available at [https://retorque.re/bibtex-parser/](https://retor
|
|
|
12
12
|
|
|
13
13
|
## Choosing a Parser
|
|
14
14
|
|
|
15
|
-
The
|
|
15
|
+
The Rust/WebAssembly implementation is the default export (ESM only, see below). The pure TypeScript implementation, which also needs no initialization, is available as an ESM-only `/js` subpath:
|
|
16
16
|
|
|
17
17
|
```js
|
|
18
|
-
import { parse } from '@retorquere/bibtex-parser'
|
|
18
|
+
import { parse } from '@retorquere/bibtex-parser/js'
|
|
19
19
|
|
|
20
20
|
const library = parse('@article{example, title={A title}}')
|
|
21
21
|
```
|
|
@@ -23,19 +23,19 @@ const library = parse('@article{example, title={A title}}')
|
|
|
23
23
|
For the scanner-level representation, use `parseVerbatim`. Its fields are strings and have not been normalized or interpreted as LaTeX:
|
|
24
24
|
|
|
25
25
|
```js
|
|
26
|
-
import { parseVerbatim } from '@retorquere/bibtex-parser'
|
|
26
|
+
import { parseVerbatim } from '@retorquere/bibtex-parser/js'
|
|
27
27
|
|
|
28
28
|
const library = parseVerbatim('@article{example, title={A title}}')
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
The generated API documentation covers the normalized TypeScript API,
|
|
31
|
+
The generated API documentation covers the normalized TypeScript API (`/js`), its `parseVerbatim` export, and the WASM exports available from the default entry point.
|
|
32
32
|
|
|
33
33
|
All parser results expose `preambles: string[]`, retaining multiple `@preamble` directives in source order. The normalized result property was previously named `preamble`; callers should use `preambles` instead.
|
|
34
34
|
|
|
35
|
-
The WebAssembly implementation is
|
|
35
|
+
The WebAssembly implementation is the ESM-only default entry point. Initialize it before calling the parser. In a browser, `init()` loads the binary relative to the module:
|
|
36
36
|
|
|
37
37
|
```js
|
|
38
|
-
import init, { parse } from '@retorquere/bibtex-parser
|
|
38
|
+
import init, { parse } from '@retorquere/bibtex-parser'
|
|
39
39
|
|
|
40
40
|
await init()
|
|
41
41
|
const library = parse('@article{example, title={A title}}')
|
|
@@ -45,9 +45,9 @@ In Node.js, load the exported binary explicitly:
|
|
|
45
45
|
|
|
46
46
|
```js
|
|
47
47
|
import { readFile } from 'node:fs/promises'
|
|
48
|
-
import init, { parse } from '@retorquere/bibtex-parser
|
|
48
|
+
import init, { parse } from '@retorquere/bibtex-parser'
|
|
49
49
|
|
|
50
|
-
const binary = new URL(import.meta.resolve('@retorquere/bibtex-parser/
|
|
50
|
+
const binary = new URL(import.meta.resolve('@retorquere/bibtex-parser/bibtex_parser_bg.wasm'))
|
|
51
51
|
await init({ module_or_path: await readFile(binary) })
|
|
52
52
|
const library = parse('@article{example, title={A title}}')
|
|
53
53
|
```
|
|
@@ -56,10 +56,10 @@ Both entry points include TypeScript declarations. Building the package from sou
|
|
|
56
56
|
|
|
57
57
|
### Zotero Plugins
|
|
58
58
|
|
|
59
|
-
Include the
|
|
59
|
+
Include the default JavaScript entry point in your plugin's build and package the WASM binary as a plugin resource. In the plugin's privileged Zotero context, initialize the parser during startup, before any parsing calls:
|
|
60
60
|
|
|
61
61
|
```js
|
|
62
|
-
import init, { parse } from '@retorquere/bibtex-parser
|
|
62
|
+
import init, { parse } from '@retorquere/bibtex-parser'
|
|
63
63
|
|
|
64
64
|
await init({ module_or_path: 'chrome://zotero-better-bibtex/content/resource/bibtex/bibtex_parser_bg.wasm' })
|
|
65
65
|
|
|
@@ -68,6 +68,10 @@ const library = parse('@article{example, title={A title}}')
|
|
|
68
68
|
|
|
69
69
|
Await initialization once during startup; subsequent `parse` or `parseAsync` calls reuse the initialized module.
|
|
70
70
|
|
|
71
|
+
## URL Commands
|
|
72
|
+
|
|
73
|
+
Both parsers accept `richURL`, a boolean that defaults to `true`. With `richURL: true`, `\href{http://example.org/{id}}{url}` renders as `<a href="http://example.org/{id}">url</a>` without case-protection spans. With `richURL: false`, it renders as `<span class="nocase">http://example.org/{id}</span>`, discarding the label and preserving the destination's casing regardless of the `caseProtection` setting. The option also applies to `\url`.
|
|
74
|
+
|
|
71
75
|
## Unknown TeX Commands
|
|
72
76
|
|
|
73
77
|
Both `parse` and `parseAsync` accept an `unsupported` option:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crossref.d.ts","sourceRoot":"","sources":["../../js/crossref.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAiLlE,CAAA"}
|
package/dist/esm/crossref.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../crossref.ts"],
|
|
3
|
+
"sources": ["../../js/crossref.ts"],
|
|
4
4
|
"sourcesContent": ["export const crossref: Record<string, Record<string, Record<string, string>>> = {\n '*': {\n '*': {},\n },\n article: {\n periodical: {\n journalsubtitle: 'subtitle',\n journaltitle: 'title',\n },\n },\n book: {\n mvbook: {\n mainsubtitle: 'subtitle',\n maintitle: 'title',\n maintitleaddon: 'titleaddon',\n },\n },\n bookinbook: {\n book: {\n bookauthor: 'author',\n booksubtitle: 'subtitle',\n booktitle: 'title',\n booktitleaddon: 'titleaddon',\n },\n mvbook: {\n bookauthor: 'author',\n mainsubtitle: 'subtitle',\n maintitle: 'title',\n maintitleaddon: 'titleaddon',\n },\n },\n collection: {\n mvcollection: {\n mainsubtitle: 'subtitle',\n maintitle: 'title',\n maintitleaddon: 'titleaddon',\n },\n mvreference: {\n mainsubtitle: 'subtitle',\n maintitle: 'title',\n maintitleaddon: 'titleaddon',\n },\n },\n inbook: {\n '*': {\n bookauthor: 'author',\n },\n book: {\n bookauthor: 'author',\n booksubtitle: 'subtitle',\n booktitle: 'title',\n booktitleaddon: 'titleaddon',\n },\n mvbook: {\n bookauthor: 'author',\n mainsubtitle: 'subtitle',\n maintitle: 'title',\n maintitleaddon: 'titleaddon',\n },\n },\n incollection: {\n collection: {\n booksubtitle: 'subtitle',\n booktitle: 'title',\n booktitleaddon: 'titleaddon',\n },\n mvcollection: {\n mainsubtitle: 'subtitle',\n maintitle: 'title',\n maintitleaddon: 'titleaddon',\n },\n mvreference: {\n mainsubtitle: 'subtitle',\n maintitle: 'title',\n maintitleaddon: 'titleaddon',\n },\n reference: {\n booksubtitle: 'subtitle',\n booktitle: 'title',\n booktitleaddon: 'titleaddon',\n },\n },\n inproceedings: {\n mvproceedings: {\n mainsubtitle: 'subtitle',\n maintitle: 'title',\n maintitleaddon: 'titleaddon',\n },\n proceedings: {\n booksubtitle: 'subtitle',\n booktitle: 'title',\n booktitleaddon: 'titleaddon',\n },\n },\n inreference: {\n collection: {\n booksubtitle: 'subtitle',\n booktitle: 'title',\n booktitleaddon: 'titleaddon',\n },\n mvcollection: {\n mainsubtitle: 'subtitle',\n maintitle: 'title',\n maintitleaddon: 'titleaddon',\n },\n mvreference: {\n mainsubtitle: 'subtitle',\n maintitle: 'title',\n maintitleaddon: 'titleaddon',\n },\n reference: {\n booksubtitle: 'subtitle',\n booktitle: 'title',\n booktitleaddon: 'titleaddon',\n },\n },\n proceedings: {\n mvproceedings: {\n mainsubtitle: 'subtitle',\n maintitle: 'title',\n maintitleaddon: 'titleaddon',\n },\n },\n reference: {\n mvcollection: {\n mainsubtitle: 'subtitle',\n maintitle: 'title',\n maintitleaddon: 'titleaddon',\n },\n mvreference: {\n mainsubtitle: 'subtitle',\n maintitle: 'title',\n maintitleaddon: 'titleaddon',\n },\n },\n suppbook: {\n book: {\n bookauthor: 'author',\n booksubtitle: 'subtitle',\n booktitle: 'title',\n booktitleaddon: 'titleaddon',\n },\n mvbook: {\n bookauthor: 'author',\n mainsubtitle: 'subtitle',\n maintitle: 'title',\n maintitleaddon: 'titleaddon',\n },\n },\n suppcollection: {\n collection: {\n booksubtitle: 'subtitle',\n booktitle: 'title',\n booktitleaddon: 'titleaddon',\n },\n mvcollection: {\n mainsubtitle: 'subtitle',\n maintitle: 'title',\n maintitleaddon: 'titleaddon',\n },\n mvreference: {\n mainsubtitle: 'subtitle',\n maintitle: 'title',\n maintitleaddon: 'titleaddon',\n },\n reference: {\n booksubtitle: 'subtitle',\n booktitle: 'title',\n booktitleaddon: 'titleaddon',\n },\n },\n suppperiodical: {\n periodical: {\n journalsubtitle: 'subtitle',\n journaltitle: 'title',\n },\n },\n} as const\n"],
|
|
5
5
|
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V,cAAc;AAAA,MACd,WAAW;AAAA,MACX,gBAAgB;AAAA,IAClB;AAAA,IACA,cAAc;AAAA,MACZ,cAAc;AAAA,MACd,WAAW;AAAA,MACX,gBAAgB;AAAA,IAClB;AAAA,IACA,aAAa;AAAA,MACX,cAAc;AAAA,MACd,WAAW;AAAA,MACX,gBAAgB;AAAA,IAClB;AAAA,IACA,WAAW;AAAA,MACT,cAAc;AAAA,MACd,WAAW;AAAA,MACX,gBAAgB;AAAA,IAClB;AAAA,EACF;AAAA,EACA,gBAAgB;AAAA,IACd,YAAY;AAAA,MACV,iBAAiB;AAAA,MACjB,cAAc;AAAA,IAChB;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../js/fields.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAq+NnC,CAAA;AAEV,eAAO,MAAM,UAAU,EAAE,MAAM,EAmBrB,CAAA"}
|