A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/ricmua/markdown-md2html_links below:

ricmua/markdown-md2html_links: A Python-Markdown extension for replacing .md file extensions with .html extensions in links.

This is a Python-Markdown extension for replacing .md file extensions with .html extensions in links. This is especially useful for maintaining Markdown collections that contain relative internal links, but are still parser-agnostic. There is a related GitHub issue.

The package must be available in the Python path. A setup.py script is included.

Example:

from markdown import markdown
from md2html_links import CustomLinkExtension

data = 'Some text and a [link](path/to/a/document.md).\n'
html = markdown(data, extensions=[CustomLinkExtension()])
print(f'ORIGINAL:\n{data}\n\nCONVERTED:\n{html}')

The output is as follows:

ORIGINAL:
Some text and a [link](path/to/a/document.md).


CONVERTED:
<p>Some text and a <a href="path/to/a/document.html">link</a>.</p>

This extension has been created following the guidance of the Python-Markdown extensions tutorial and the extensions API documentation.

The approach is to replace the LinkInlineProcessor inline processor with a slightly modified version of the same. It is given the same priority as the original in the Python-Markdown registry.

An alternative approach was also suggested by @venthur.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4