LightningCreations / LightningLabsClient

1 stars 0 forks source link

Make links clickable in messages #302

Open Haeleon opened 1 month ago

Haeleon commented 1 month ago

Title. Some valid types of links should be converted to hyperlinks for quick access; this feature could also set up for creating fuller text rendering later.

kilbouri commented 1 month ago

I would suggest approaching this from a two-step perspective:

  1. the message is transformed when sent into real markdown (e.g. unmasked links become links masked as their URL)
  2. every message is rendered with markdown, the content is not transformed (neglecting any transformation required for custom markdown like Discord's negative heading)

This approach means that we probably need to store both the "original" content and the "transformed" content, otherwise when a user edits their message it won't contain the same plaintext in all cases.

Haeleon commented 1 month ago

I think I get what you mean.

In other words, the first step ("transforming") would be tweaking the plaintext of the message to essentially remove some syntax sugar, and the second step ("rendering") would be generating the styled HTML from that tweaked text. Is this correct?

kilbouri commented 1 month ago

Not nessarily removing syntax sugar (if we don't support things yes, we'd remove them) but rather taking plaintext and making markdown. For example if the user types a code block, we want to make sure that code block exists as Markdown expects (regardless of how we represent it ourselves). If a user types a link, we automatically mask it behind the scenes so it becomes a hyperlink when rendered.

The second step would be exactly that - there are even libraries to render markdown already, we probably don't need to brew our own for an MVP.