Transform Zotero BibTex files to LaTeX friendly representation.
Project description
zotero-bibtize
Refurbish exported Zotero-BibTex bibliographies into a more friendly representation.
In the current state exporting the contents of a Zotero database to Bibtex format most special characters are replaced by Zotero internal versions or escaped before written to the output file. This behavior is exceptionally annoying if entries contain code which is meant to be processed by (i.e. chemical or mathematical expressions and formulas in the title, etc.).
zotero-bibtize
can be used to post-process the generated Zotero output files
and remove added escape sequences (i.e. the output is an identical replica
of the raw entry contents stored in the Zotero interface)
Usage
After installing the package zotero-bibtize
can be invoked via a call to the
zotero-bibtize
command on the command line:
$ zotero-bibtize zotero_bibliography.bib bibtized_bibliography.bib
which will process the original contents zotero_bibliography.bib
and writes
the processed contents to the new bibtized_bibliography.bib
file.
Note that specifying a target file is optional and the input file will be
overwritten if left out.
Example
Original bibtex entry generated by Zotero export:
$ cat zotero_bibliography.bib
@article{LangCM2015,
title = {Lithium {Ion} {Conduction} in {\textbackslash}ce\{{LiTi}2({PO}4)3\} and {Related} {Compounds} {Based} on the \{{NASICON}\} {Structure}: {A} {First}-{Principles} {Study}},
volume = {27},
issn = {0897-4756, 1520-5002},
shorttitle = {Lithium {Ion} {Conduction} in {\textbackslash}ce\{{LiTi}2({PO}4)3\} and {Related} {Compounds} {Based} on the {NASICON} {Structure}},
url = {http://pubs.acs.org/doi/10.1021/acs.chemmater.5b01582},
doi = {10.1021/acs.chemmater.5b01582},
language = {en},
number = {14},
urldate = {2019-02-11},
journal = {Chem. Mater.},
author = {Lang, Britta and Ziebarth, Benedikt and Els{\textbackslash}"\{a\}sser, Christian},
month = jul,
year = {2015},
pages = {5040--5048}
}
After running zotero-bibtize zotero_bibliography.bib
:
$ cat zotero_bibliography.bib
@article{LangCM2015,
title = {Lithium Ion Conduction in \ce{LiTi2(PO4)3} and Related Compounds Based on the NASICON Structure: A First-Principles Study},
volume = {27},
issn = {0897-4756, 1520-5002},
shorttitle = {Lithium Ion Conduction in \ce{LiTi2(PO4)3} and Related Compounds Based on the NASICON Structure},
url = {http://pubs.acs.org/doi/10.1021/acs.chemmater.5b01582},
doi = {10.1021/acs.chemmater.5b01582},
language = {en},
number = {14},
urldate = {2019-02-11},
journal = {Chem. Mater.},
author = {Lang, Britta and Ziebarth, Benedikt and Els\"{a}sser, Christian},
month = jul,
year = {2015},
pages = {5040--5048}
}
Custom BibTex Keys (very experimental)
Custom BibTex keys can be defined through the optional --key-format
option
that will be written to the bibliography file instead of the default keys
generated by Zotero. The key format defines the way how to combine and format
contents taken from the BibTex entry fields to build a custom key format. In
general the format key is of the form
[field1:option][field2:option]...
where field
defines the BibTex entry field to take the contents from and the
options defines different format options that will be applied to the contents.
Currently the following fields are implemented:
author
Adds the author's lastnames to the key entry
General format: [author:num:options]
num
Defines the maximal number of author names used for the key
options
The format options that will be applied to the author names, i.e.
- capitalize: Capitalize the names
- upper: Transform names uppercase
- lower: Transform names to lowercase
- abbreviate: Only us the first letter instead of the full name
title
Adds contents of the title string to the key entry
General format: [title:num:options]
num
Defines the maximal number of words in the title used for the key (Note that function keys will not be taken into account)
options
The format options that will be applied to the title contents, i.e.
- capitalize: Capitalize the names
- upper: Transform names uppercase
- lower: Transform names to lowercase
- abbreviate: Only us the first letter instead of the full name
journal
Adds contents of the journal name to the key entry
General format: [journal:options]
options
The format options that will be applied to the journal name, i.e.
- capitalize: Capitalize the names
- upper: Transform names uppercase
- lower: Transform names to lowercase
- abbreviate: Only us the first letter instead of the full name
year
Add the publication year to the key entry
General format: [year:option]
option
Adding the year only allows to specify two types of options:
- short: Add the year to the key as 2-digit quantity
- long: Add the full year to the (i.e. as 4-digit quantitiy)
Example
In the following example we create a custom key containing the first
author name and the abbreviated journal name followed by the publication
year. The key format defining such a key is of the following form:
[author:1:capitalize][journal:capitalize:abbreviate][year]
The original entry generated by Zotero looks like this:
$ cat zotero_bibliography.bib
@article{lang_lithium_ion_conduction_2015,
title = {Lithium {Ion} {Conduction} in {\textbackslash}ce\{{LiTi}2({PO}4)3\} and {Related} {Compounds} {Based} on the \{{NASICON}\} {Structure}: {A} {First}-{Principles} {Study}},
volume = {27},
issn = {0897-4756, 1520-5002},
shorttitle = {Lithium {Ion} {Conduction} in {\textbackslash}ce\{{LiTi}2({PO}4)3\} and {Related} {Compounds} {Based} on the {NASICON} {Structure}},
url = {http://pubs.acs.org/doi/10.1021/acs.chemmater.5b01582},
doi = {10.1021/acs.chemmater.5b01582},
language = {en},
number = {14},
urldate = {2019-02-11},
journal = {Chem. Mater.},
author = {Lang, Britta and Ziebarth, Benedikt and Els{\textbackslash}"\{a\}sser, Christian},
month = jul,
year = {2015},
pages = {5040--5048}
}
After running zotero-bibtize zotero_bibliography.bib --key-format [author:1:capitalize][journal:capitalize:abbreviate][year]
the original contents will be processed by zotero-bibtize
and the original
Zotero key will be replaced with the modified version:
$ cat zotero_bibliography.bib
@article{LangCM2015,
title = {Lithium Ion Conduction in \ce{LiTi2(PO4)3} and Related Compounds Based on the NASICON Structure: A First-Principles Study},
volume = {27},
issn = {0897-4756, 1520-5002},
shorttitle = {Lithium Ion Conduction in \ce{LiTi2(PO4)3} and Related Compounds Based on the NASICON Structure},
url = {http://pubs.acs.org/doi/10.1021/acs.chemmater.5b01582},
doi = {10.1021/acs.chemmater.5b01582},
language = {en},
number = {14},
urldate = {2019-02-11},
journal = {Chem. Mater.},
author = {Lang, Britta and Ziebarth, Benedikt and Els\"{a}sser, Christian},
month = jul,
year = {2015},
pages = {5040--5048}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file zotero-bibtize-0.1.0.tar.gz
.
File metadata
- Download URL: zotero-bibtize-0.1.0.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191101 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b8dc2256645a403443ba292f5b1ad658842b0bc2db8311bccc1f78419b453d9 |
|
MD5 | 8c478133e5454d014d46d53ef589ee2e |
|
BLAKE2b-256 | 8a5b8b222a629e9dbab166bd0c826909d46bb3c1168b997fc54db44d36447ec4 |
File details
Details for the file zotero_bibtize-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: zotero_bibtize-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191101 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bd126809e08dcdde711833f07b1f4c4b3b48f0b3ea71d7e405ddad063a7cec6 |
|
MD5 | 2d5038d6e9154cdf6e9ff7af9465dab8 |
|
BLAKE2b-256 | e7537536ee2d39a136eb88555c28505add46fc9b2d35ce5fdb83e0bd98c58bf2 |