btmanip : Command-line BibTeX file manipulator

btmanip is a tool for managing and processing BibTeX files. Of course, there are several other tools which do similar things, bibdesk, jabref, zotero, etc., but it was easier for me to construct a tool myself which is optimized around the tasks I wanted to perform. The BibTeX parser is built upon bibtex-spirit by Sergiu Dotenco.

This documentation was developed with the use of doxygen , sphinx , and breathe .

Installation

The full source distribution can be obtained from github . btmanip requires that O2scl (see link ) has been installed (with HDF5 support enabled). You will also have to manually edit the makefile in the top directory so that the appropriate header files and libraries can be found. On OSX, you can use homebrew, so brew install --HEAD awsteiner/science/btmanip may work.

Basic Operation

Typical usage

Read a .bib file, look for duplicates, and overwrite:

btmanip -parse my.bib -dup -bib my.bib

Read a bib file and output in a format useful for an LaTeX NSF bio sketch (see btmanip::btmanip_class::nsf() )

btmanip -parse my.bib -nsf refs.txt

Get help on the parse command:

btmanip -h parse

List all of the commands:

btmanip --commands

Read a .bib file, in entry Smith75, set the month field to April, then output to a new file:

btmanip -parse my.bib -set-field Smith75 month Apr -bib out.bib

Read a .bib file, list all the keys which begin with the letter S, and get the entry which starts with Smith

btmanip -parse my.bib -list-keys S* -get-key Smith*

Read a .bib file, add a second .bib file, clean, sort, and save in a new file:

btmanip -parse one.bib -add two.bib -clean -sort -bib all.bib

Default commands

If an environment variable BTMANIP_DEFAULTS is present, then it is assumed that it contins a list of commands to be run each time btmanip is run.

Readline history

btmanip uses the environment variable HOME to put the readline history file .btmanip_hist. If this environment variable does not exist (or is empty), then the readline history is not stored or used.

Long Example

$ btmanip
This program comes with ABSOLUTELY NO WARRANTY; for details
type `warranty'.  This is free software, and you are welcome
to redistribute it under certain conditions; type `license'
for details.
------------------------------------------------------------
btmanip> run examples/example.scr
# ------------------------------------------------------------
# This file documents the use of the 'btmanip' command.
# Read a .bib file using 'parse'
# ------------------------------------------------------------
> parse examples/ex1.bib
Read 65 entries from file examples/ex1.bib
# ------------------------------------------------------------
# You can use 'search' to find entries in the .bib file,
# which removes all entries but the ones that match.
# ------------------------------------------------------------
> search and journal "Phys. Rev. Lett." author "*Teaney*"
1 record found.
# ------------------------------------------------------------
# Go back to the original file
# ------------------------------------------------------------
> parse examples/ex1.bib
Read 65 entries from file examples/ex1.bib
# ------------------------------------------------------------
# Use 'list-keys' to list all the keys in the current set 
# of entries
# ------------------------------------------------------------
> list-keys
0. Machleidt:2011zz       22. Molnar:2003ff         44. Shen:1998gq           
1. Alver:2010gr           23. Teaney:2003kp         45. Akmal:1998cf          
2. Epelbaum:2008ga        24. Greco:2003xt          46. Bass:1998ca           
3. Luzum:2008cw           25. Fries:2003vb          47. Kaplan:1998we         
4. Li:2008gp              26. Maris:2003vk          48. Kaplan:1998tg         
5. Romatschke:2007mq      27. Danielewicz:2002pu    49. Oset:1997it           
6. Wicks:2005gt           28. Hirano:2002ds         50. Maris:1997tm          
7. Andronic:2005yp        29. Bedaque:2002mn        51. Pudliner:1997ck       
8. Baran:2004ih           30. Teaney:2001av         52. Serot:1997xg          
9. Lin:2004en             31. Kharzeev:2001gp       53. Lalazissis:1996rd     
10. Steiner:2004fi        32. Pieper:2001mp         54. Prakash:1996xs        
11. Epelbaum:2004fk       33. Kharzeev:2000ph       55. Machleidt:1995km      
12. Gyulassy:2004zy       34. Teaney:2000cw         56. BraunMunzinger:1995bp 
13. Caurier:2004gf        35. BraunMunzinger:2000px 57. Kaiser:1995eg         
14. Fries:2003kq          36. Machleidt:2000ge      58. BraunMunzinger:1994xr 
15. Kolb:2003dz           37. Gyulassy:2000er       59. Wiringa:1994wb        
16. Rischke:2003mt        38. Roberts:2000aa        60. Stoks:1994wp          
17. Greco:2003mm          39. Gyulassy:2000fs       61. Gyulassy:1994ew       
18. Entem:2003ft          40. Hagino:1999xb         62. Moller:1993ed         
19. BraunMunzinger:2003zd 41. BraunMunzinger:1999qy 63. Gyulassy:1993hr       
20. Jido:2003cb           42. Drechsel:1998hk       64. Schnedermann:1993ws   
21. Gyulassy:2003mc       43. Rijken:1998yy         
# ------------------------------------------------------------
# 'get-key' returns the entry which matches a specified key
# ------------------------------------------------------------
> get-key Epelbaum:2008ga
@article{Epelbaum:2008ga,
  author =       {Epelbaum, Evgeny and Hammer, Hans-Werner and Meissner,
                        Ulf-G.},
  title =        {Modern Theory of Nuclear Forces},
  journal =      {Rev. Mod. Phys.},
  volume =       81,
  year =         2009,
  pages =        {1773-1825},
  doi =          {10.1103/RevModPhys.81.1773},
  eprint =       {0811.1338},
  archivePrefix ={arXiv},
  primaryClass = {nucl-th},
  reportNumber = {HISKP-TH-08-18, FZJ-IKP-TH-2008-20},
  SLACcitation = {%%CITATION = ARXIV:0811.1338;%%}
}
# ------------------------------------------------------------
# Sort by key
# ------------------------------------------------------------
> sort
# ------------------------------------------------------------
# Output to a file named 'output.bib'
# ------------------------------------------------------------
> bib output.bib
# ------------------------------------------------------------
# Shell commands are preceeded by a !
# ------------------------------------------------------------
> !head -n 10 output.bib
: Executing system command: head -n 10 output.bib
@article{Akmal:1998cf,
  author =       {Akmal, A. and Pandharipande, V. R. and Ravenhall, D. G.},
  title =        {The Equation of state of nucleon matter and neutron star
                        structure},
  journal =      {Phys. Rev.},
  volume =       {C58},
  year =         1998,
  pages =        {1804-1828},
  doi =          {10.1103/PhysRevC.58.1804},
  eprint =       {nucl-th/9804027},
: Done with system command (returned 0).
# ------------------------------------------------------------
# The 'add' command adds entries from a .bib file to the
# current set of entries, prompting if it finds possible
# duplicates.
# ------------------------------------------------------------
> add examples/ex2.bib
When adding entry:

@article{Li:2008gp,
  author =       {Li, Bao-An and Chen, Lie-Wen and Ko, Che Ming},
  title =        {Recent Progress and New Challenges in Isospin Physics
                        with Heavy-Ion Reactions},
  journal =      {Phys. Rept.},
  volume =       464,
  year =         2008,
  pages =        {113-281},
  doi =          {10.1016/j.physrep.2008.04.005},
  eprint =       {0804.3580},
  archivePrefix ={arXiv},
  primaryClass = {nucl-th},
  SLACcitation = {%%CITATION = ARXIV:0804.3580;%%}
}

1 duplicates in the current list were found:

@article{Li:2008gp,
  author =       {Li, Bao-An and Chen, Lie-Wen and Ko, Che Ming},
  title =        {Recent Progress and New Challenges in Isospin Physics
                        with Heavy-Ion Reactions},
  journal =      {Phys. Rept.},
  volume =       464,
  year =         2008,
  pages =        {113-281},
  doi =          {10.1016/j.physrep.2008.04.005},
  eprint =       {0804.3580},
  archivePrefix ={arXiv},
  primaryClass = {nucl-th},
  SLACcitation = {%%CITATION = ARXIV:0804.3580;%%}
}

Add entry anyway (y/n)? n
Ignoring Li:2008gp
When adding entry:

@article{Steiner05ia,
  author =       {Steiner, Andrew W. and Prakash, Madappa and Lattimer,
                        James M. and Ellis, Paul J.},
  title =        {Isospin asymmetry in nuclei and neutron stars},
  journal =      {Phys. Rept.},
  volume =       411,
  year =         2005,
  pages =        {325-375},
  doi =          {10.1016/j.physrep.2005.02.004},
  eprint =       {nucl-th/0410066},
  archivePrefix ={arXiv},
  primaryClass = {nucl-th},
  reportNumber = {LA-UR-04-6745},
  SLACcitation = {%%CITATION = NUCL-TH/0410066;%%}
}

1 duplicates in the current list were found:

@article{Steiner:2004fi,
  author =       {Steiner, Andrew W. and Prakash, Madappa and Lattimer,
                        James M. and Ellis, Paul J.},
  title =        {Isospin asymmetry in nuclei and neutron stars},
  journal =      {Phys. Rept.},
  volume =       411,
  year =         2005,
  pages =        {325-375},
  doi =          {10.1016/j.physrep.2005.02.004},
  eprint =       {nucl-th/0410066},
  archivePrefix ={arXiv},
  primaryClass = {nucl-th},
  reportNumber = {LA-UR-04-6745},
  SLACcitation = {%%CITATION = NUCL-TH/0410066;%%}
}

Add entry anyway (y/n)? n
Ignoring Steiner05ia
Read 2 entries from file "examples/ex2.bib". Now 65 total entries with 65 sortabntries.
# ------------------------------------------------------------
# List the keys for the current set of entries again
# ------------------------------------------------------------
> list-keys
0. Akmal:1998cf           22. Gyulassy:1994ew       44. Maris:2003vk          
1. Alver:2010gr           23. Gyulassy:2000er       45. Moller:1993ed         
2. Andronic:2005yp        24. Gyulassy:2000fs       46. Molnar:2003ff         
3. Baran:2004ih           25. Gyulassy:2003mc       47. Oset:1997it           
4. Bass:1998ca            26. Gyulassy:2004zy       48. Pieper:2001mp         
5. Bedaque:2002mn         27. Hagino:1999xb         49. Prakash:1996xs        
6. BraunMunzinger:1994xr  28. Hirano:2002ds         50. Pudliner:1997ck       
7. BraunMunzinger:1995bp  29. Jido:2003cb           51. Rijken:1998yy         
8. BraunMunzinger:1999qy  30. Kaiser:1995eg         52. Rischke:2003mt        
9. BraunMunzinger:2000px  31. Kaplan:1998tg         53. Roberts:2000aa        
10. BraunMunzinger:2003zd 32. Kaplan:1998we         54. Romatschke:2007mq     
11. Caurier:2004gf        33. Kharzeev:2000ph       55. Schnedermann:1993ws   
12. Danielewicz:2002pu    34. Kharzeev:2001gp       56. Serot:1997xg          
13. Drechsel:1998hk       35. Kolb:2003dz           57. Shen:1998gq           
14. Entem:2003ft          36. Lalazissis:1996rd     58. Steiner:2004fi        
15. Epelbaum:2004fk       37. Li:2008gp             59. Stoks:1994wp          
16. Epelbaum:2008ga       38. Lin:2004en            60. Teaney:2000cw         
17. Fries:2003kq          39. Luzum:2008cw          61. Teaney:2001av         
18. Fries:2003vb          40. Machleidt:1995km      62. Teaney:2003kp         
19. Greco:2003mm          41. Machleidt:2000ge      63. Wicks:2005gt          
20. Greco:2003xt          42. Machleidt:2011zz      64. Wiringa:1994wb        
21. Gyulassy:1993hr       43. Maris:1997tm          
# ------------------------------------------------------------
# Sometimes it's helpful to determine which entries in a
# .bib file are already present in a master .bib file.
# We first parse the file with additional entries:
# ------------------------------------------------------------
> parse examples/ex3.bib
Read 2 entries from file examples/ex3.bib
# ------------------------------------------------------------
# Then use 'sub' to subtract out all entries already present
# in the master .bib file
# ------------------------------------------------------------
> sub examples/ex1.bib
Read 65 entries from file examples/ex1.bib
Duplicate keys and duplicate tags: article Bedaque:2002mn
# ------------------------------------------------------------
# Now output in .bib format
# ------------------------------------------------------------
> bib
@article{Thorsett:1998uc,
  author =       {Thorsett, S. E. and Chakrabarty, Deepto},
  title =        {Neutron star mass measurements. 1. Radio pulsars},
  journal =      {Astrophys. J.},
  volume =       512,
  year =         1999,
  pages =        288,
  doi =          {10.1086/306742},
  eprint =       {astro-ph/9803260},
  archivePrefix ={arXiv},
  primaryClass = {astro-ph},
  SLACcitation = {%%CITATION = ASTRO-PH/9803260;%%}
}
# ------------------------------------------------------------
# Output in plain text format
# ------------------------------------------------------------
> text
tag: article
key: Thorsett:1998uc
author: Thorsett, S. E. and Chakrabarty, Deepto
author (reformat): S. E. Thorsett and Deepto Chakrabarty
title: {Neutron star mass measurements. 1. Radio pulsars}
journal: Astrophys. J.
volume: 512
year: 1999
pages: 288
doi: 10.1086/306742
eprint: astro-ph/9803260
archivePrefix: arXiv
primaryClass: astro-ph
SLACcitation: %%CITATION = ASTRO-PH/9803260;%%
# ------------------------------------------------------------
# There is a generic help command
# ------------------------------------------------------------
> help

List of commands:

add          Add a specified .bib file.                    
alias        Create a command alias.                       
bib          Output a .bib file.                           
clean        Clean.                                        
commands     List all available commands.                  
cv           Create output for a CV.                       
cvt          Create presentations output for a CV.         
dox          Output a doxygen file for O2scl.              
dup          Find duplicates between .bib files.           
exit         Exit (synonymous with 'quit').                
get          Get the value of a parameter.                 
get-key      Get entry by key.                             
hay          Create a simple HTML author-year list.        
help         Show help information.                        
keep-field   Remove a field from the remove list.          
license      Show license information.                     
list-keys    List entry keys.                              
nsf          Output LaTeX source for an NSF bio sketch.    
parse        Parse a specified .bib file.                  
prop         Output a proposal .bib file.                  
quit         Quit (synonymous with 'exit').                
read-jlist   Read a new journal list.                      
remove-field Add a field to the remove list.               
run          Run a file containing a list of commands.     
search       Search.                                       
set          Set the value of a parameter.                 
sort         Sort.                                         
sub          Subtract the current entries from a .bib file.
text         Output a text file.                           
warranty     Show warranty information. 

Classes

Class btmanip_class

class btmanip::btmanip_class

Main class for the command-line BibTeX manipulator.

Parameters for ‘set’ command

o2scl::cli::parameter_int p_verbose
o2scl::cli::parameter_bool p_recase_tag
o2scl::cli::parameter_bool p_reformat_journal
o2scl::cli::parameter_bool p_trans_latex_html
o2scl::cli::parameter_bool p_normalize_tags
o2scl::cli::parameter_bool p_lowercase_fields
o2scl::cli::parameter_bool p_check_required
o2scl::cli::parameter_bool p_natbib_jours
o2scl::cli::parameter_bool p_remove_vol_letters
o2scl::cli::parameter_bool p_autoformat_urls
o2scl::cli::parameter_bool p_add_empty_titles
o2scl::cli::parameter_bool p_remove_author_tildes
bib_file bf

A file of BibTeX entries.

bool jlist_read

If true, a journal list has been read.

virtual int read_jlist(std::vector<std::string> &sv, bool itive_com)

Read journal list file.

virtual int set_field(std::vector<std::string> &sv, bool itive_com)

Set the value of one field in one entry.

virtual int search(std::vector<std::string> &sv, bool itive_com)

Search among current entries.

virtual int remove(std::vector<std::string> &sv, bool itive_com)

Remove matching entries.

virtual int sub(std::vector<std::string> &sv, bool itive_com)

Subtract the current entries from a .bib file.

virtual int journal(std::vector<std::string> &sv, bool itive_com)

Return the journal aliases for a given journal.

virtual int hdf5(std::vector<std::string> &sv, bool itive_com)

Output an HDF5 file.

virtual int parse_hdf5(std::vector<std::string> &sv, bool itive_com)

Parse an HDF5 file.

virtual int sort(std::vector<std::string> &sv, bool itive_com)

Sort the bib file by key.

virtual int dup(std::vector<std::string> &sv, bool itive_com)

Find duplicates between two .bib files.

virtual int parse(std::vector<std::string> &sv, bool itive_com)

Parse a .bib file.

virtual int add(std::vector<std::string> &sv, bool itive_com)

Add a .bib file.

virtual int text(std::vector<std::string> &sv, bool itive_com)

Output the BibTeX data as plain text.

virtual int cv(std::vector<std::string> &sv, bool itive_com)

Output the BibTeX data as .tex for input in a CV.

virtual int cv_talks(std::vector<std::string> &sv, bool itive_com)

Output the BibTeX data as .tex for input in a CV.

virtual int nsf(std::vector<std::string> &sv, bool itive_com)

Output the BibTeX data as .tex for input in a NSF bio sketch.

This command uses the format:

\item \href{URL}{\emph{title}} \\
First Last, First2 Last2 year, jour, \textbf{volume}, pages.

The URL is set to plus the DOI field (if present) or plus the eprint field if no DOI field is present. The url field is ignored. If a field called title_latex is present, it is used instead of the title field.

virtual int reverse(std::vector<std::string> &sv, bool itive_com)

Reverse the order.

virtual int utk_review(std::vector<std::string> &sv, bool itive_com)

A tex format for UTK review.

virtual int plain(std::vector<std::string> &sv, bool itive_com)

Plain output of talks for DOE progress reports.

virtual int bib(std::vector<std::string> &sv, bool itive_com)

Output the BibTeX data as a new .bib file.

virtual int get_key(std::vector<std::string> &sv, bool itive_com)

Get one bibtex entry by it’s key.

virtual int auto_key(std::vector<std::string> &sv, bool itive_com)

Loop over all entries and change keys to a standard key if possible.

virtual int change_key(std::vector<std::string> &sv, bool itive_com)

Change the key of an entry.

virtual int list_keys(std::vector<std::string> &sv, bool itive_com)

List current keys or those matching a pattern.

virtual int proposal(std::vector<std::string> &sv, bool itive_com)

Output the BibTeX data as a new .bib file suitable for proposals.

virtual int remove_field(std::vector<std::string> &sv, bool itive_com)

Add a field to the remove list.

virtual int keep_field(std::vector<std::string> &sv, bool itive_com)

Remove a field from the remove list.

virtual int clean(std::vector<std::string> &sv, bool itive_com)

Clean the bibliography.

virtual int hay(std::vector<std::string> &sv, bool itive_com)

Output in a short HTML author-year format.

virtual int dox(std::vector<std::string> &sv, bool itive_com)

Output the BibTeX data as a new .bib file in a doxygen format for O2scl.

virtual int rst(std::vector<std::string> &sv, bool itive_com)

Output the BibTeX data as a file in reStructured Text format for Sphinx.

btmanip_class()

Create a btmanip_class object.

~btmanip_class()

Destroy a btmanip_class object.

virtual int run(int argc, char *argv[])

Main class interface.

Protected Attributes

o2scl::cli_readline *cl

Command-line interface.

Class bib_file

class btmanip::bib_file

Manipulate BibTeX files using bibtex-spirit.

Special character handling (default is <tt>sc_allow_all</tt>)

int spec_chars
const int sc_allow_all =0
const int sc_force_unicode =1
const int sc_force_html =2
const int sc_force_latex =3

Unnamed Group

int month_format

Short month names.

const int month_format_long =0
const int month_format_four =1
const int month_format_short =2
const int month_format_short_dot =3
const int month_format_num =4

Public Functions

bib_file()

Create a bib_file object.

std::string lower_string(std::string s)

Convert all characters in a string to lower case.

int read_journals(std::string fname = "")

Read a journal name list from file fname.

If verbose is greater than 0, then this function outputs the total number of journal lists read after reading the full list. If verbose is greater than 1, then every list of synonyms is output to the screen.

Note
If a list was read previously, that list is deleted before reading the new list.

void thin_whitespace(std::string &s)

Remove extra whitespace by parsing through a stringstream

This function ensures that each word is separated by one and only one space, removing all other whitespace.

std::string journal_simplify(std::string s)

Remove all whitespace and punctuation and convert to lower case.

int find_abbrev(std::string jour, std::string &abbrev)

Find the standard abbrevation for a journal with name jour.

If an abbreviation is found, then this function returns 0, otherwise this function return 1. If no journal list has been loaded, then this function calls the error handler.

int find_abbrevs(std::string jour, std::vector<std::string> &list)

Find all synonyms for a journal with name jour.

If the journal is found in the list, then this function fills list with all the synonyms and returns 0. If the journal is not found in the list, this function return 1. If no journal list has been loaded, then this function calls the error handler.

std::string first_page(std::string pages)

Given a pages field, return only the first page.

This function just looks for the first hyphen and returns all characters before it.

void search_keys(std::string pattern, std::vector<std::string> &list)

Search for a pattern, setting list equal to the set of keys which match.

void search_or(std::vector<std::string> &args)

Search for entries using ‘or’.

If the number of arguments to this function is zero or an odd number, then the error handler is called.

void remove_or(std::vector<std::string> &args)

Remove matching entries using ‘or’.

If the number of arguments to this function is zero or an odd number, then the error handler is called.

void search_and(std::vector<std::string> &args)

Search for entries using ‘and’.

If the number of arguments to this function is zero or an odd number, then the error handler is called.

void entry_check_required(bibtex::BibTeXEntry &bt)

Check entry for required fields.

bool entry_add_empty_title(bibtex::BibTeXEntry &bt)

If an ‘article’ or ‘inproceedings’ has no title, set the title equal to one space.

bool entry_autoformat_url(bibtex::BibTeXEntry &bt)

If DOI number is present, ensure URL matches.

This function returns true if any change has been made to the entry.

bool entry_remove_vol_letters(bibtex::BibTeXEntry &bt)

Remove volume letters and move to journal names for some journals.

void clean(bool prompt = true)

Clean the current BibTeX entries.

int set_field_value(bibtex::BibTeXEntry &bt, std::string field, std::string value)

In entry bt, set the value of field equal to value.

int set_field_value(std::string key, std::string field, std::string value)

In entry with key key, set the value of field equal to value.

void parse_bib(std::string fname)

Parse a BibTeX file and perform some extra reformatting.

void refresh_sort()

Refresh the sort object which contains a set of keys an indexes for the entries array.

void sort_bib()

Sort the bibliography by key.

Because the indexes for a sorted list are always maintained in sort, this is a \({\cal O}(N)\) operation.

Note
This will call the error handler if more than one entry has the same key

void reverse_bib()

Reverse the bibliography.

void bib_output_one(std::ostream &outs, bibtex::BibTeXEntry &bt)

Output one entry bt to stream outs in .bib format.

int possible_duplicate(bibtex::BibTeXEntry &bt, bibtex::BibTeXEntry &bt2)

Return a positive number if bt and bt2 are possible duplicates.

This function returns 1 if the tags and keys are identical (except for capitalization) and 2 if the tags are the same and the keys are different, but the volume pages, and journal are the same. This function returns zero otherwise.

void list_possible_duplicates(bibtex::BibTeXEntry &bt, std::vector<size_t> &list)

Create a list of possible duplicates of bt in the current set of BibTeX entries.

void text_output_one(std::ostream &outs, bibtex::BibTeXEntry &bt)

Output one entry bt to stream outs in plain text.

void add_bib(std::string fname)

Add entries in a specified BibTeX file to the current list, checking for duplicates and prompting if they’re found.

bool is_key_present(std::string key)

Get entry by key name.

bibtex::BibTeXEntry &get_entry_by_key(std::string key)

Get entry by key name.

void change_key(std::string key1, std::string key2)

Change an entry’s key.

size_t get_index_by_key(std::string key)

Get index of entry by key name.

std::string spec_char_to_latex(std::string s_in)

Reformat special characters to latex.

std::string spec_char_to_html(std::string s_in)

Reformat special characters to html.

std::string spec_char_to_uni(std::string s_in)

Reformat special characters to unicode.

std::string spec_char_auto(std::string s_in)

Reformat special characters based on spec_chars

std::string short_author(bibtex::BibTeXEntry &bt)

Return the last name of the first author, and “et al.” if there is more than one author.

std::string last_name_first_author(bibtex::BibTeXEntry &bt)

Return the last name of the first author.

void parse_author(std::string s_in, std::vector<std::string> &firstv, std::vector<std::string> &lastv, bool remove_braces = false)

Reformat author string into first and last names.

Note that by default this doesn’t automatically remove curly braces from the author’s last name. This option is put there because many BibTeX entries put braces around by default, even if they are not needed. Curly braces are, however, sometimes required if the actual “author” of the entry is not a person but an organization with the word “and” in the name of the organization. The best plan for curly braces is probably just to leave them as is in the bibtex entries, and naively remove them for text-based formats and phase out this ‘remove_braces’ option (since it only works for authors and we need something that works for titles also).

std::string author_firstlast(std::string s_in, bool remove_braces = true, bool first_initial = true)

Reformat author string into a list with commas and the word "and" before the last author.

bool is_field_present(bibtex::BibTeXEntry &bt, std::string field)

Return true if field named field (ignoring differences in field name capitalization) is present in entry bt.

bool is_field_present(bibtex::BibTeXEntry &bt, std::string field1, std::string field2)

Return true if field named field1 or field named field2 is present in entry bt.

std::string &get_field(bibtex::BibTeXEntry &bt, std::string field)

Get field named field from entry bt.

std::vector<std::string> &get_field_list(bibtex::BibTeXEntry &bt, std::string field)

Get field named field from entry bt.

void tilde_to_space(std::string &s)

Convert tildes to spaces.

void output_html(std::ostream &os, bibtex::BibTeXEntry &bt)

Output an entry in HTML format.

void output_latex(std::ostream &os, bibtex::BibTeXEntry &bt)

Output an entry in LaTeX format.

void add_entry(bibtex::BibTeXEntry &bt)

Add an entry to the list.

Public Members

std::map<std::string, std::vector<std::string>, std::greater<std::string>> journals

List of journal synonyms.

std::vector<std::string> remove_fields

Fields automatically removed by parse()

std::vector<bibtex::BibTeXEntry> entries

The full list of BibTeX entries.

std::map<std::string, size_t, std::less<std::string>> sort

A sorted list of keys and indexes.

bool remove_extra_whitespace

Remove extra whitespace inside entries (default false)

bool recase_tag

Recase tag so that only the first letter is upper case.

bool reformat_journal

Reformat journal name from, e.g. to Phys. Rev. Lett.

bool trans_latex_html

Translate LaTeX symbols to HTML and vice versa.

bool normalize_tags

If true, convert tag strings to standard capitalization.

bool lowercase_fields

If true, convert fields to lowercase.

bool check_required

If true, check to make sure all required fields are present.

Note
This only works if normalize_tags and lowercase_fields are both true.

bool natbib_jours

If true, prefer natbib journal abbreviations (default false)

bool remove_vol_letters

If true, move letters from volumes for some journals (default false)

bool autoformat_urls

If true, add and reformat URLs (default true)

bool add_empty_titles

Add empty titles (default true)

bool remove_author_tildes

If true, remove LaTeX tildes from author names (default true)

int verbose

Verbosity parameter.

std::vector<std::string> months_long

Month names.

std::vector<std::string> months_short

Short month names.

std::vector<std::string> months_four

Short month names.

Protected Types

typedef std::map<std::string, std::vector<std::string>, std::greater<std::string>>::iterator journal_it

Type for journal name list iterator.

Protected Attributes

std::vector<std::string> trans_latex

LaTeX strings for translation.

std::vector<std::string> trans_latex_alt

LaTeX strings for translation.

std::vector<std::string> trans_html

HTML strings for translation.

std::vector<std::string> trans_uni

Unicode strings for translation.

Todo List

Todo

Better documentation.

Todo

A mechanism for removing curly braces and other ‘extra’ characters from author and title entries for text mode. (How do we distinguish necessary from unnecessary curly braces?) See discussion in parse_author() docs.

Todo

Move code from bib_file.h to a new source file bib_file.cpp

Todo

In clean, remove tildes from author lists, and rework loop to operate one entry at a time.

Todo

Use the bibtex-spirit writer?

Todo

Unicode support?

Todo

The code seems to crash if there are errant backslashes in the journal name. Fix this.

Indices and tables