Metadata-Version: 2.1
Name: zensols.bibstract
Version: 0.0.5
Summary: This utility extracts Bib(La)Tex references (a.k.a *markers*) from a (La)Tex.
Home-page: https://github.com/plandes/bibstract
Author: Paul Landes
Author-email: landes@mailc.net
License: UNKNOWN
Download-URL: https://github.com/plandes/bibstract/releases/download/v0.0.5/zensols.bibstract-0.0.5-py3-none-any.whl
Keywords: tooling
Platform: UNKNOWN
Description-Content-Type: text/markdown

# BibTex Extract and Populate

[![Travis CI Build Status][travis-badge]][travis-link]
[![PyPI][pypi-badge]][pypi-link]
[![Python 3.9][python37-badge]][python37-link]

This utility extracts [BibTex] references (a.k.a *markers*) from a [(La)Tex]
file and copies entries from a source, which the *master BibTex file*.  The use
case is exporting all [BetterBibtex] entries to a file on your file system,
usually one that is updated as you add, remove and modify papers in [Zotero].

**Note**:  While the use case was intended for use with Zoter and BetterBibtex,
it will work on any BibTex file.

The program does the following:
1. Parses some large master source BibTex file.
1. Parses a file or recursively all `.tex`, `.sty`, and `.cls` files
   recursively in a directory.
1. Copies the matching entries from the master source BibTex to standard out.

The program makes the assumption that the BibTex entry IDs are unique as the
matches are very loose when parsing the (La)Tex file.


## Obtaining

The easiest way to install the command line program is via the `pip` installer:
```bash
pip3 install zensols.bibstract
```

Binaries are also available on [pypi].


## Usage

This is a command line program written that has the following usage (also use
`--help`):

* Print IDs in a master source file BibTex file: `bibstract showbib`.
* Print cite references in a (La)Tex file: `bibstract showtex <file|directory>`
* Print IDs that will be exported from the BibTex file: `bibstract showexport <file|directory>`
* Export the matching entries to standard out: `bibstract export <file|directory>`


## Converters

A set of *converters* can be specified in the [configuration file], which
modify each parsed BibTex entry in succession.  Currently there the following:
* **date_year**: Converts the year part of a date field to a year.  This is
  useful when using Zotero's Better Biblatex extension that produces BibLatex
  formats, but you need BibTex entries.
* **copy**: Copy or move one or more fields in the entry.  This is useful when
  your bibliography style expects one key, but the output (i.e.BibLatex)
  outputs a different named field). When `destructive` is set to ``True``, this
  copy operation becomes a move.

Converters can be set be set and configured in the [configuration file].


## Configuration

A [configuration file] must be given, whose location is either given with a
`-c` command line argument, or set in the environment variable `BIBSTRACTRC`.

An example [configuration file] is available, which has only one INI section
`default` with option `master_bib` with the master BibTex file.


### Example Configuration File

The following example configuration file points to the a home directory file
where you tell where [BetterBibtex] to export.  It then specifies to convert
dates with years (deleting the `date` field after)when creating the output.

In addition, it copies the `journaltitle` (exported by [BetterBibtex]) to
`journal`, which is used by BibTex.  This converter, called *replace* is
configured the `replace_converter` entry.

```ini
[default]
master_bib = ${env:home}/.zotero-betterbib.bib
converters = date_year_destructive, replace

[replace_converter]
class_name = zensols.bibstract.CopyOrMoveConverter
fields = dict: {'journaltitle': 'journal'}
destructive = False
```


## Changelog

An extensive changelog is available [here](CHANGELOG.md).


## License

Copyright (c) 2020 - 2021 Paul Landes

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


<!-- links -->
[travis-link]: https://travis-ci.org/plandes/bibstract
[travis-badge]: https://travis-ci.org/plandes/bibstract.svg?branch=master
[pypi]: https://pypi.org/project/zensols.bibstract/
[pypi-link]: https://pypi.python.org/pypi/zensols.bibstract
[pypi-badge]: https://img.shields.io/pypi/v/zensols.bibstract.svg
[python37-badge]: https://img.shields.io/badge/python-3.9-blue.svg
[python37-link]: https://www.python.org/downloads/release/python-370

[configuration file]: #example-configuration-file
[BetterBibtex]: https://github.com/retorquere/zotero-better-bibtex
[Zotero]: https://www.zotero.org
[BibTex]: http://www.bibtex.org
[(La)Tex]: http://www.bibtex.org


