mirror of https://github.com/sveltejs/svelte
parent
b869e48bff
commit
0e9f16b589
@ -1,9 +1,9 @@
|
||||
export function stringify(data: string) {
|
||||
return JSON.stringify(escape(data));
|
||||
export function stringify(data: string, options = {}) {
|
||||
return JSON.stringify(escape(data, options));
|
||||
}
|
||||
|
||||
export function escape(data: string) {
|
||||
return data.replace(/(@+|#+)/g, (match: string) => {
|
||||
export function escape(data: string, { onlyEscapeAtSymbol = false } = {}) {
|
||||
return data.replace(onlyEscapeAtSymbol ? /(@+)/g : /(@+|#+)/g, (match: string) => {
|
||||
return match + match[0];
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in new issue