https://github.com/foliant-docs/foliantcontrib.imgcaptions
Preprocessor for Foliant for adding visible captions to images.
https://github.com/foliant-docs/foliantcontrib.imgcaptions
Last synced: 5 months ago
JSON representation
Preprocessor for Foliant for adding visible captions to images.
- Host: GitHub
- URL: https://github.com/foliant-docs/foliantcontrib.imgcaptions
- Owner: foliant-docs
- License: mit
- Created: 2018-10-11T12:14:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-10T06:53:49.000Z (about 2 years ago)
- Last Synced: 2025-09-28T00:22:56.675Z (9 months ago)
- Language: Python
- Size: 31.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pypi.org/project/foliantcontrib.imgcaptions/) [](https://github.com/foliant-docs/foliantcontrib.imgcaptions)
# 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
```bash
$ pip install foliantcontrib.imgcaptions
```
## Usage
To enable the preprocessor, add `imgcaptions` to `preprocessors` section in the project config:
```yaml
preprocessors:
- imgcaptions
```
The preprocessor supports the following options:
```yaml
- imgcaptions:
stylesheet_path: !path imgcaptions.css
template:
{caption}
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: `
{caption}
`.
`targets`
: Allowed targets for the preprocessor. If not specified (by default), the preprocessor applies to all targets.
Image definition example:
```markdown
(leading exclamation mark here)[My Picture](picture.png)
```
This Markdown source will be finally transformed into the HTML code:
```html

My Picture
```
(Note that ImgCaptions preprocessor does not convert Markdown syntax into HTML; it only inserts HTML tags like `
My Picture
` into Markdown code after the image definitions. Empty alternative text descriptions are ignored.)