ijgnd / anki__BetterSearch

7 stars 1 forks source link

multiline setting issue in 2.1.22 #13

Closed Laern2Do closed 4 years ago

Laern2Do commented 4 years ago

hi there,

thank you so much for making this available on 2.122! i cant wait to mess with it

Here a first one XD.... I cant change the modify search bar to "down" or "multiline" as this errors is show

image

thx!

Laern2Do commented 4 years ago

false alarm, i didnt double quote the multiline, "multiline" work... the default is set to false, rather then "down" as mention in the right side bar info ^^

ijgnd commented 4 years ago

When you adjust the config for an add-on in this extra window you actually edit a so-called "json" file. This means you must strictly adhere to the json rules or you will get such weird error messages.

It's not ideal. But but better than no option to config add-ons or forcing add-on creators to invest much time into writing nice dialog with buttons which would mean that I wouldn't invest any time into offering config options.

The json format is actually pretty simple. Maybe google "json file syntax" for a short introduction which will help will all add-ons in the future, maybe Learn json in Y minutes? There are also websites where you can paste your json code which highlight invalid parts which makes it easier to fix it

In general:

  1. Closely look how it's done in the default config
  2. Usually all settings must be surrounded with "" (quote signs). There are some exceptions: The boolean values true/false (lowercase) and numbers. But a few add-ons have counterexceptions where you must also quote numbers. But then rule 1 helps.
  3. json holds key-value pairs that can be nested. As values you can also have list and other key-value pairs. In general at the end of each pair you must have a comma. Exception: Trailing commas are not allowed.
  4. all opening square bracket [ and curly braces { must have a closing counterpart ] or }.

 

About the counter-exceptions from number 2: Sometimes add-on creators also require you to quote numbers. Closely look how it's done in the default config. Admittedly this does not help with BetterSearch because the alternatives here are false (unquoted) and "down" and "multiline".

The reason why numbers are sometimes quoted but in most add-on configs they are unquoted has to do with the "data type" that the add-on creator uses in their add-on, i.e. how they want to use your config. This all depends on the add-on creator's needs.

E.g. some operations like dividing only make sense for numbers. You can multiply the default height of 2 rows by 1.5. But dividing "dog" by "phone" doesn't make sense. On the other hand take the add-on "MotivAnki" from the user TheAnKing which at the moment in only available on his patreon, see here. This add-on only shows a motivational text below your deck list. By default it's a motivational quote by Gandhi. Now imagine a satanist is using Anki. Uplifting Gandhi quotes won't motivate them. Instead they prefer the number of the beast. So in the add-on config they'd set as text to dipslay "666". MotivAnki only displays your config. It doesn't "work" with your config, e.g. there are no multiplication or division on what you enter. Numbers are exactly treated as other text so it makes no sense to write additional code to handle unquoted numbers. So in the MotivAnki config everything must be quoted like "666" or "be the change you wish to see".

You as a human wouldn't need quotes to know what to do with user input. But unless a programmer invests a lot of time and work computers are dumb and don't handle ambiguity well ...