@citestyle/bibtex 1.0.0 → 1.1.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/package.json +2 -2
- package/src/export.js +7 -0
- package/src/parse.js +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@citestyle/bibtex",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "BibTeX ↔ CSL-JSON parser and serializer",
|
|
5
5
|
"author": "Uniweb",
|
|
6
6
|
"homepage": "https://github.com/uniweb/csl/tree/main/packages/bibtex",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"README.md"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@citestyle/types": "1.0.
|
|
34
|
+
"@citestyle/types": "1.0.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"vitest": "^3.1.1"
|
package/src/export.js
CHANGED
|
@@ -111,6 +111,13 @@ export function exportBibtex(items) {
|
|
|
111
111
|
const key = generateKey(item)
|
|
112
112
|
const fields = []
|
|
113
113
|
|
|
114
|
+
// Preserve `$`-sigil fields verbatim (out-of-band metadata — e.g. `$uuid` for
|
|
115
|
+
// content-sync identity — not CSL). Emitted first so a pristine entry gains a
|
|
116
|
+
// stable leading field and a parse↔export cycle is idempotent.
|
|
117
|
+
for (const k of Object.keys(item)) {
|
|
118
|
+
if (k.startsWith('$') && item[k] != null) fields.push([k, wrapBraces(String(item[k]))])
|
|
119
|
+
}
|
|
120
|
+
|
|
114
121
|
// Names
|
|
115
122
|
if (item.author) {
|
|
116
123
|
const val = serializeNames(item.author)
|
package/src/parse.js
CHANGED
|
@@ -570,6 +570,14 @@ function convertToCSL(entry) {
|
|
|
570
570
|
if (/^https?:\/\//i.test(hp)) item.URL = hp
|
|
571
571
|
}
|
|
572
572
|
|
|
573
|
+
// Preserve `$`-sigil fields verbatim — out-of-band metadata (e.g. `$uuid` for
|
|
574
|
+
// content-sync identity), not CSL. Kept instead of dropped, and passed through
|
|
575
|
+
// untouched (no LaTeX conversion) so a sync round-trip carries identity in the
|
|
576
|
+
// file. The raw tokenizer already accepts `$`-prefixed field names.
|
|
577
|
+
for (const [name, value] of Object.entries(fields)) {
|
|
578
|
+
if (name.startsWith('$')) item[name] = value
|
|
579
|
+
}
|
|
580
|
+
|
|
573
581
|
return item
|
|
574
582
|
}
|
|
575
583
|
|