Skip to content

Commit 8d7dbe7

Browse files
committed
Add domain config option to support GES.
Fixes #15.
1 parent 24242b5 commit 8d7dbe7

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ a GitHub link, then the value of this option will be used.
5656
A GitHub repository. If no repository is specified in a GitHub link, then the
5757
value of this option will be used.
5858

59+
### domain
60+
61+
The domain of the host server for the repository. Defaults to
62+
`https://github.com`, but may be set to the root of a GitHub Enterprise Server.
63+
5964
## Syntax
6065

6166
This extension implements shorthand to specify links to GitHub in various ways.
@@ -142,6 +147,10 @@ defined in `LICENSE`.
142147

143148
## Change Log
144149

150+
### Version 0.4 (unreleased)
151+
152+
Add `domain` configuration option in order to support GitHub Enterprise Servers.
153+
145154
### Version 0.3.1 (2023/07/28)
146155

147156
Include README in release.

mdx_gh_links.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
from xml.etree import ElementTree
3636

3737

38-
URL_BASE = 'https://github.com'
3938
RE_PARTS = dict(
4039
USER=r'[-_\w]{1,39}\b',
4140
REPO=r'[-_.\w]+\b'
@@ -65,10 +64,10 @@ def handleMatch(self, m):
6564
repo = m.group(4)
6665
if repo:
6766
title = 'GitHub Repository: @{0}/{1}'.format(user, repo)
68-
href = '{0}/{1}/{2}'.format(URL_BASE, user, repo)
67+
href = '{0}/{1}/{2}'.format(self.config['domain'], user, repo)
6968
else:
7069
title = 'GitHub User: @{0}'.format(user)
71-
href = '{0}/{1}'.format(URL_BASE, user)
70+
href = '{0}/{1}'.format(self.config['domain'], user)
7271
return _build_link(label, title, href, 'gh-link gh-mention')
7372

7473

@@ -86,7 +85,7 @@ def handleMatch(self, m):
8685
repo = m.group(4) or self.config['repo']
8786
num = m.group(5).lstrip('0')
8887
title = 'GitHub Issue {0}/{1} #{2}'.format(user, repo, num)
89-
href = '{0}/{1}/{2}/issues/{3}'.format(URL_BASE, user, repo, num)
88+
href = '{0}/{1}/{2}/issues/{3}'.format(self.config['domain'], user, repo, num)
9089
return _build_link(label, title, href, 'gh-link gh-issue')
9190

9291

@@ -109,13 +108,14 @@ def handleMatch(self, m):
109108
label = short
110109
user = self.config['user']
111110
title = 'GitHub Commit: {0}/{1}@{2}'.format(user, repo, commit)
112-
href = '{0}/{1}/{2}/commit/{3}'.format(URL_BASE, user, repo, commit)
111+
href = '{0}/{1}/{2}/commit/{3}'.format(self.config['domain'], user, repo, commit)
113112
return _build_link(label, title, href, 'gh-link gh-commit')
114113

115114

116115
class GithubLinks(Extension):
117116
def __init__(self, *args, **kwargs):
118117
self.config = {
118+
'domain': ['https://github.com', 'GitHub domain or Enterprise Server domain'],
119119
'user': ['', 'GitHub user or organization.'],
120120
'repo': ['', 'Repository name.']
121121
}

0 commit comments

Comments
 (0)