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

Message formatting support #115

Open
ondryaso opened this issue Mar 23, 2022 · 1 comment
Open

Message formatting support #115

ondryaso opened this issue Mar 23, 2022 · 1 comment
Labels
backend A backend-related issue comp-events Related to the event management functionality comp-states Related to the state management functionality frontend A frontend-related issue frontend-homepage Related to the frontend's homepage

Comments

@ondryaso
Copy link
Member

Currently, notes and events' details are always rendered in plaintext. This prevents users from formatting them in any way.

Also, public state notes get sent to Discord. Users may use Markdown to format them; and use special Discord tags to include Discord emojis or tags. However, these are shown in plaintext on the web page which makes the messages look rather ugly.

Formatting capabilities should be added both to the backend and the frontend. Let's use Markdown because that's what everybody does and it's (kinda) what Discord uses.

A new optional parameter, noteFormat, should be introduced on the backend for endpoints that return notes and descriptions (basically all GET /states/* and /events/* endpoints). It will control the kind of preprocessing the client requires:

  • Markdown: this will return the note exactly as stored in the database.
  • PlainText: this will strip the returned note of all formatting and extra tags (emojis, mentions, HTML, images etc.) Links will be replaced with their label. If the note contains a Discord tag and the target user ID is stored in our database, it may be replaced with the user's name.
  • Discord: this strips the message of all formatting not supported by Discord (links, HTML).
  • ReplaceDiscordEntities: keeps the text as-is, except that it replaces the emoji entities <:name:ID> with HTML images pointing to Discord's CDN: <img src="https://cdn.discordapp.com/emojis/{EMOJI_ID}.webp">; user tags are processed like in PlainText; other entities are removed.

Mind the newlines.

Before saving to the database, all notes and descriptions should be checked for dangerous HTML entities and unsupported formatting.

In the frontend, a Markdown rendering library should be used.

@ondryaso ondryaso added backend A backend-related issue frontend A frontend-related issue comp-states Related to the state management functionality comp-events Related to the event management functionality frontend-homepage Related to the frontend's homepage labels Mar 23, 2022
@ondryaso
Copy link
Member Author

ondryaso commented Dec 5, 2022

In event details (possibly elsewhere as well?), whitespaces at the beginning of lines should also be respected and kept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend A backend-related issue comp-events Related to the event management functionality comp-states Related to the state management functionality frontend A frontend-related issue frontend-homepage Related to the frontend's homepage
Projects
None yet
Development

No branches or pull requests

1 participant