Git Product home page Git Product logo

lightgallery-markdown's Introduction

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.

![!Description](/img/pic1.png)

This will Output :

<p>
  <div class="lightgallery">
    <a href="../img/pic1.png">
      <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('![!description](/img/pic1.png)', extensions=[LightGalleryExtension()]))

Install

$ cd lightgallery-markdown

$ python setup.py install

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

License

MIT License

lightgallery-markdown's People

Contributors

g-provost avatar mementum avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.