citar icon indicating copy to clipboard operation
citar copied to clipboard

Make bib parser configurable

Open bdarcus opened this issue 3 years ago • 4 comments

Implement #680.

This should be enough to enable #397?

Please review and comment.

Regardless, I'll probably merge this later this weekend (so August 4).


On the org-bibtex parser, etc

I don't think I have time to do the org-bibtex parser and updatep functions. Would be great if someone can test this with that.

The first should look something like the below, and return a hash-table exactly like parsebib-parse does:

(cl-defun citar-cache--org-bibtex-parser (files &optional &key entries fields)
  "Return a parsebib-compatible hash-table for a list of org-bibtex FILES."
  ;; FILES is a list of file paths, though in citar, will only be a single item list
  (map-into                                ; convert alist into hash-table
    (org-element-cache-map ...

EDIT - I tried to figure out how to add the parser to parsebib on this branch:

https://github.com/bdarcus/parsebib/tree/org-bibtex

But I ran into a UX and technical issue: to take advantage of org-element-cache-map, you can't use temp-buffers, and need to be in the org major-mode. So unlike the other formats, it would seem to be more sensible to open all listed org files. But that's a departure from how parsebib and citar work. And what happens if someone does something crazy like do file-per-reference using org?

This may suggest that parser is better off here, and we just clearly document the different workflows.

bdarcus avatar Aug 29 '22 18:08 bdarcus

@andras-simonyi - when you have time, can you review this simple PR?

bdarcus avatar Aug 30 '22 11:08 bdarcus

I am not sure how much this will help. The configuration it introduces is seems unlikely to be used outside of citar since a new parser is likely a lot of work. If the intention is to allow formats not supported by parsebib think a simpler way would be to essentially define an analog of parsebib-parse that does the calls to parsebib-parse-bib-buffer etc as parsebib-parse and includes the additional calls too. If a user really wants to support some format outside of citar, this function can be advised.

aikrahguzar avatar Sep 03 '22 09:09 aikrahguzar

That's a good point.

I went this way because I wasn't sure if we want the org-bibtex parser in the citar package, or in a separate package. I'm still not sure on that actually, largely because there are outstanding UX and performance issues to sort out there.

WDYT?

bdarcus avatar Sep 03 '22 11:09 bdarcus

I went this way because I wasn't sure if we want the org-bibtex parser in the citar package, or in a separate package. I'm still not sure on that actually, largely because there are outstanding UX and performance issues to sort out there.

WDYT?

So the problematic scenario is when the parser is in a separate package and we don't want to depend on it? I think the soft dependency can be handled via featurep check inside the citar version of parsebib-parse and in that case we can warn users that they need the package installed if we are called to parse an org-bibtex file.

aikrahguzar avatar Sep 03 '22 12:09 aikrahguzar

@aikrahguzar

So the problematic scenario is when the parser is in a separate package and we don't want to depend on it?

That's the immediate issue I was thinking of. But perhaps there could be others in the future?

bdarcus avatar Sep 26 '22 11:09 bdarcus