Package: mdx-gh-links
Python-Markdown Github-Links ExtensionAn extension to Python-Markdown which adds support for shorthand links to GitHub
users, repositories, issues and commits.InstallationTo install the extension run the following command:pipinstallmdx-gh-linksUsageTo use the extension simply include its name in the list of extensions passed to
Python-Markdown.importmarkdownmarkdown.markdown(src,extensions=['mdx_gh_links'])Configuration OptionsTo set configuration options, you may pass them to Markdown'sexension_configskeyword...markdown.markdown(src,extensions=['mdx_gh_links'],extension_configs={'mdx_gh_links':{'user':'foo','repo':'bar'}})... or you may import and pass the configs directly to an instance of themdx_gh_links.GithubLinksclass...frommdx_gh_linksimportGithubLinksmarkdown.markdown(src,extensions=[GithubLinks(user='foo',repo='bar')])The following configuration options are available:userA GitHub user name or organization. If no user or organization is specified in
a GitHub link, then the value of this option will be used.repoA GitHub repository. If no repository is specified in a GitHub link, then the
value of this option will be used.domainThe domain of the host server for the repository. Defaults tohttps://github.com, but may be set to the root of a GitHub Enterprise Server.SyntaxThis extension implements shorthand to specify links to GitHub in various ways.All links in the generated HTML are assigned agh-linkclass as well as a class
unique to that type of link. See each type for the specific class assigned.MentionsLink directly to a GitHub user, organization or repository. Note that no
verification is made that an actual user, organization or repository exists. As
the syntax does not differentiate between users and organizations, all
organizations are assumed to be users. However, this assumption is only
reflected in the title of a link.Mentions use the format@{user}to link to a user or organization and@{user}/{repo}to link to a repository. The defaults defined in the
configuration options are ignored by mentions. A mention may be escaped by
adding a backslash immediately before the at sign (@).All mentions are assigned thegh-mentionclass.The following table provides some examples:shorthandhrefrendered result@foohttps://github.com/foo@foo@foo/barhttps://github.com/foo/bar@foo/bar\@foo@foo\@foo/bar@foo/barIssuesLink directly to a GitHub issue or pull request (PR). Note that no verification
is made that an actual issue or PR exists. As the syntax does not differentiate
between Issues and PRs, all URLs point to "issues". Fortunately, GitHub will
properly redirect an issue URL to a PR URL if appropriate.Issue links use the format#{num}or{user}/{repo}#{num}.{num}is the
number assigned to the issue or PR.{user}and{repo}will use the
defaults defined in the configuration options if not provided. An issue link may
be escaped by adding a backslash immediately before the hash mark (#).All issue links are assigned thegh-issueclass.The following table provides various examples (with the defaults set asuser='user', repo='repo'):shorthandhrefrendered result#123https://github.com/user/repo/issues/123#123foo/bar#123https://github.com/foo/bar/issues/123foo/bar#123\#123#123foo/bar\#123foo/bar#123CommitsLink directly to a GitHub Commit. Note that no verification is made that an
actual commit exists.Commit links consist of a complete 40 character SHA hash and may optionally be
prefaced by{user}@or{user/repo}@.{user}and{repo}will use the
defaults defined in the configuration options if not provided. To avoid a 40
character hash from being linked, wrap it in a code span.All commit links are assigned thegh-commitclass.The following table provides various examples (with the defaults set asuser='user', repo='repo'):shorthandhrefrendered result72df691791fb36f00cf5363fefe757c8d3042656https://github.com/user/repo/commit/72df691791fb36f00cf5363fefe757c8d304265672df691foo@72df691791fb36f00cf5363fefe757c8d3042656https://github.com/foo/repo/commit/72df691791fb36f00cf5363fefe757c8d3042656foo@72df691foo/bar@72df691791fb36f00cf5363fefe757c8d3042656https://github.com/foo/bar/commit/72df691791fb36f00cf5363fefe757c8d3042656foo/bar@72df691`72df691791fb36f00cf5363fefe757c8d3042656`72df691791fb36f00cf5363fefe757c8d3042656LicenseThe Python-Markdown Github-Links Extension is licensed under theBSD Licenseas
defined inLICENSE.Change LogVersion 0.4 (2023/12/22)Adddomainconfiguration option in order to support GitHub Enterprise Servers.Version 0.3.1 (2023/07/28)Include README in release.Version 0.3 (2022/07/18)Update dependencies.Version 0.2 (2018/03/09)Ignore mentions/issues/commits within Markdown links.Version 0.1 (2017/11/10)The initial release.