Type journal article DOIs, and have them automagically converted into a beautiful bibliography.
[](https://travis-ci.org/bcaller/markdown_doi)
[](https://badge.fury.io/py/markdown_doi)
A Markdown extension that looks through your text for things like `doi:10.1234/j.banana.5678`,
looks up the metadata on the crossref API and outputs text according to your requirements
Add `'markdown_doi'` to your Markdown call and watch the magic unfold:
```python
>>> from markdown import Markdown
>>> markdown = Markdown(extensions=['markdown_doi']
>>> markdown.convert('doi:10.1016/j.applanim.2010.02.004')
```
outputs
```html
<p><span class="doi"><a href="http://dx.doi.org/10.1016/j.applanim.2010.02.004">Are cows more likely to lie down the longer they stand?</a> <span class="doi-year">(2010)</span></span></p>
```
You can enable the caching if for example you are using Pelican and constantly regenerating the same files
```python
>>> markdown = Markdown(extensions=['markdown_doi(cache_file=.doi_cache)']
```
The templating function takes the metadata Dict from the
message key of [the JSON API response](https://api.crossref.org/works/10.1016/j.applanim.2010.02.004)
and returns a `markdown.util.etree.ElementTree`. See the default `template_title_link_year` function.
```python
from markdown_doi import makeExtension as makeDoiExtension
def templater(metadata, doi_pattern):
el = markdown.util.etree.Element("span")
el.text = '%(given)s %(family)s' % metadata['author'][0]
return el
ext = makeDoiExtension(templater=templater)
md = markdown.Markdown(extensions=[ext])
html = md.convert('hello 10.1016/j.applanim.2010.02.004')
assert html == 'hello <p><span>Bert J. Tolkamp</span></p>'
```
## Options
| Option | Type | Default |Description |
|-----------|------|---------|------------|
| templater | (Dict, LinkPattern) -> etree.ElementTree | None | Function which renders the metadata as an element tree |
| cache_file | str | '' | File name that can store a cache of the DOIs looked up |
| cache | dict | None | Instead, you can pass a map from DOI to metadata dict as the cache rather than a file name |
## Installation
>From Github:
```
git clone https://github.com/bcaller/markdown_doi.git
pip install -e ./markdown_doi
```
>From Pypi:
```
pip install markdown_doi
```
Metadata
Release files for markdown-doi 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| markdown_doi-1.1.0.tar.gz | 17.0 kB | Without provenance | Details for markdown_doi-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| markdown_doi-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for markdown_doi-1.1.0-py3-none-any.whl |
Total release size: 23.8 kB
Release files / markdown_doi-1.1.0.tar.gz
| Download URL | markdown_doi-1.1.0.tar.gz |
|---|---|
| Size | 17.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
061d6b0f06c24855cb848599f839ce526572653b83b7f6a887d7f2f098b87997
|
|
BLAKE2b-256 checksum How to use checksums |
c7f3cec6537320e8184c66a956542c82bcf33480648523b2e0a846734fb8c2b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.8.1 pkginfo/1.4.1 requests/2.9.1 setuptools/20.7.0 requests-toolbelt/0.7.0 clint/0.5.1 CPython/2.7.12 Linux/4.4.6-3-surface
|
Release files / markdown_doi-1.1.0-py3-none-any.whl
| Download URL | markdown_doi-1.1.0-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef4ecc3e37d70ddd58b6d6fda6af1b57c756c0462ad058d163b66cfeebce3a3c
|
|
BLAKE2b-256 checksum How to use checksums |
631c490b7a79ecbfe6f9395abe4d74ac3f2722daba920e39cbc26afeac9d9267
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.8.1 pkginfo/1.4.1 requests/2.9.1 setuptools/20.7.0 requests-toolbelt/0.7.0 clint/0.5.1 CPython/2.7.12 Linux/4.4.6-3-surface
|
Security for markdown-doi 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.