Skip to main content

Easily display icon fonts in markdown.

Project description

Code style: black

markdown-icons (

Easily display icon fonts in python markdown. Just add the CSS necessary for your font and add this extension.

This is a 3rd party extension for Python Markdown. You can see a full list of 3rd party extensions here.

Although this works with any icon font, users can use a mod syntax to add more prefixed classes to support Font Awesome and its special classes such as 2x, 3x, muted, spin, etc

Furthermore, users can add their own user_mod syntax to add additional, non-prefixed, pre-defined classes for greater control over their icons while allowing you to control exactly what styles are allowed.

See the python markdown documentation for more information.

Use it in any personal or commercial project you want.


  • Accepts a-z, A-Z, 0-9, _(underscore), and - (hypen)
  • Uses HTML Entity like syntax: &entity_name;

Mod syntax:


User mod syntax:


Example Markdown:

I love &icon-html5; and &icon-css3;
&icon-spinner:large,spin; Sorry we have to load...
I love <i aria-hidden="true" class="icon-html5"></i> and <i aria-hidden="true" class="icon-css3"></i>
<i aria-hidden="true" class="icon-spinner icon-large icon-spin"></i> Sorry we have to load...


pip install markdown-iconfonts

Usage / Setup:

Default Prefix is "icon-":

import markdown

md = markdown.Markdown(extensions=['iconfonts'])


import markdown
from iconfonts import IconFontsExtension

md = markdown.Markdown(extensions=[IconFontsExtension()])

The base option allows for use of Bootstrap 3 and FontAwesome 4 icons

md = markdown.Markdown(extensions=['iconfonts'],
converted_text = md.convert(text)

Input: &icon-html5;

Output: <i aria-hidden="true" class="icon icon-html5"></i>

prefix_base_pairs option

The prefix_base_pairs option allows for multiple prefix-base pairs to be specified, to allow you to support both Bootstrap 3/Glyphicon and FontAwesome icons

md = markdown.Markdown(extensions=['iconfonts'],
                           'iconfonts': {
                               'prefix_base_pairs': {
                                   'fa-': 'fa',
                                   'glyphicon-': 'glyphicon',
converted_text = md.convert(text)

Input: &glyphicon-remove; &fa-html5;

Output: <i aria-hidden="true" class="glyphicon glyphicon-remove"></i><i aria-hidden="true" class="fa fa-html5"></i>

How to run the unit tests

  • Install Markdown: pip install markdown
  • Install markdown icons. Copy the file into site-packages/markdown/extensions/
  • Navigate to the test directory in CMD/terminal and run python -v

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
markdown_iconfonts-3.0.0-py3-none-any.whl (4.8 kB) Copy SHA256 hash SHA256 Wheel py3
markdown-iconfonts-3.0.0.tar.gz (5.4 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page