Skip to main content

A markdown link preprocessor for Python Markdown

Project description

Mdx Link2MD: Convert markdown to HTML in batch

This extension for Python Markdown changes md extension in the markdown links to html before links in the text are converted to HTML hyperlinks. For example, the sample text in markdown format,

Please read [help](../read.md)

would be converted to

Please read <a href="../read.html">help</a>

.

This would allow converting markdown files to HTML format in batch, with internal links to markdown files being updated to the corresponding HTML files. It helps most when there are cross references among the markdown documents of interest.

Usage

Minimal Example

from markdown import markdown
from mdx_link2md.markdownlinks import MarkdownLinkExtension


md = markdown.Markdown(output_format='html5',
                       extensions=[MarkdownLinkExtension(ignore_url=False)])
md.convertFile('input_file', output='output_file', encoding='utf-8')

Please see markdown2html.py for a working example, which could also be used as a utility to convert markdown files in batch.

Configuration Settings

The only setting for the extension is ignore_url, with a True default value. When ignore_url is False, markdown links to none local files are also updated:

ignore_url input output
True [help](http://xyz.com/read.mD) <a href="http://xyz.com/read.mD">help</a>
False [help](http://xyz.com/read.mD) <a href="http://xyz.com/read.html">help</a>

Note: the preprocessing is case insensitive to the md file extension.

Installation

Development

Releasing

Project details


Download files

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

Files for mdx-link2md, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size mdx_link2md-0.0.1-py3-none-any.whl (3.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size mdx_link2md-0.0.1.tar.gz (2.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page