Skip to content

Commit 1fe9808

Browse files
yarikopticclaude
andcommitted
Add Version field to extra for versioned entries
For versioned entries (e.g., dandi.000027/0.210831.2033), add "Version: {version}" to the extra field. This ensures the version appears in BibTeX exports, since BibTeX doesn't have a standard version field. Logic: - Versioned entries (has / or @ in ID): "Version: 0.210831.2033" - Latest entries (no / or @): "Current version: 0.210831.2033" This distinguishes between: - Specific version citation: dandi.000027@0.210831.2033 Extra: Version: 0.210831.2033 - Latest version citation: dandi.000027 Extra: Current version: 0.210831.2033 Both have versionNumber field set in Zotero, but the extra field text clarifies the intent for BibTeX users. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent cf68270 commit 1fe9808

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

‎sandbox/update-zotero-collection‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,20 @@ def bibtex_to_zotero_item(entry: Dict) -> Dict:
165165
citation_key = bibtex_id.replace("/", "@")
166166
item["extra"] += f"Citation Key: {citation_key}\n"
167167

168-
# For "latest" entries (no version in ID), extract version from DOI
169-
# e.g., ID=dandi.000027, DOI=10.48324/DANDI.000027/0.210831.2033
170-
if "/" not in bibtex_id and "@" not in bibtex_id and doi:
171-
# Extract version from DOI (last part after /)
168+
# Add version info to extra field for BibTeX export compatibility
169+
# (since BibTeX doesn't have a standard version field)
170+
if doi:
172171
doi_parts = doi.split("/")
173172
if len(doi_parts) >= 2:
174173
version = doi_parts[-1]
175-
# Add current version info to extra field
176-
item["extra"] += f"Current version: {version}\n"
174+
# Check if it looks like a version (not just a dandiset ID)
175+
if "." in version and len(version) > 6:
176+
# For "latest" entries (no version in ID), use "Current version:"
177+
if "/" not in bibtex_id and "@" not in bibtex_id:
178+
item["extra"] += f"Current version: {version}\n"
179+
else:
180+
# For versioned entries, use "Version:"
181+
item["extra"] += f"Version: {version}\n"
177182

178183
return item
179184

0 commit comments

Comments
 (0)