Skip to main content

Python-Markdown GitLab-Links Extension

An extension to Python-Markdown which adds support for GitLab-specific references. Inspired by github-links.

Installation

pip install mdx-gitlab-links

Usage

To use the extension simply include its name in the list of extensions passed to Python-Markdown.

To set configuration options, you may pass them to Markdown's exension_configs keyword.

import markdown

markdown.markdown(
    src,
    extensions=["mdx_gitlab_links"],
    extension_configs={
        "mdx_gitlab_links": {
            "domain": "https://gitlab.mydomain.com",
            "group": "my-group/my-subgroup",
            "project": "my-project",
        },
    },
)

Or you may import and pass the configs directly to an instance of the mdx_gitlab_links.GitlabLinks class.

import markdown
from mdx_gitlab_links import GitlabLinks

extension = GitlabLinks(
    domain="https://gitlab.mydomain.com",
    group="my-group/my-subgroup",
    project="my-project",
)

markdown.markdown(src, extensions=[extension])

The following configurations options are available:

  • domain: The GitLab domain or Enterprise Server domain. Default to https://gitlab.com.
  • group: The GitLab user or group (and subgroup).
  • project: The GitLab repository name.

Syntax

All links are assigned the gl-link class as well as a class unique to that type of link. See each type for the specific class assigned.

Merge Requests

All merge requests links are assigned the gl-mr class.

The following table provides various examples (with the defaults set as group='group/subgroup', project='project'):

input href render
!123 https://gitlab.com/group/subgroup/project/123 !123
proj!123 https://gitlab.com/group/subgroup/proj/123 proj/!123
grp/sub/proj!123 https://gitlab.com/grp/sub/proj/123 grp/sub/proj/!123
\!123 !123
proj\!123 proj!123
grp/sub/proj\!123 grp/sub/proj!123

Metadata

Release files for mdx-gitlab-links 0.1.0

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-gitlab-links 0.1.0
File Size Uploaded Provenance Actions
mdx_gitlab_links-0.1.0.tar.gz 32.6 kB With provenance Details for mdx_gitlab_links-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mdx-gitlab-links 0.1.0
File Interpreter ABI Platform Actions
mdx_gitlab_links-0.1.0-py3-none-any.whl Python 3 none any Details for mdx_gitlab_links-0.1.0-py3-none-any.whl

Total release size: 38.2 kB

Security for mdx-gitlab-links 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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