Lightgallery markdown Extension
Markdown extension to wrap images in a lightbox.
Will only wrap images by adding "!" right after the opening "[" bracket of the image.

This will Output :
<p>
<div class="lightgallery">
<a href="../img/pic1.png" data-sub-html="Description">
<img alt="Description" src="../img/pic1.png" />
</a>
</div>
</p>
The extension is made to work with lightgallery.js a full featured JavaScript lightgallery/lightbox with no dependencies.
Extension inspired by : mardown-lightbox
To test the extension:
import markdown
from lightgallery import LightGalleryExtension
print(markdown.markdown('', extensions=[LightGalleryExtension()]))
Install
$ pip install lightgallery
How to make it works with Mkdocs
1. Create a theme folder will the following structure in your Mkdocs folder
theme/
|_ css/
|_ fonts/
|_ img/
|_ js/
2. Go to lightgallery.js GitHub or JSDELIVR to download the following files to the theme sub-folders as listed below
- dist/js/lightgallery.min.js -> theme/js/
- dist/css/lightgallery.min.css -> theme/css/
- dist/fonts/lg.* -> theme/fonts/
- dist/img/loading.gif -> theme/img/
3. Create a theme/main.hml file and add the following code to the file
{% extends "base.html" %}
{% block styles %}
{{ super() }}
<link rel="stylesheet" href="{{ base_url }}/css/lightgallery.min.css">
{% endblock styles %}
{% block libs %}
{{ super() }}
<script src="{{ base_url }}/js/lightgallery.min.js"></script>
{% endblock libs %}
{% block scripts %}
{{ super() }}
<script>
var elements = document.getElementsByClassName("lightgallery");
for(var i=0; i<elements.length; i++) {
lightGallery(elements[i]);
}
</script>
{% endblock scripts %}
4. Modify the mkdocs.yml file to add the following settings
# Documentation and theme
theme:
custom_dir: 'theme'
# Extensions
markdown_extensions:
- lightgallery
5. Change extension settings in mkdocs.yml
All settings of the extension are optional and can be omitted.
# Extensions
markdown_extensions:
- lightgallery:
show_description_in_lightgallery: true | false
show_description_as_inline_caption: true | false
custom_inline_caption_css_class: 'my-caption-class'
| Setting | Description | Default Value |
|---|---|---|
show_description_in_lightgallery |
Adds the description as caption in lightgallery dialog. | true |
show_description_as_inline_caption |
Adds the description as inline caption below the image. | false |
custom_inline_caption_css_class |
Custom CSS classes which are applied to the inline caption paragraph. Multiple classes are separated via space. | Empty |
License
MIT License
Metadata
Release files for lightgallery 0.5
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 |
|---|---|---|---|---|
| lightgallery-0.5.tar.gz | 3.6 kB | Without provenance | Details for lightgallery-0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lightgallery-0.5-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for lightgallery-0.5-py2.py3-none-any.whl |
Total release size: 7.9 kB
Release files / lightgallery-0.5.tar.gz
| Download URL | lightgallery-0.5.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3063ba855fc96fe6b9c978845052d3e837095a55277fe1982be5748f7cb4085c
|
|
BLAKE2b-256 checksum How to use checksums |
0918f7be28c54f7271dd81a6ef04ea17bc5192d6c4edb65b1d7ef21ac49b9380
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
|
Release files / lightgallery-0.5-py2.py3-none-any.whl
| Download URL | lightgallery-0.5-py2.py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
9f14d5986aff5c4e0ef17d85f85488b9f2295b904556c71f1db99e3378a6cbc6
|
|
BLAKE2b-256 checksum How to use checksums |
8036f44678cd1e876770db2ceb744a820c270d0cb03eed439d8390b8cc1788e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
|
Security for lightgallery 0.5
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.