Skip to main content

Link recognition for Python Markdown

Project description

# Mdx Linkify

[![Build Status](](
[![Coverage Status](](
[![PyPI Downloads](](
[![PyPI Version](](

This extension for [Python Markdown](
will convert all links to HTML anchors.

There's [an existing solution]( for
parsing links with regexes. Mdx Linkify is a bit smarter and asks
[Bleach]( to parse them. :clap:

## Usage

### Basic Example

By default, if you add `linkify` extension to `markdown` extensions...

from markdown import markdown

text = ""

assert markdown(text) == "<p></p>"

expected = markdown(text, extensions=["linkify"])
actual = '<p><a href=""></a></p>'
assert expected == actual
``` will automatically convert all links to HTML anchors.

### Linkify Callbacks

If you need callbacks, you can specify them in `extension_configs` like shown

from mdx_linkify.mdx_linkify import LinkifyExtension
from markdown import Markdown

def dont_linkify_txt_extension(attrs, new=False):
if attrs["_text"].endswith(".txt"):
return None

return attrs

md = Markdown(
"linkify": {
"linkify_callbacks": [[dont_linkify_txt_extension], ""]

assert md.convert("not_link.txt"), '<p>not_link.txt</p>'

expected = md.convert("")
actual = '<p><a href=""></a></p>'
assert expected == actual
```, we only convert links that do **not** end with `.txt` extension.

## Installation

The project is [on PyPI](!

pip install mdx_linkify

## Development

git clone
virtualenv mdx_linkify/
cd mdx_linkify/
source bin/activate
python install
python test

Pull requests are much welcome! :+1:

Project details

Release history Release notifications

History Node


History Node


History Node


This version
History Node


History Node


History Node


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
mdx_linkify-0.5.tar.gz (3.3 kB) Copy SHA256 hash SHA256 Source None Mar 16, 2014

Supported by

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