Skip to main content

Preprocessor for Foliant for adding visible captions to images.

Project description

ImgCaptions

ImgCaptions is a preprocessor that generates visible captions for the images from alternative text descriptions of the images. The preprocessor is useful in projects built with MkDocs or another backend that provides HTML output.

Installation

$ pip install foliantcontrib.imgcaptions

Usage

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

preprocessors:
    - imgcaptions

The preprocessor supports the following options:

    - imgcaptions:
        stylesheet_path: !path imgcaptions.css
        template: <p class="image_caption">{caption}</p>
        targets:
            - pre
            - mkdocs
            - site
            - ghp

stylesheet_path : Path to the CSS stylesheet file. This stylesheet should define rules for the .image_caption class. Default path is imgcaptions.css. If stylesheet file does not exist, default built-in stylesheet will be used.

template : Template string representing the HTML tag of the caption to be placed after the image. The template should contain the {caption} variable that will be replaced with the image caption. Default: <p class="image_caption">{caption}</p>.

targets : Allowed targets for the preprocessor. If not specified (by default), the preprocessor applies to all targets.

Image definition example:

(leading exclamation mark here)[My Picture](picture.png)

This Markdown source will be finally transformed into the HTML code:

<p><img alt="My Picture" src="picture.png"></p>
<p class="image_caption">My Picture</p>

(Note that ImgCaptions preprocessor does not convert Markdown syntax into HTML; it only inserts HTML tags like <p class="image_caption">My Picture</p> into Markdown code after the image definitions. Empty alternative text descriptions are ignored.)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for foliantcontrib.imgcaptions, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size foliantcontrib.imgcaptions-1.0.2-py3-none-any.whl (4.2 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size foliantcontrib.imgcaptions-1.0.2.tar.gz (3.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page