Message formatting support #115
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
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 inPlainText
; 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.
The text was updated successfully, but these errors were encountered: