-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(js): document highlighting utils
- Loading branch information
1 parent
00e2227
commit f97a0fb
Showing
5 changed files
with
213 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
id: highlightItem | ||
--- | ||
|
||
Returns a string with highlighted and escaped matching parts of an Algolia hit. | ||
|
||
# Example | ||
|
||
```js | ||
import { highlightItem } from '@algolia/autocomplete-js'; | ||
|
||
const item = {}; // fetch an Algolia hit | ||
const highlightedValue = highlightItem({ | ||
item, | ||
attribute: 'query', | ||
}); | ||
``` | ||
|
||
# Reference | ||
|
||
## Params | ||
|
||
### `item` | ||
|
||
> `AlgoliaHit` | required | ||
The Algolia hit to retrieve the attribute value from. | ||
|
||
### `attribute` | ||
|
||
> `string` | required | ||
The attribute to retrieve the highlight value from. | ||
|
||
### `highlightPreTag` | ||
|
||
> `string` | defaults to `<mark>` | ||
The HTML tag to prefix the value with. | ||
|
||
### `highlightPostTag` | ||
|
||
> `string` | defaults to `</mark>` | ||
The HTML tag to suffix the value with. | ||
|
||
### `ignoreEscape` | ||
|
||
> `string[]` | defaults to `[]` | ||
The characters to skip from escaping. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
id: reverseHighlightItem | ||
--- | ||
|
||
Returns a string with highlighted and escaped non-matching parts of an Algolia hit. | ||
|
||
# Example | ||
|
||
```js | ||
import { reverseHighlightItem } from '@algolia/autocomplete-js'; | ||
|
||
const item = {}; // fetch an Algolia hit | ||
const highlightedValue = reverseHighlightItem({ | ||
item, | ||
attribute: 'query', | ||
}); | ||
``` | ||
|
||
# Reference | ||
|
||
## Params | ||
|
||
### `item` | ||
|
||
> `AlgoliaHit` | required | ||
The Algolia hit to retrieve the attribute value from. | ||
|
||
### `attribute` | ||
|
||
> `string` | required | ||
The attribute to retrieve the highlight value from. | ||
|
||
### `highlightPreTag` | ||
|
||
> `string` | defaults to `<mark>` | ||
The HTML tag to prefix the value with. | ||
|
||
### `highlightPostTag` | ||
|
||
> `string` | defaults to `</mark>` | ||
The HTML tag to suffix the value with. | ||
|
||
### `ignoreEscape` | ||
|
||
> `string[]` | defaults to `[]` | ||
The characters to skip from escaping. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
id: reverseSnippetItem | ||
--- | ||
|
||
Returns a string with highlighted and escaped non-matching parts of an Algolia hit snippet. | ||
|
||
# Example | ||
|
||
```js | ||
import { reverseSnippetItem } from '@algolia/autocomplete-js'; | ||
|
||
const item = {}; // fetch an Algolia hit | ||
const reverseSnippetedValue = reverseSnippetItem({ | ||
item, | ||
attribute: 'query', | ||
}); | ||
``` | ||
|
||
# Reference | ||
|
||
## Params | ||
|
||
### `item` | ||
|
||
> `AlgoliaHit` | required | ||
The Algolia hit to retrieve the attribute value from. | ||
|
||
### `attribute` | ||
|
||
> `string` | required | ||
The attribute to retrieve the snippet value from. | ||
|
||
### `highlightPreTag` | ||
|
||
> `string` | defaults to `<mark>` | ||
The HTML tag to prefix the value with. | ||
|
||
### `highlightPostTag` | ||
|
||
> `string` | defaults to `</mark>` | ||
The HTML tag to suffix the value with. | ||
|
||
### `ignoreEscape` | ||
|
||
> `string[]` | defaults to `[]` | ||
The characters to skip from escaping. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
id: snippetItem | ||
--- | ||
|
||
Returns a string with highlighted and escaped matching parts of an Algolia hit snippet. | ||
|
||
# Example | ||
|
||
```js | ||
import { snippetItem } from '@algolia/autocomplete-js'; | ||
|
||
const item = {}; // fetch an Algolia hit | ||
const snippetedValue = snippetItem({ | ||
item, | ||
attribute: 'query', | ||
}); | ||
``` | ||
|
||
# Reference | ||
|
||
## Params | ||
|
||
### `item` | ||
|
||
> `AlgoliaHit` | required | ||
The Algolia hit to retrieve the attribute value from. | ||
|
||
### `attribute` | ||
|
||
> `string` | required | ||
The attribute to retrieve the snippet value from. | ||
|
||
### `highlightPreTag` | ||
|
||
> `string` | defaults to `<mark>` | ||
The HTML tag to prefix the value with. | ||
|
||
### `highlightPostTag` | ||
|
||
> `string` | defaults to `</mark>` | ||
The HTML tag to suffix the value with. | ||
|
||
### `ignoreEscape` | ||
|
||
> `string[]` | defaults to `[]` | ||
The characters to skip from escaping. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters