A tool to convert BibLaTeX bbl files to plain LaTeX, markdown, or docx files.
pip install git+https://github.com/sbtseiji/bblconverter
bblconverter --infile [your bbl file or yaml bib file] --outfile [destination file path] --yaml [bib formatter yaml] --bibitem
-i INFILE, --infile INFILE- The file path of the input file. Either .bbl or .yml
-o OUTFILE, --outfile OUTFILE- Specifies the file to output. Either .tex, .md, or .docx. The extension of the output file name determines the target format. If no output file is specified, the resulting file has the same name as the input file and ends with .tex. If .yml or .yaml is specified, then the YAML bib file converted from .bbl will be exported.
-y YAML, --yaml YAML- File path of the bibliography formatter YAML.
-b, --bibitem- Toggle whether the bibliography should be in bibitem format when the output format is LaTeX. If this option is set, the bibliography items are output as bibitems. Otherwise they are output as simple LaTeX strings.
bblconverter uses a bibliography formatter created in YAML format to create a bibliography list from a bbl or yaml bibfile. The YAML file of the bibliography formatter contains sections for constants', names' and `driver'.
The constants section contains constants that are used when creating the bibliography list. For example, the maximum number of author names to display. Each constant is defined in the dictionary format as shown in the following example. No definition is required if there is no constant to use.
constants:
maxnames: 20
The names key contains a list of fields in BibLaTeX's names list, such as author, editor, and so on. The driver describes the format of each bibliography type, such as article, book.
The bibliography type in driver must have the same name as the bibliography type used by BibLaTeX. The format of each bibliography type is described as a list consisting of the elements "field name: field format".
The field name must be the same as the field name used in BibLaTeX.
In field format, the following commands can be used in list form to indicate how the field contents should be rendered.
value::FIELDNAME- Retrieves and displays the contents of the field.
text::"STRING"- Displays a string.
italic::true- Begin italic.
italic::false- End italic.
bold::true- Begin bold.
bold::false- End bold.
delim::DELIMITER- The delimiters that can be used are
COLON(:),SPACE( ),COMMA(,),PERIOD(.),DOT(.),DOTS(…),EMDASH(—),NDASH(–),LINEBREAK(\n). punct::"PUNCTUATION"- Symbols specified as punctuation marks are processed so that they do not overlap if the same symbol immediately precedes them. For example, if you specified
punct::"."immediately after thevalue::title, the title "my first paper" will appear as "my first paper." in the bibliography, and the title "my second paper." will also appear as "my second paper.", not "my second paper.."
The minimal YAML file sample will look something like this.
names:
- author
- editor
driver:
article:
- author:
- value::family
- text::", "
- value::giveni
- year: value::year
- title: value::title
- journaltitle: value::journaltitle
- volume: value::volume
- pages: value::pages
book:
- editor:
- value::family
- text::", "
- value::giveni
- year: value::year
- booktitle: value::booktitle
- publisher: value::publisher
As an example of a more complex formatter, attached to the yaml folder is the bibliography format for The Japanese Journal of Psychology.
YAML formatter can also perform basic conditional branching. Condition clauses are indicated by keys beginning with cond:: and are used in the following format:
- - cond::CONDITIONAL
- formats when conditional is true
- formats when conditional is false
The condition clauses available in Formatter are:
cond::ifequal[VALUE1,VALUE2]- Check if values 1 and 2 are the same.
cond::ifgreater[VALUE1,VALUE2]- Check if value 1 is greater than value 2.
cond::ifgreatereq[VALUE1,VALUE2]- Check if value 1 is greater than or equals to value 2.
cond::ifless[VALUE1,VALUE2]- Check if value 1 is smaller than value 2.
cond::iflesseq[VALUE1,VALUE2]- Check if value 1 is smaller than or equals to value 2.
cond::ifdef[field::FIELDNAME,true]- Check if field
FIELDNAMEis defined. cond::ifdef[field::FIELDNAME,false]- Check if field
FIELDNAMEis undefined.
You can also combine two conditional clauses using &&, ||, or ^^.
&&logical conjunction- (Example)
cond::ifgreater[listcount,2]&&ifless[listcount,5](listcount is greater than 2 and smaller than 5) ||logical disjunction- (Example)
cond::ifgreater[listcount,2]||ifless[listcount,5](listcount is greater than 2 or smaller than 5) ^^exclusive disjunction- (Example)
cond::ifgreater[listtotal,2]^^ifdef[field::title,false](either listtotal is greater than 2 or fieldtitleis not defined, not both.)
You can also use the variables listcount and listtotal in the condition clause. The variable listcount is the position of the author currently being processed, and listtotal is the total number of author names listed in the entry.