Skip to main content

Mdx Link2MD: Convert markdown to HTML in batch

PyPI PyPI CircleCI MIT License

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.

Installation

The project is on PyPI!

$ pip install mdx_link2md

If you want the latest version, which might include unreleased-to-PyPI code, you can always grab the develop branch directly from Git.

$ pip install git+git://github.com/scyu16/mdx_link2md.git

Usage

As A Utility Script

The package can run as a top-level script to convert the multiple markdown files in batch:

$ python -m mdx_link2md <files_to_be_converted>

The converted files are placed in the same directory as the source files with the same names of html extension.

As A Module

If more flexibility is desired, the package could be used as a Python module.

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 __main__.py for the source code of the script that makes the module work as a utility, as described in the preceding subsection.

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:

1. If the package is run as a utility script, `ignore_url` is set to `True`.
2. The package is case insensitive to the `md` file extension in either usage.

Development

develop branch holds the latest stable code. Please create branches off develop branch for any changes or enhancement. It's suggested you first create a virtual environment and activate it, then:

$ git clone git@github.com:scyu16/mdx_link2md.git

. For Python 2.x,

$ pip install -r requirements/python2.txt

, while for Python 3.x,

$ pip install -r requirements/python3.txt

With this being done, import mdx_link2md would pick up any local changes made to the package.

TODO

  1. Make it work for links in other forms
  2. Fix circle ci for publishing to PyPi

Release files for mdx-link2md 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mdx-link2md 0.0.2
File Size Uploaded
mdx_link2md-0.0.2.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mdx-link2md 0.0.2
File Interpreter ABI Platform
mdx_link2md-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 8.8 kB

Release files / mdx_link2md-0.0.2.tar.gz

Download URL mdx_link2md-0.0.2.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
25b9d2080b0792d54136230dbf52dbd06279f6fcf699ad4800b5b865c4bcd288
BLAKE2b-256 checksum
How to use checksums
ce1cd23c32acd6b02e88b303aa90bb6711a1814a1f102a12644ae089c02dfcf8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.4

Release files / mdx_link2md-0.0.2-py3-none-any.whl

Download URL mdx_link2md-0.0.2-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
10e624105bc4f4af2369bda7baba0e0822276485395bf95f2c9e6ad1965bc488
BLAKE2b-256 checksum
How to use checksums
943980265902624380e3ccccf0bda9f0997d3a16597bfb21a9cf87dda6997c80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.4

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page