Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature suggestion: Flag to disable replacements unless some text is selected #29

Open
voltel opened this issue Sep 11, 2023 · 1 comment

Comments

@voltel
Copy link

voltel commented Sep 11, 2023

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.

@No3371
Copy link
Owner

No3371 commented Oct 2, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants