obsidian-latex-suite icon indicating copy to clipboard operation
obsidian-latex-suite copied to clipboard

[FEATURE] Excluded environments for snippets

Open BobVarioa opened this issue 1 year ago • 7 comments

Description of the Problem

Its annoying when in environments where the syntax is different (e.g. ce, pu) the default snippets still run.

Description of the Solution

Either something like the current auto-fraction options to disable all snippets from running in certain environments or a new parameter for each snippet that lets you exclude (/ whitelist) certain environments.

BobVarioa avatar Jan 25 '24 17:01 BobVarioa

I agree, this would be a great feature. For example, using mhchem's arrows is very annoying since the plugin keeps autocompleting math inside \ce{}. I have to type everything with spaces to stop the autocomplete.

https://github.com/artisticat1/obsidian-latex-suite/assets/68677082/3e94fec5-df6f-43c5-bd35-944b743c800f

Comprehensive-Jason avatar Feb 25 '24 16:02 Comprehensive-Jason

@BobVarioa I'm thinking of writing a PR for this by either extending the auto-fraction options or building a system of entries.

1

I will add a blacklist under Advanced Snippet Settings. Any environment written in the blacklist will have all snippets disabled unless the snippet has an e option added.

The limitation with this approach is that you can't select specific snippets for specific environments. For instance, if you have certain snippets that you want to run in \ce{ } but not in \physics{ } and vice versa, there is no way to specifically select for each.

2

I add a dialog for the user to enter individual environments to blacklist. Each environment will have an associated dialog box where the user could add a custom option character to enable snippets in that environment.

Example: I blacklist \ce{ } and add the option character h to enable snippets in it.


Which one do you think is the better approach?

Comprehensive-Jason avatar Mar 04 '24 18:03 Comprehensive-Jason

I think 2 is probably the better approach, as it's more gradual, i.e. people would only add things that annoy them, etc.

BobVarioa avatar Mar 04 '24 18:03 BobVarioa

Excluded environments are actually already implemented in code (see here), though currently the list of exclusions is fixed - there is no way for users to define custom exclusions for their snippets.

What do you think about exposing this functionality to the user through an interface like this (as opposed to a dialog box)?

{trigger: "->", replacement: "\\to", options: "mA", excluding: [["\ce{", "}"]]}

artisticat1 avatar Mar 04 '24 19:03 artisticat1

@artisticat1 This would be perfect! That puts all the customization in one place, which is way simpler.

Comprehensive-Jason avatar Mar 05 '24 21:03 Comprehensive-Jason

@artisticat1 I encountered recently that the i want to enter inline code mkdir folder_A, but the mk is automatically fracted to $$ after I input mk, I found a setting Excluded Environment (seems related), but no detailed notes, so I tried to add a line ["", ""] or ["\'", "\'"], but still no luck, it still auto-fracted. Would you tell me how to set this configuration. Thanks.

sylph520 avatar Apr 19 '24 03:04 sylph520

@sylph520 I don't think this feature has been implemented yet, though the bones are already there as artisticat said. We're waiting on them to add the feature.

Comprehensive-Jason avatar Apr 20 '24 07:04 Comprehensive-Jason