Skip to main content

pelican-embed-svg

Pelican plugin for embedding SVG images/icons at generation time. The plugin currently supports FontAwesome 5 icons specified using <i> tags as well as arbitrary SVG image files.

Copyright (c) 2020 by Kevin Houlihan

License: MIT, see LICENSE for more details.

Installation

The plugin can be installed from PyPI:

pip install pelican-embed-svg

To enable the plugin, add it to the PLUGINS list in your pelicanconf.py

PLUGINS = [
    'pelican_embed_svg',
]

If you want to use FontAwesome icons then you will need to download that as well. It is recommended to install that to a directory named font-awesome in the root of your pelican site. However, if you want to use FontAwesome's css (for sizing, etc.), then those files will need to be included in your site's static content, and referenced appropriately in your templates.

Usage

SVG images to embed can be specified in three ways in your templates.

FontAwsome <i> tags

<i> tags with base FontAwesome classes (fas, fab etc.) and an additional class specifying the icon.

<i class="fas fa-heart"></i>

All the classes specified will be copied to the embedded <svg> element in the output.

Custom <i> tags

<i> tags with the class pi, and an additional class specifying the name of the icon.

<i class="pi my-heart"></i>

This will embed the first file named my-heart.svg that is found in your project output, or the svg icon path, if set (see the settings section below).

All the classes specified will be copied to the embedded <svg> element in the output.

<img> tags

<img> tags with src attributes that specify svg files.

<img src="http://localhost:8000/images/my-heart.svg">

The svg file in this case will be found by stripping out the SITEURL. As such, the file must be present in the project output.

Settings

FontAwesome path

By default, FontAwesome icons are looked for in a directory called font-awesome in the root of your pelican project. If you have FontAwesome installed somewhere else then you can specify the path by adding the PES_FONT_AWESOME_PATH setting to your pelicanconf.py.

SVG icon path

When specifying icons using <i> tags and the pi class, by default the output directory is searched for the first svg file that matches. However, it is not strictly necessary for the svg files to be included in the output, so if you have them stored somewhere else the path can be specified using the PES_SVG_ICON_PATH setting.

<img> embedding

If you don't want to process <img> tags then that can be turned off using the PES_EMBED_IMG_TAGS setting:

PES_EMBED_IMG_TAGS = False

Path fills

By default, the embedded svg paths have their fill attribute set to currentColor for <i> tags so that the image colours can be controlled using css color properties. If this is not desirable (such as if your svgs have their own colour information), this can be turned off using the PES_SET_ICON_FILL setting.

For <img> tags, the fill is not modified by default. If you want the fill to be set for these then you can enable it using the PES_SET_IMG_FILL setting.

Caveats

This plugin is at an early stage of development, and largely untested outside of my own personal use-case.

Release files for pelican-embed-svg 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pelican-embed-svg 0.0.3
File Size Uploaded
pelican-embed-svg-0.0.3.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pelican-embed-svg 0.0.3
File Interpreter ABI Platform
pelican_embed_svg-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 9.9 kB

Release files / pelican-embed-svg-0.0.3.tar.gz

Download URL pelican-embed-svg-0.0.3.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d5111afc403c37c72ad45797ab7550f6785e121ad78ba58fe6b574d4ac5035d5
BLAKE2b-256 checksum
How to use checksums
d28283d9d13c6abcf9c3c62ff011bfe4908da9b6502f046f46dd2a615bc7e91d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

Release files / pelican_embed_svg-0.0.3-py3-none-any.whl

Download URL pelican_embed_svg-0.0.3-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74408747f02a9ba50f66b5a57f2670131c4667852c22f76f7ec13730dddc6ac1
BLAKE2b-256 checksum
How to use checksums
7985ca50e5d7237b65e47ba99af1abd93ca54e04ef14c00df2bb4b91b9c047af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page