Updated Definition format (markdown)

garfield69 2023-04-06 07:57:14 +12:00
parent e1820be511
commit 9eba2522d3
1 changed files with 37 additions and 21 deletions

@ -619,9 +619,9 @@ After that the selector specified in the `remove` keyword is applied. With this,
Now it's possible to set the value based on the existence of elements using the `case` keyword. If the corresponding selector matches the field value is set to the specified case value. Processing ends after the first case selector matches. This is commonly used for `downloadvolumefactor` and `uploadvolumefactor`.
Finally, the resulting value will be processed by the template engine and filter engine (see below).
#### Providing the category field with a default value
#### Providing fields with a default value
In the event that you need to provide a default category due to the possibility that a site may not provide one consistently, you have several options you can use, either the `default` statement or the `noappend` modifier, as shown in these examples:
In the event that a field might not be reliably present from the site results, you can use the `default` statement, as shown in these examples:
```yaml
category:
@ -632,25 +632,6 @@ In the event that you need to provide a default category due to the possibility
filters:
- name: querystring
args: cat
```
```yaml
category:
text: Other
category|noappend:
# try category=
optional: true
selector: a.label[href*="category="]
category|noappend:
# try type=
optional: true
selector: a.label[href*="type="]
```
#### Providing other fields with a default value
In the event that a field (other than category) might not be reliably present from the site results, you can use the `default` statement, as shown in these examples:
```yaml
title_default:
# this title may be abbreviated
selector: a[href^="details.php?id="]
@ -666,6 +647,41 @@ In the event that a field (other than category) might not be reliably present fr
optional: true
default: 0
```
Note that the use of the `noappend` modifier is deprecated for the category field.
So if you have an old category block like
```yaml
category:
selector: td:nth-child(1)
optional: true
filters:
- name: replace
args: ["---", 4]
category|noappend:
selector: a[href^="browse.php?cat="]
attribute: href
optional: true
filters:
- name: querystring
args: cat
```
then you will see warnings on your log, and you should covert to
```yaml
category_default:
selector: td:nth-child(1)
optional: true
filters:
- name: replace
args: ["---", 4]
category:
selector: a[href^="browse.php?cat="]
attribute: href
optional: true
default: "{{ .Result.category_default }}"
filters:
- name: querystring
args: cat
```
as at some point support for the category:noappend will be removed.
### Search JSON