msprev / fzf-bibtex

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

BibTeX entries other than articles and books ignored? #13

Closed ashwinvis closed 5 years ago

ashwinvis commented 5 years ago
/tmp  ❯❯❯ cat>ref.bib<<EOF
then> @article{smith_finite-size_1994,
  author = {Smith, Leslie M. and Yakhot, Victor},
  date = {1994-09},
  doi = {10.1017/S0022112094002065},
  issn = {1469-7645, 0022-1120},
  journaltitle = {J. Fluid Mech.},
  langid = {english},
  pages = {115-138},
  title = {Finite-Size Effects in Forced Two-Dimensional Turbulence},
  volume = {274}
}

@online{smith_notes_2018,
  author = {Smith, Nathaniel J.},
  date = {2018},
  title = {Notes on Structured Concurrency, or: {{Go}} Statement Considered Harmful \textemdash{} Njs Blog},
  url = {https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/}
}

@software{smith_trio_2017,
  author = {Smith, Nathaniel J.},
  date = {2017},
  title = {Trio: A Friendly {{Python}} Library for Async Concurrency and {{I}}/{{O}}},
  url = {https://trio.readthedocs.io/en/latest/index.html}
}
then> EOF
/tmp  ❯❯❯ bibtex-ls ref.bib
Smith, Leslie M. & Yakhot, Victor (1994) 'Finite-Size Effects in Forced Two-Dimensional Turbulence',  274, 115-138 [article] @smith_finite-size_1994
msprev commented 5 years ago

This is right. You can easily add formatters for other BibTeX types by adding extra clauses to the file format.go. You can see examples there and it’s fairly self explanatory how to do this. PRs welcome if you add formatters that would be useful for others.

msprev commented 5 years ago

NB. you may have to also modify the rsc string to ensure that whatever fields you are looking for are preserved when your file is parsed:

ashwinvis commented 5 years ago

No Go experience here, but I see what you mean. Why wasn't the text formatted by the "default" case?

https://github.com/msprev/fzf-bibtex/blob/master/format/format.go#L84-L98

msprev commented 5 years ago

Good point. It may be that bibtool ignores these as they are not standard BibTeX types. You can check if this has happened by running:

bibtool ref.bib -o parsed.bib

and check if they have been skipped in parsed.bib. If so, it is possible to change this behaviour by changing the rsc string to make sure bibtool doesn't ignore them (bibtool docs, pp. 24--25).

ashwinvis commented 5 years ago

OK, so this is not strictly a bibtex file, but uses biblatex. Bibtool can also parse it, but not by default (see bibtool docs pp. 14). Also I don't think the rsc string has to be changed, as author, date, title fields are already present.


/tmp  ❯❯❯ bibtool -r biblatex ref.bib

@Article{     smith_finite-size_1994,
  Author    = {Smith, Leslie M. and Yakhot, Victor},
  Date      = {1994-09},
  DOI       = {10.1017/S0022112094002065},
  ISSN      = {1469-7645, 0022-1120},
  JournalTitle  = {J. Fluid Mech.},
  langid    = {english},
  Pages     = {115-138},
  Title     = {Finite-Size Effects in Forced Two-Dimensional Turbulence},
  Volume    = {274}
}

@Online{      smith_notes_2018,
  Author    = {Smith, Nathaniel J.},
  Date      = {2018},
  Title     = {Notes on Structured Concurrency, or: {{Go}} Statement
          Considered Harmful \textemdash{} Njs Blog},
  URL       = {https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/}
}

@Software{    smith_trio_2017,
  Author    = {Smith, Nathaniel J.},
  Date      = {2017},
  Title     = {Trio: A Friendly {{Python}} Library for Async Concurrency
          and {{I}}/{{O}}},
  URL       = {https://trio.readthedocs.io/en/latest/index.html}
}
/tmp  ❯❯❯ bibtool -r biblatex thesis.bib
/tmp  ❯❯❯ bibtool ref.bib

@online{smith_notes_2018,
_^
*** BibTool ERROR:  (line 13 in ./ref.bib): Unknown entry type

*** BibTool WARNING: Skipping to next '@'

*** BibTool WARNING:  (line 20 in ./ref.bib): 254 non-space characters ignored.

@software{smith_trio_2017,
_^
*** BibTool ERROR:  (line 20 in ./ref.bib): Unknown entry type

*** BibTool WARNING: Skipping to next '@'

@Article{     smith_finite-size_1994,
  author    = {Smith, Leslie M. and Yakhot, Victor},
  date      = {1994-09},
  doi       = {10.1017/S0022112094002065},
  issn      = {1469-7645, 0022-1120},
  journaltitle  = {J. Fluid Mech.},
  langid    = {english},
  pages     = {115-138},
  title     = {Finite-Size Effects in Forced Two-Dimensional Turbulence},
  volume    = {274}
}```
msprev commented 5 years ago

You need to add a new type to the rsc string as described in the docs, page numbers I posted previously, for bibtool to parse it.

ashwinvis commented 5 years ago

14 should do it and a lot more. Thanks for all the help.