su-fit-vut / kachna-online

Students' Club U Kachničky: Member's portal
MIT License
5 stars 5 forks source link

Message formatting support #115

Open ondryaso opened 2 years ago

ondryaso commented 2 years ago

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:

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 commented 1 year ago

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