msprev / fzf-bibtex

a BibTeX source for fzf
BSD 3-Clause "New" or "Revised" License
129 stars 15 forks source link

bibtex-markdown to include doi url #28

Closed kiil closed 2 years ago

kiil commented 2 years ago

Is it possible to include to doi address as an url in the "pretty print" from bibtex-markdown?

msprev commented 2 years ago

sure, do you want to do sketch out a proposal on how it should look on this thread? It's fairly trivial to implement. Bear in mind that an entry might have both a url and and a doi field.

kiil commented 2 years ago

That's what I call a responsive reply. Thanks a lot!

I don't know for url fields, I guess they vary a lot, but doi fields tend to be of a fairly constant and fairly short length like this:

https://doi.org/10.1145/3458864.3467682

So currently bibtex-markdown prints this:

Dash, Pranab & Hu, Y. Charlie (2021) 'How Much Battery Does Dark Mode Save? An Accurate OLED Display Power Profiler for Modern Smartphones' in Proceedings of the 19th Annual International Conference on Mobile Systems Applications and Services, New York, NY, USA: Association for Computing Machinery, pp. 323--335

I think simply appending the doi url after a comma and a space would be the best way like this:

Dash, Pranab & Hu, Y. Charlie (2021) 'How Much Battery Does Dark Mode Save? An Accurate OLED Display Power Profiler for Modern Smartphones' in Proceedings of the 19th Annual International Conference on Mobile Systems Applications and Services, New York, NY, USA: Association for Computing Machinery, pp. 323--335, https://doi.org/10.1145/3458864.3467682

pandoc could then convert the doi to a html link if necessary.

(I see that github actually converts the field to a link here automatically also, eventhough it is just pasted as text)

EDIT: In fact, I think most "markdowns" will take a raw url and turn it into a link, so just appending the doi field without any further markdown formatting should suffice

So, without the markdown formatting and linking github does:

Dash, Pranab & Hu, Y. Charlie (2021) 'How Much Battery Does Dark Mode Save? An Accurate OLED Display Power Profiler for Modern Smartphones' in *Proceedings of the 19th Annual International Conference on Mobile Systems Applications and Services*, New York, NY, USA: Association for Computing Machinery, pp. 323--335, https://doi.org/10.1145/3458864.3467682
msprev commented 2 years ago

Great, I've implemented it now if you want to pull the latest version. Remember to refresh your caches. Please let me know if you have any issues with it.

kiil commented 2 years ago

Thank you very much.

I've tried to make a new bibtex-markdown binary, but as far as I can see https://github.com/msprev/fzf-bibtex/tree/master/cmd/bibtex-markdown/main.go is unchanged, so I simply do not know how to build the new bibtex-markdown with the added doi functionality.

I realize that cmd/bibtex-markdown/main.go references github.com/msprev/fzf-bibtex/format so why the new functionality does not seem to go into the new build, I cannot understand.

If you can give me a hint, it would be much appreciated, but I do understand that it is outside the scope of the fzf-bibtex project, so no problem if you cannot.

msprev commented 2 years ago

the easiest thing is reinstall from the latest version on github. Just run:

go install github.com/msprev/fzf-bibtex/cmd/bibtex-ls@latest
go install github.com/msprev/fzf-bibtex/cmd/bibtex-markdown@latest
go install github.com/msprev/fzf-bibtex/cmd/bibtex-cite@latest

Let me know if that doesn't work (and don't forget to force a cache refresh by touching your .bib files!).

kiil commented 2 years ago

Thanks a lot again. Much appreciated!

It works now in vim :) (but not from the command line. But now I know that the binary is updated to the new version, and I'll debug the command line problem.)

Again, thanks a lot for taking the time.

And very interesting subjects you are dealing with in your academic career :)

msprev commented 2 years ago

Great, and thank you very much!!