3535from xml .etree import ElementTree
3636
3737
38- URL_BASE = 'https://github.com'
3938RE_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
116115class 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