Feature suggestion: Flag to disable replacements unless some text is selected
Opened this issue · 1 comments
I use Plugin commands in the chain of automated commands (a macro) by QuickAdd Obsidian plugin.
Sometimes, when the macro fails to select the line for which the replacements should be limited, the Regex-Pipeline plugin introduces replacements in the whole document, which, unless timely recognized, becomes a major "pain-in-the-butt" to fix.
For example, the following workflow allows creating a callout with term-definition lists, like the following:
> > [!INFO]- Used abbreviations
> > - term_1: definition_1
> > - term_2: definition_2
> > - term_3: definition_3
with the following QuickAdd workflow:
See QuickAdd macro definition image
and the following QuickAdd template:
> > [!INFO]- Used abbreviations
> > - {{VALUE: Abbreviations}}
and the following input for Abbreviations: "term_1, defition_1; term_2, definition_2; term_3, definition_3."
and the following Regex-Pipeline ruleset:
:: Replace ; with a new line and a dash for list item ("-") inside a nested callout
";\s*"->"
> > - "
:: Replace the first in newly created lines comma (",") with the colon (":")
:: (separator between term and its definition)
"^([^,]+),\s*"->"$1: "
:: Remove final dot/period
"\.\s*$"->""
I recognize that part of the problem is lack of mechanisms in QuickAdd to select the whole text inserted with "{{VALUE}}".
As a workaround, I insert text as a single line. But when there is an empty line in the end of input, the QuickAdd will only select the last empty line, and the Regex-Pipeline plugin will understand this as a need to make replacements in the whole document, which is not the intention.
I want to have a configuration option to limit all operations to only the selected text and just signal in the console if nothing is selected.
Regex-Pipeline plugin will understand this as a need to make replacements in the whole document, which is not the intention.
Is the empty line actually empty or it consists of white spaces? Because if Obsidian consider white spaces selected as "nothing" and results in this plugin go replacing the whole document, it'd be a bit concerning.
I has added the flag for "selection only" mode but after reviewing this once again I figured I need the answer first.
So I selected a empty line (with line break) and a line with 1 white space, both case my ruleset is not applied to the whole document.