obsidian-text-format
obsidian-text-format copied to clipboard
[FR] custom replacement to modify selectedText
The js code can be written in a textarea, the content will be eval() in the plugin.
As "Use of eval is strongly discouraged", this plugin will only support custom replacement. For now, only replace one pattern for each command, i.e., text.replace(search, replace).
If the user wants to replace multi-patterns in one command, the user can modify data.json directly (setting about it is not supported yet). If you think the setting is needed, comment on this issue to let me know. :)
Example
data.json:
"customReplaceList": [
{
"name": "test",
"data": [
{
"search": "\\n",
"replace": "\\n\\n"
},
{
"search": "manually add second search",
"replace": "manually add second replace"
},
]
}
],
The configuration works like
text.replace(/\n/g, "\n\n")
.replace("manually add second search", "manually add second replace");
As "Use of eval is strongly discouraged", this plugin will only support custom replacement.
Related work
- Dataview disable rollup checking in rollup.config.js
- Templater user
window.eval()and it will not raise warning/error likeeval().
Custom replacement should add a subpart, advanced custom replacement, for custom js