Parse @username links and colon emoji codes in markdown #441
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
On GitHub, the KSP forum, and most other web sites with users and comments, you can use an @-username sequence to link to a user of that site.
Currently this doesn't do anything on SpaceDock. It could be useful if you want to credit a user for something or if their mods are relevant to your mod's description.
(Thought of while reviewing KSP-CKAN/NetKAN#9007, which accidentally passed such a string through to a pull request and notified the wrong user on GitHub. The link in that description still won't be valid because it references a user that exists on the forum but not SpaceDock, but it would still be a nice feature to have for other cases.)
Similarly, GitHub supports
:emoji_name:
syntax for inserting emojis, as in::thinking:
→ 🤔... and this also doesn't work on SpaceDock currently.
Changes
Now the
KerbDown
processor is updated to handle @-username sequences. If the specified username doesn't exist (case-insensitive lookup) or isn't public, then the original text is preserved unchanged. Otherwise we turn it into a bold link with a tooltip on hover (my screen capture software did not preserve the mouse cursor).The link tooltip shows the number of mods on the user's profile and the date their account was created. Note that the mod count is the "correct" count of mods that will be visible after #425 is merged (including co-authored mods and excluding non-published mods).
The
/markdown
documentation route is updated to reflect this behavior.We also now support GitHub's
:emoji_name:
codes.Considered and not done
It would be even nicer to provide editing assistance by autocompleting usernames after the user types @, as GitHub does:
However, if we tried to add editing assistance now, we would have to re-do it after #420 is merged because it is changing the library that we use for the Markdown editor. So for now this is left as a possible future project.