https://github.com/foliant-docs/foliantcontrib.badges
https://github.com/foliant-docs/foliantcontrib.badges
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/foliant-docs/foliantcontrib.badges
- Owner: foliant-docs
- License: mit
- Created: 2019-06-11T10:37:56.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-25T10:44:33.000Z (over 3 years ago)
- Last Synced: 2025-12-16T15:17:31.530Z (6 months ago)
- Language: Python
- Size: 11.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pypi.org/project/foliantcontrib.badges/) [](https://github.com/foliant-docs/foliantcontrib.badges)
# Badges
Preprocessor for Foliant which helps to add badges to your documents. It uses [Shields.io](https://shields.io) to generate badges.
# Installation
```bash
$ pip install foliantcontrib.badges
```
# Config
To enable the preprocessor, add `badges` to `preprocessors` section in the project config:
```yaml
preprocessors:
- badges
```
The preprocessor has a number of options:
```yaml
preprocessors:
- badges:
server: 'https://img.shields.io'
as_object: true
add_link: true
vars:
jira_path: localhost:3000/jira
package: foliant
# badge look parameters
style: flat-square
logo: jira
```
`server`
: Shields server URL, which hosts badges. default: `https://img.shields.io`
`as_object`
: If `true` — preprocessor inserts `svg` badges with HTML `` tag, instead of Markdown image tag. This is required for links and hints to work. default: `true`
`add_link`
: If `true` preprocessor tries to determine the link which should be added to badge (for example, link to jira issue page for jira issue badge). Only works with `as_object = true`. default: `true`
> Please note that right now only links for **pypi** and **jira-issue** badges are being added automatically. Please contribute or contact author for adding other services.
`vars`
: Dictionary with variables which will be replaced in badge urls. See **variables** section.
Also you may add parameters specified on the shields.io website which alter the badge view like: `label`, `logo`, `style` etc.
# Usage
Just add the `badge` tag and specify path to badge in the tag body:
```
jira/issue/https/issues.apache.org/jira/kafka-2896.svg
```
All options from config may be overriden in tag parameters:
```
jira/issue/https/issues.apache.org/jira/kafka-2896.svg
```
## Variables
You can use variables in your badges to replace parts which repeat often. For example, if we need to add many badges to our Jira tracker, we may put the protocol and host parameters into a variable like this:
```yaml
preprocessors:
- badges:
vars:
jira: https/issues.apache.org/jira
```
To reference a variable in a badge path use syntax `${variable}`:
```
jira/issue/${jira}/kafka-2896.svg
Description of the issue goes here. But it's not the only one.
jira/issue/${jira}/KAFKA-7951.svg
Description of the second issue.
```