mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Handle <br> in message texts with Showdown instead of manually
This commit is contained in:
@ -724,6 +724,7 @@ function reloadMarkdownProcessor(render_formulas = false) {
|
|||||||
underline: true,
|
underline: true,
|
||||||
tables: true,
|
tables: true,
|
||||||
parseImgDimensions: true,
|
parseImgDimensions: true,
|
||||||
|
simpleLineBreaks: true,
|
||||||
extensions: [
|
extensions: [
|
||||||
showdownKatex(
|
showdownKatex(
|
||||||
{
|
{
|
||||||
@ -742,6 +743,7 @@ function reloadMarkdownProcessor(render_formulas = false) {
|
|||||||
parseImgDimensions: true,
|
parseImgDimensions: true,
|
||||||
tables: true,
|
tables: true,
|
||||||
underline: true,
|
underline: true,
|
||||||
|
simpleLineBreaks: true,
|
||||||
extensions: [markdownUnderscoreExt()],
|
extensions: [markdownUnderscoreExt()],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1807,9 +1809,7 @@ function messageFormatting(mes, ch_name, isSystem, isUser, messageId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this_chid === undefined && !selected_group) {
|
if (this_chid === undefined && !selected_group) {
|
||||||
mes = mes
|
mes = mes.replace(/\*\*(.+?)\*\*/g, '<b>$1</b>');
|
||||||
.replace(/\*\*(.+?)\*\*/g, '<b>$1</b>')
|
|
||||||
.replace(/\n/g, '<br/>');
|
|
||||||
} else if (!isSystem) {
|
} else if (!isSystem) {
|
||||||
// Save double quotes in tags as a special character to prevent them from being encoded
|
// Save double quotes in tags as a special character to prevent them from being encoded
|
||||||
if (!power_user.encode_tags) {
|
if (!power_user.encode_tags) {
|
||||||
@ -1841,7 +1841,6 @@ function messageFormatting(mes, ch_name, isSystem, isUser, messageId) {
|
|||||||
// Firefox creates extra newlines from <br>s in code blocks, so we replace them before converting newlines to <br>s.
|
// Firefox creates extra newlines from <br>s in code blocks, so we replace them before converting newlines to <br>s.
|
||||||
return match.replace(/\n/gm, '\u0000');
|
return match.replace(/\n/gm, '\u0000');
|
||||||
});
|
});
|
||||||
mes = mes.replace(/\n/g, '<br/>');
|
|
||||||
mes = mes.replace(/\u0000/g, '\n'); // Restore converted newlines
|
mes = mes.replace(/\u0000/g, '\n'); // Restore converted newlines
|
||||||
mes = mes.trim();
|
mes = mes.trim();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user