Skip to main content

Extension pack for Python Markdown.

Project description

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.

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

mkdocs-material-extensions-1.0.1.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file mkdocs-material-extensions-1.0.1.tar.gz.

File metadata

  • Download URL: mkdocs-material-extensions-1.0.1.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.9

File hashes

Hashes for mkdocs-material-extensions-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6947fb7f5e4291e3c61405bad3539d81e0b3cd62ae0d66ced018128af509c68f
MD5 4ada83215fa71cf317f893123b5983b8
BLAKE2b-256 0bc3cd35b94086fbe289f6d9323c793198423739c8cdbad01efa564098357298

See more details on using hashes here.

Provenance

File details

Details for the file mkdocs_material_extensions-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: mkdocs_material_extensions-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.9

File hashes

Hashes for mkdocs_material_extensions-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d90c807a88348aa6d1805657ec5c0b2d8d609c110e62b9dce4daf7fa981fa338
MD5 cca46239ba4036aa321b13289fa99728
BLAKE2b-256 521cd44c75a584e19a6b63d20befe6ac282a8cc092bf1299dd3b225fd3c3e239

See more details on using hashes here.

Provenance

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