Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First stab at adding support for the BibTeX format #94

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

DmitrySharabin
Copy link
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/.

Copy link

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
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.

formats/README.md Outdated Show resolved Hide resolved
processUnknown: true,
};

static extensions = ["bib"];
Copy link
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
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


static parse (str, options) {
options = this.resolveOptions(options, "parse");
return new BibLatexParser(str, options).parse();
Copy link
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.

export default class BibTeX extends Format {
static defaultOptions = {
processUnexpected: true,
processUnknown: true,
Copy link
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