Skip to main content

A pandoc filter for globbing image paths in multi file projects.

Project description

pandoc-img-glob is a panflute pandoc filter.

In multi file and GitHub stored markdown projects, many images are specified relative to their documents. For example consider the following document tree:

example
|-- section1
|   |-- image1.png
|   `-- section1.md
|-- section2
|   |-- images
|   |   |-- image3.png
|   |   `-- image2.png
|   `-- section2.md
`-- Makefile

Assuming the Makefile would compile my full book, it might look like this:

book:
    pandoc -o book.pdf section*/*.md

And in section1.md there would be a line referencing image1.png, etc. This is often used because then the GitHub preview looks awesome! However, pandoc has no way of telling where files came from, so it loses track of image references, resulting in errors like this:

[pandoc warning] Could not find image `image1.png', skipping...
[pandoc warning] Could not find image `images/image2.png', skipping...
[pandoc warning] Could not find image `images/image3.png', skipping...

pandoc-img-glob solves this problem by just searching recursivly through the path find images matching the given filenames and providing pandoc (and pandoc only) with the absolute paths. This allows for both: Beautiful pdfs and GitHub previews using the updated Makefile.

fixedbook:
    pandoc --filter pandoc-img-glob -o book.pdf section*/*.md

However, this filter becomes slow if you have very deep and complex file trees, and if you have multiple images with the same name, it will just silently use the first it finds.

Installation

Just use pip to install it from pypi

pip install pandoc-img-glob

Project details


Download files

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

Source Distribution

pandoc-img-glob-0.1.3.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file pandoc-img-glob-0.1.3.tar.gz.

File metadata

File hashes

Hashes for pandoc-img-glob-0.1.3.tar.gz
Algorithm Hash digest
SHA256 40042dbd3a7497c7ba8adb65ff37e96178aa20a3076df6cec6af719f722cfdf7
MD5 d6ecbb510bdec874c49dd7b7c6af8db9
BLAKE2b-256 bca002bbb3a19b71325db4d6d0b7334d9c3ab3e6718c299370ce177c2283846d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page