Commit 0b2fe9a2 authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files


parent 1782fcf5
import re
import os
from mkdocs.config import Config
from mkdocs.plugins import BasePlugin
class IssueLinkPlugin(BasePlugin):
MD_LINK = re.compile(r']\(([^)]*)\)', re.UNICODE)
def _should_ignore_link(self, link):
return link.startswith(u"http") or link.startswith(u"#") or link.startswith(u"ftp") or link.startswith(u"www") or link.startswith(u"mailto") or link.endswith(u".md")
def on_page_markdown(self, markdown, page = None, config = None, **kwargs):
links = re.findall(self.MD_LINK, markdown)
issue_token ="issue_token")
issue_url ="issue_url")
for link in links:
#if self._should_ignore_link(link.lstrip()):
# continue
if not link.startswith(issue_token):
# Build the actual link
link_base = link[len(issue_token):]
link_new = "[GITLAB %s](%s%s)" % (link, issue_base, link)
# Replace the link in the markdown
markdown = markdown.replace("({})".format(link), "({})".format(link_new))
return markdown
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment