skip to navigation
skip to content

mdx_linkify 0.5

Link recognition for Python Markdown

Latest Version: 1.1

# 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:  
File Type Py Version Uploaded on Size
mdx_linkify-0.5.tar.gz (md5) Source 2014-03-16 3KB