Description
Describe your feature request
In pr #1562 , a WSIWYG editor has been added to the text input area, however, when a text is sent, it is displayed in unrendered markdown. The idea is to use marked
to conditionally render certain elements in the user's sent message into markdown, and leave others untouched.
The WSIWYG editor currently converts the following into markdown:
- bold
- italic
- code blocks
- code spans
The sent user messages should display those specific elements converted into markdown, and leave the rest untouched and unconverted, such as headings.
Screenshots
An example of how a user message is currently displayed:
Implementation idea
The idea is to create a custom renderer
which might be done using marked
to be used when the message sender is the user
.
The renderer allows certain modifications, such as explicitly specifying what it should and should not convert, something like:
const renderer = new marked.Renderer();
renderer.list = (body, _ordered) => {
return body;
};
renderer.heading = (text: string, _level: number) => {
return text;
};
// continue to disable unwanted features
// enable what we need
renderer.code = (code: string) => `<pre><code>${code}</code></pre>`;
renderer.codespan = (text: string) => `<code>${text}</code>`;
renderer.strong = (text: string) => `<strong>${text}</strong>`;
renderer.em = (text: string) => `<em>${text}</em>`;
However any other implementation ideas are welcome!