Skip to main content

Donate via PayPal Build Coverage Status PyPI Version PyPI - Python Version License

MkDocs Material Extensions

Markdown extension resources for MkDocs for Material

Install

pip install mkdocs-material-extensions

Inline SVG Icons

MkDocs Material provides numerous icons from Material, FontAwesome, and Octicons, but it does so by inlining the SVG icons into the source. Currently there is no easy way access these icons and arbitrarily insert them into Markdown content. Users must include the icon fonts themselves and do it with HTML.

This module allows you to use PyMdown Extensions' Emoji extension to enable easy insertion of MkDocs Material's SVG assets using simple :emoji-syntax:. This is done by creating our own emoji index and emoji generator. The custom index provides a modified version of the Emoji extensions Twemoji index.

In addition to the custom index, you must also specify the associated custom generator. This will will find the appropriate icon and insert it into your Markdown content as an inlined SVG.

Example:

markdown_extensions:
  - pymdownx.emoji:
      emoji_index: !!python/name:materialx.emoji.twemoji
      emoji_generator: !!python/name:materialx.emoji.to_svg

Then, using the folder structure of Material's .icons folder, you can specify icons:

We can use Material Icons :material-airplane:.

We can also use Fontawesome Icons :fontawesome-solid-ambulance:.

That's not all, we can also use Octicons :octicons-octoface:.

Using Local Custom Icons

In MkDocs, you can override theme assets locally, and even add assets to the theme. Unfortunately, the Markdown parsing process isn't aware of the MkDocs environment. Luckily, if you are using PyMdown Extensions 7.1, you can pass in custom icon paths that will be used when constructing the emoji index and include your custom SVG assets. If a folder path of theme/my_icons was given to the index builder, all icons under my_project/my_icons, even in sub-folders, would become part of the index.

markdown_extensions:
  - pymdownx.emoji:
      emoji_index: !!python/name:materialx.emoji.twemoji
      emoji_generator: !!python/name:materialx.emoji.to_svg
      options:
        custom_icons:
          - theme/my_icons

If given an icon at my_project/my_icons/animals/bird.svg, the icon would be available using the emoji syntax as :animals-bird:. Notice that the base folder that is provided doesn't contribute to the icon's name. Also, folders are separated with -. Folder names and icon names should be compatible with the emoji syntax, so special characters should be avoided -- - and _ are okay.

You can provide as many paths as you would like, and they will be evaluated in the order that they are specified. The Material theme's own icons will be evaluated after all custom paths. This allows a user to override Material's icons if desired.

If an icon name is already in the index, the icon will not be added. It is recommended to always have your icons in sub-folders to help namespace them to avoid name collisions. In the example above, bird was under animals which created the name :animals-bird: and helped create a more unique name with less of a chance of creating a duplicate name with existing emoji and Material icons.

Metadata

Release files for mkdocs-material-extensions 1.0

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

Source distribution (sdist)

Source distribution for mkdocs-material-extensions 1.0
File Size Uploaded
mkdocs-material-extensions-1.0.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs-material-extensions 1.0
File Interpreter ABI Platform
mkdocs_material_extensions-1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.1 kB

Release files / mkdocs-material-extensions-1.0.tar.gz

Download URL mkdocs-material-extensions-1.0.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
17d7491e189af75700310b7ec33c6c48a22060b8b445001deca040cb60471cde
BLAKE2b-256 checksum
How to use checksums
37969c7825ac728f89de143741bb6db8750726e590b1f1a85cab9050871c9311
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.46.0 CPython/3.7.7

Release files / mkdocs_material_extensions-1.0-py3-none-any.whl

Download URL mkdocs_material_extensions-1.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
09569c3694b5acc1e8334c9730e52b4bcde65fc9d613cc20e49af131ef1a9ca0
BLAKE2b-256 checksum
How to use checksums
dd2a1ebdd2ddc72d3a886c9161202f3c568fee11685ca3668ae1c77ea6bb8304
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.46.0 CPython/3.7.7

Release history Release notifications | RSS feed

1.3.1

2 release files

1.3

2 release files

1.2

2 release files

1.1.1

2 release files

1.1

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

This release

1.0 This release

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