From c493fe8b151348cdea4eaa87d61b14982f14ad80 Mon Sep 17 00:00:00 2001 From: facelessuser Date: Tue, 14 Nov 2017 23:51:58 -0700 Subject: [PATCH] Display user on repository mention even if user is default For consistency, keep both the user and repository name when displaying repository mention. It is easier to add new functionality if we change our mind than it is to remove the functionality if we change our mind. --- docs/src/markdown/changelog.md | 2 +- docs/src/markdown/extensions/magiclink.md | 3 +-- pymdownx/magiclink.py | 8 ++++---- tests/extensions/magiclink/magiclink (shorthand).html | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/src/markdown/changelog.md b/docs/src/markdown/changelog.md index 57b410c57..867210c1a 100644 --- a/docs/src/markdown/changelog.md +++ b/docs/src/markdown/changelog.md @@ -2,7 +2,7 @@ ## 4.3.0 -Nov X, 2017 +Nov 14, 2017 - **NEW**: Shorthand format for referencing non-default provider commits, issues, pulls, and mentions (!147). - **NEW**: Shorthand format for mentioning a repo via `@user/repo` (!149). diff --git a/docs/src/markdown/extensions/magiclink.md b/docs/src/markdown/extensions/magiclink.md index 0314ede98..357f94060 100644 --- a/docs/src/markdown/extensions/magiclink.md +++ b/docs/src/markdown/extensions/magiclink.md @@ -37,7 +37,7 @@ All shorthand links will be relative to your `provider`, and they do not current Mentions of other users are performed with the following syntax: `@{user}`. To reference an external provider, use the format `@{provider}:{user}` -You can also mention repositories. This feature is actually inspired by the GitHub only @Python-Markdown/github-links which performs *similar* auto-linking. The syntax to auto-link a repository with mentioning is very similar to auto-linking a user, except you append the repository to the user name like so: `@{user}/{repo}`. If specifying a non-default provider, the form would look like: `@{provider}:{user}/{repo}`. The output for repository mentions omits the `@` symbol, and will even omit the user if it is a repository under the default user. +You can also mention repositories. This feature is actually inspired by the GitHub only @Python-Markdown/github-links which performs *similar* auto-linking. The syntax to auto-link a repository with mentioning is very similar to auto-linking a user, except you append the repository to the user name like so: `@{user}/{repo}`. If specifying a non-default provider, the form would look like: `@{provider}:{user}/{repo}`. The output for repository mentions omits the `@` symbol and will just show the user and repository, but you are free to style it with CSS to make it stand out more like has been done in this document. ### Issues and Pull Requests @@ -61,7 +61,6 @@ Shorthand | Output `@user` | @user `@gitlab:user` | @gitlab:user `@user/repo` | @user/repo -`@facelessuser/pymdown-extensions` | @facelessuser/pymdown-extensions `@gitlab:user/repo` | @gitlab:user/repo `#1` | #1 `repo#1` | repo#1 diff --git a/pymdownx/magiclink.py b/pymdownx/magiclink.py index 116dfdf57..1af4fbc94 100644 --- a/pymdownx/magiclink.py +++ b/pymdownx/magiclink.py @@ -388,10 +388,10 @@ def process_mention_repo(self, el, provider, mention, repo_name): ) el.set('class', 'magiclink magiclink-%s magiclink-repository' % prov) user = mention[1:] - if user == self.user and prov == self.provider: - el.text = md_util.AtomicString(repo_name) - else: - el.text = md_util.AtomicString('%s/%s' % (user, repo_name)) + # if user == self.user and prov == self.provider: + # el.text = md_util.AtomicString(repo_name) + # else: + el.text = md_util.AtomicString('%s/%s' % (user, repo_name)) return el def process_issues(self, el, provider, user, repo, issue): diff --git a/tests/extensions/magiclink/magiclink (shorthand).html b/tests/extensions/magiclink/magiclink (shorthand).html index 7c2541dfd..b27ac6bc4 100644 --- a/tests/extensions/magiclink/magiclink (shorthand).html +++ b/tests/extensions/magiclink/magiclink (shorthand).html @@ -1,6 +1,6 @@

Mention @some-bodies_name

Mention some-bodies_name/some_repository

-

Mention some_repository

+

Mention facelessuser/some_repository

Commit some-bodies_name/some_repository@3f6b07a

Issue some-bodies_name/some_repository#33

Pull request some-bodies_name/some_repository!33