GithubHelp home page GithubHelp logo

stuebersystems / mkdocs-img2fig-plugin Goto Github PK

View Code? Open in Web Editor NEW
20.0 3.0 10.0 38 KB

A MkDocs plugin that converts markdown encoded images into <figure> elements.

Home Page: https://pypi.org/project/mkdocs-img2fig-plugin

License: MIT License

Python 100.00%
mkdocs-plugin

mkdocs-img2fig-plugin's Introduction

MkDocs Img2Fig Plugin

This MkDocs plugin converts markdown encoded images like

![An image caption](\assets\images\my-image.png)

into

<figure class="figure-image">
  <img src="\assets\images\my-image.png" alt="An image caption">
  <figcaption>An image caption</figcaption>
</figure>

Requirements

This package requires Python >=3.5 and MkDocs version 1.0 or higher.

Installation

Install the package with pip:

pip install mkdocs-img2fig-plugin

Enable the plugin in your mkdocs.yml:

plugins:
    - search
    - img2fig

Note: If you have no plugins entry in your config file yet, you'll likely also want to add the search plugin. MkDocs enables it by default if there is no plugins entry set, but now you have to enable it explicitly.

More information about plugins in the MkDocs documentation

mkdocs-img2fig-plugin's People

Contributors

fstueber avatar timvink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mkdocs-img2fig-plugin's Issues

Allow markdown inside of figcaptions

Great plugin! I notice that markdown is not processed inside of the figure caption.

Example:

![**Figure 1** Markdown here is not processed by the plugin.](/images/figure1.jpg)

Produces the output:

<figure class="figure-image">
<img src="/images/figure1.jpg" alt="**Figure 1** Markdown here is not processed by the plugin."
<figcaption>**Figure 1** Markdown here is not processed by the plugin.</figcaption>
</figure>

Would be great to be able to format the text inside of the caption.

Add option to ignore converting certain figures

I have a feature request.

I would like the option to specify that some images in my page should not be converted to figures.

For example:

[![Actions Status](https://github.com/timvink/mkdocs-print-site-plugin/workflows/pytest/badge.svg)](https://github.com/timvink/mkdocs-print-site-plugin/actions)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mkdocs-print-site-plugin)
![PyPI](https://img.shields.io/pypi/v/mkdocs-print-site-plugin)
![PyPI - Downloads](https://img.shields.io/pypi/dm/mkdocs-print-site-plugin)
[![codecov](https://codecov.io/gh/timvink/mkdocs-print-site-plugin/branch/master/graph/badge.svg)](https://codecov.io/gh/timvink/mkdocs-print-site-plugin)
![GitHub contributors](https://img.shields.io/github/contributors/timvink/mkdocs-print-site-plugin)
![PyPI - License](https://img.shields.io/pypi/l/mkdocs-print-site-plugin)

Should render as:

image

But renders as:

image

Proposal

I would suggest two updates:

  • If an image does not contain a caption (f.e. ![](<path>)), do not convert
  • If an image caption contains the words img2fig-ignore, remove the text from the caption and do not convert to figure

img2fig breaks relative links when use_directory_urls is set to True

With the following directory structure:

docs/
   - folder/page.md
   - sys.png
mkdocs.yml 

And use_directory_urls: true in mkdocs.yml, the images break when enabling this plugin.

The src path is not correct, f.e. changing:

<img alt="The github logo" src="../../github-octocat.png">

To

<figure class="figure-image">
  <img src="../github-octocat.png" alt="The github logo">
  <figcaption>The github logo</figcaption>
</figure>

For a reproducable example (try turning img2fig off and on):

git clone [email protected]:timvink/mkdocs-print-site-plugin.git
cd mkdocs-print-site-plugin
mkdocs serve -f tests/fixtures/projects/relative_images/mkdocs_img2fig.yml

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.