mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge pull request #475 from bdashore3/dev
Markdown escaping and reloading
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
updateVisibleDivs,
|
||||
eventSource,
|
||||
event_types,
|
||||
getCurrentChatId,
|
||||
} from "../script.js";
|
||||
import { favsToHotswap } from "./RossAscends-mods.js";
|
||||
import {
|
||||
@@ -933,6 +934,7 @@ $(document).ready(() => {
|
||||
$("#custom_chat_separator").on('input', function () {
|
||||
power_user.custom_chat_separator = $(this).val();
|
||||
saveSettingsDebounced();
|
||||
reloadMarkdownProcessor(power_user.render_formulas);
|
||||
});
|
||||
|
||||
$("#multigen").change(function () {
|
||||
@@ -1155,6 +1157,13 @@ $(document).ready(() => {
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$("#reload_chat").on('click', function () {
|
||||
const currentChatId = getCurrentChatId();
|
||||
if (currentChatId !== undefined && currentChatId !== null) {
|
||||
reloadCurrentChat();
|
||||
}
|
||||
});
|
||||
|
||||
$("#allow_name1_display").on("input", function () {
|
||||
power_user.allow_name1_display = !!$(this).prop('checked');
|
||||
reloadCurrentChat();
|
||||
|
||||
19
public/scripts/showdown-dinkus.js
Normal file
19
public/scripts/showdown-dinkus.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { power_user } from './power-user.js';
|
||||
|
||||
// Showdown extension to make chat separators (dinkuses) ignore markdown formatting
|
||||
export const dinkusExtension = () => {
|
||||
if (!power_user) {
|
||||
console.log("Showdown-dinkus extension: power_user wasn't found! Returning.");
|
||||
return []
|
||||
}
|
||||
|
||||
// Create an escaped sequence so the regex can work with any character
|
||||
const savedDinkus = power_user.custom_chat_separator
|
||||
const escapedDinkus = savedDinkus.split('').map((e) => `\\${e}`).join('');
|
||||
const replaceRegex = new RegExp(`^(${escapedDinkus})\n`, "gm")
|
||||
return [{
|
||||
type: "lang",
|
||||
regex: replaceRegex,
|
||||
replace: (match) => match.replace(replaceRegex, `<div>${savedDinkus}</div>`).trim()
|
||||
}];
|
||||
}
|
||||
Reference in New Issue
Block a user