Skip to content

First stab at adding support for the BibTeX format#94

Open
DmitrySharabin wants to merge 5 commits into
mainfrom
bibtex-format
Open

First stab at adding support for the BibTeX format#94
DmitrySharabin wants to merge 5 commits into
mainfrom
bibtex-format

Conversation

@DmitrySharabin
Copy link
Copy Markdown
Member

Unfortunately, I couldn't make it work by importing BibLatexParser and BibLatexExporter from node_modules as we do with the TOML format, so I ended up using https://esm.sh/.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jul 23, 2024

Deploy Preview for madata ready!

Name Link
🔨 Latest commit 89cc7e8
🔍 Latest deploy log https://app.netlify.com/sites/madata/deploys/669f91c074df080008332778
😎 Deploy Preview https://deploy-preview-94--madata.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@DmitrySharabin DmitrySharabin requested a review from LeaVerou July 23, 2024 10:11
@LeaVerou
Copy link
Copy Markdown
Contributor

Unfortunately, I couldn't make it work by importing BibLatexParser and BibLatexExporter from node_modules as we do with the TOML format, so I ended up using https://esm.sh/.

That works as a proof of concept, but we cannot have a remote dependency like that.
They have a browser version, though it creates globals. Did you try that one?
Did you file an issue in their repo to support ESM in a way that works in browsers? That’s how we got the TOML library to work in browsers, it originally didn’t, I just filed an issue and the maintainer was responsive. You could also ask if they'd be willing to merge a PR, then perhaps we could submit one. IIRC they use TS & Rollup, so it's a matter of configuring their build process to output it.

Comment thread formats/README.md Outdated
Comment thread formats/bibtex/index.js
processUnknown: true,
};

static extensions = ["bib"];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s the most popular one, but pretty sure there are a few more extensions in use.

Copy link
Copy Markdown
Contributor

@LeaVerou LeaVerou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

Comment thread formats/bibtex/index.js

static parse (str, options) {
options = this.resolveOptions(options, "parse");
return new BibLatexParser(str, options).parse();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC this does not produce a useful format by itself, though it preserves duplicate keys which could be useful for some use cases like reference managers.
We should probably have some sort of option to get back an object of ids to metadata. And something to transform to CSL, though I'm not sure what that entails exactly. But since the functionality is there, we could provide an option.

Comment thread formats/bibtex/index.js
export default class BibTeX extends Format {
static defaultOptions = {
processUnexpected: true,
processUnknown: true,
Copy link
Copy Markdown
Contributor

@LeaVerou LeaVerou Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we’d want to expose these options wholesale. We may want to expose the functionality, but with a different API. I’d not expose for now — once you expose, you need to support that forever.

Remember ideally we should be able to swap out the parser/serializer for a different package and our end-users shouldn't have to change much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants