Skip to content

Commit

Permalink
Allow configuring custom repo provider (#2277)
Browse files Browse the repository at this point in the history
* Allow configuring custom repo provider

Resolves #933

* Clean up

* Add documentation

* Bump version
  • Loading branch information
facelessuser committed Dec 26, 2023
1 parent 899e811 commit e6fe355
Show file tree
Hide file tree
Showing 6 changed files with 615 additions and 146 deletions.
1 change: 1 addition & 0 deletions docs/src/dictionary/en-custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ syntaxes
th
theming
thumbsup
tooltips
tox
uc
un
Expand Down
8 changes: 6 additions & 2 deletions docs/src/markdown/about/changelog.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Changelog

## 10.6

- **NEW**: MagicLink: Allow configuring custom repository providers based off the existing providers.

## 10.5

- **NEW**: Blocks: Admonitions and Details now allow configuring custom block classes and default titles.
- **FIX**: Keys: Ensure that Keys does not parse base64 encoded URLs.
- **NEW**: Blocks: Admonitions and Details now allow configuring custom block classes and default titles.
- **FIX**: Keys: Ensure that Keys does not parse base64 encoded URLs.

## 10.4

Expand Down
34 changes: 34 additions & 0 deletions docs/src/markdown/extensions/magiclink.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,40 @@ repository name. You can override them and add more via the option [`shortener_u
MagicLink added user name and repository name link shortening along.
///

## Custom Repository Hosts

It is possible that someone may be running their own private GitHub, GitLab, or Bitbucket repository. MagicLink allows
for the creating variants of either of these repository providers with a custom host. MagicLink provides no additional
control over specifics, so if this is sufficient for your needs, then it give it a try!

To specify a custom provider, you simply need to specify them via the `custom` option.

1. Simply specify the name to identify the provider (must only contain alphanumeric characters). Provider name is used
when manually specifying a provider (`@provider:user`) and will be used to generate custom CSS classes
`magiclink-provider`.
2. Specify the `type`. Is this a private `github`, `gitlab`, or `bitbucket` provider.
3. Specify the `label` for tooltips.
4. Specify the `host` for your private repository.

```js
'custom': {
'test': {
'host': 'http://test.com',
'label': 'Test',
'type': 'github'
}
}
```

Host URLs assume the `www` subdomain, and will generate the URL pattern to capture explicit or implicit `www` in host
URLs, whether you specify it in the host URL or not. If your repository does not use `www` subdomain, then set the
option `www` to `#!py False`. Most people will never need to touch this.

Lastly, `shortener_user_exclude` will assume your custom provider requires the same exclude list of the specified `type`
and will copy them for your custom repository. If this is not sufficient, you can add an entry to
`shortener_user_exclude` for your custom repository provider using your specified `name`. If you manually set excludes
in this manner, no excludes from the same `type` will be copied over.

## CSS

For normal links, no classes are added to the anchor tags. For repository links, `magiclink` will be added as a class.
Expand Down
2 changes: 1 addition & 1 deletion pymdownx/__meta__.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,5 @@ def parse_version(ver, pre=False):
return Version(major, minor, micro, release, pre, post, dev)


__version_info__ = Version(10, 5, 0, "final")
__version_info__ = Version(10, 6, 0, "final")
__version__ = __version_info__._get_canonical()
Loading

0 comments on commit e6fe355

Please sign in to comment.