Skip to main content

Badges

Preprocessor for Foliant which helps to add badges to your documents. It uses Shields.io to generate badges.

Installation

$ pip install foliantcontrib.badges

Config

To enable the preprocessor, add badges to preprocessors section in the project config:

preprocessors:
    - badges

The preprocessor has a number of options:

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 <object> 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:

<badge>jira/issue/https/issues.apache.org/jira/kafka-2896.svg</badge>

All options from config may be overriden in tag parameters:

<badge style="social" as_object="false">jira/issue/https/issues.apache.org/jira/kafka-2896.svg</badge>

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:

preprocessors:
    - badges:
        vars:
            jira: https/issues.apache.org/jira

To reference a variable in a badge path use syntax ${variable}:

<badge>jira/issue/${jira}/kafka-2896.svg</badge>

Description of the issue goes here. But it's not the only one.

<badge>jira/issue/${jira}/KAFKA-7951.svg</badge>

Description of the second issue.

Metadata

Release files for foliantcontrib.badges 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for foliantcontrib.badges 1.0.4
File Size Uploaded
foliantcontrib.badges-1.0.4.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for foliantcontrib.badges 1.0.4
File Interpreter ABI Platform
foliantcontrib.badges-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 10.3 kB

Release files / foliantcontrib.badges-1.0.4.tar.gz

Download URL foliantcontrib.badges-1.0.4.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
96b0e408a5effe0291569b4cbc12625385a272a037ffbc13039464d505600751
BLAKE2b-256 checksum
How to use checksums
815c6cf120c60e85e11a1b7fa4d3b4c4218a10852397d8e590cf45a0887cb104
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / foliantcontrib.badges-1.0.4-py3-none-any.whl

Download URL foliantcontrib.badges-1.0.4-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
048eba635374879957d2ba24a6ceac356fff14178605fa3f5fec71adc5d91643
BLAKE2b-256 checksum
How to use checksums
493fd531cda8fc167175c79de7f348439d663da44923f33ed14fcd3855f98cc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page