mirror of
https://github.com/keathmilligan/obsidian-paste-reformatter.git
synced 2026-07-22 05:43:44 +00:00
parent
1320ccc231
commit
63610697ed
2 changed files with 8 additions and 2 deletions
|
|
@ -22,8 +22,11 @@ export function transformHTML(
|
|||
for (const replacement of settings.htmlRegexReplacements) {
|
||||
try {
|
||||
const regex = new RegExp(replacement.pattern, 'g');
|
||||
const originalHtml = html;
|
||||
html = html.replace(regex, replacement.replacement);
|
||||
appliedTransformations = true;
|
||||
if (originalHtml !== html) {
|
||||
appliedTransformations = true;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error applying regex replacement: ${error}`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,11 @@ export function transformMarkdown(
|
|||
for (const replacement of settings.markdownRegexReplacements) {
|
||||
try {
|
||||
const regex = new RegExp(replacement.pattern, 'g');
|
||||
const originalMarkdown = markdown;
|
||||
markdown = markdown.replace(regex, replacement.replacement);
|
||||
appliedTransformations = true;
|
||||
if (originalMarkdown !== markdown) {
|
||||
appliedTransformations = true;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error applying markdown regex replacement: ${error}`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue