Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse @username links and colon emoji codes in markdown #441

Merged

Conversation

HebaruSan
Copy link
Contributor

@HebaruSan HebaruSan commented Mar 10, 2022

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.

image

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.

image

Considered and not done

It would be even nicer to provide editing assistance by autocompleting usernames after the user types @, as GitHub does:

image

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.

@HebaruSan HebaruSan added Area: Backend Related to the Python code that runs inside gunicorn Priority: Low Type: Feature Status: Ready Scope: Medium Moderately complex changes requiring non-trivial time and effort to develop and review labels Mar 10, 2022
@HebaruSan HebaruSan requested a review from DasSkelett March 10, 2022 19:42
@HebaruSan HebaruSan force-pushed the feature/md-at-username-links branch from 7505208 to bf95286 Compare March 12, 2022 20:31
@HebaruSan HebaruSan force-pushed the feature/md-at-username-links branch from bf95286 to 8204d09 Compare March 12, 2022 20:32
@HebaruSan HebaruSan changed the title Parse @username links in markdown Parse @username links and colon emoji codes in markdown Mar 16, 2022
@HebaruSan HebaruSan merged commit 7a5bd33 into KSP-SpaceDock:alpha Mar 3, 2023
@HebaruSan HebaruSan deleted the feature/md-at-username-links branch March 3, 2023 19:02
This was referenced Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Backend Related to the Python code that runs inside gunicorn Priority: Low Scope: Medium Moderately complex changes requiring non-trivial time and effort to develop and review Status: Ready Type: Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant