Skip to content

Commit

Permalink
Display user on repository mention even if user is default
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
facelessuser committed Nov 15, 2017
1 parent 80950ee commit c493fe8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/src/markdown/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
3 changes: 1 addition & 2 deletions docs/src/markdown/extensions/magiclink.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pymdownx/magiclink.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/extensions/magiclink/magiclink (shorthand).html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p>Mention <a class="magiclink magiclink-github magiclink-mention" href="https://github.com/some-bodies_name" title="GitHub User: some-bodies_name">@some-bodies_name</a></p>
<p>Mention <a class="magiclink magiclink-github magiclink-repository" href="https://github.com/some-bodies_name/some_repository" title="GitHub Repository: some-bodies_name/some_repository">some-bodies_name/some_repository</a></p>
<p>Mention <a class="magiclink magiclink-github magiclink-repository" href="https://github.com/facelessuser/some_repository" title="GitHub Repository: facelessuser/some_repository">some_repository</a></p>
<p>Mention <a class="magiclink magiclink-github magiclink-repository" href="https://github.com/facelessuser/some_repository" title="GitHub Repository: facelessuser/some_repository">facelessuser/some_repository</a></p>
<p>Commit <a class="magiclink magiclink-github magiclink-commit" href="https://github.com/some-bodies_name/some_repository/commit/3f6b07a8eeaa9d606115758d90f55fec565d4e2a" title="GitHub Commit: some-bodies_name/some_repository@3f6b07a">some-bodies_name/some_repository@3f6b07a</a></p>
<p>Issue <a class="magiclink magiclink-github magiclink-issue" href="https://github.com/some-bodies_name/some_repository/issues/33" title="GitHub Issue: some-bodies_name/some_repository#33">some-bodies_name/some_repository#33</a></p>
<p>Pull request <a class="magiclink magiclink-github magiclink-pull" href="https://github.com/some-bodies_name/some_repository/pull/33" title="GitHub Pull Request: some-bodies_name/some_repository!33">some-bodies_name/some_repository!33</a></p>
Expand Down

0 comments on commit c493fe8

Please sign in to comment.