-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathindex.d.ts
79 lines (62 loc) · 1.75 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import {type HTMLAttributes} from 'create-html-element';
export type Options = {
/**
HTML attributes to add to the link.
*/
readonly attributes?: HTMLAttributes;
/**
Set a custom HTML value for the link.
Default: The URL.
@example
```
import {linkifyUrlsToHtml} from 'linkify-urls';
linkifyUrlsToHtml('See https://sindresorhus.com/foo', {
value: url => new URL(url).pathname
});
//=> 'See <a href="https://sindresorhus.com/foo">/foo</a>'
```
*/
readonly value?: string | ((url: string) => string);
};
/**
Linkify URLs in a string, returns an HTML string.
@param string - A string with URLs to linkify.
@returns An HTML string like `'Visit <a href="https://example.com">https://example.com</a>'`.
@example
```
import {linkifyUrlsToHtml} from 'linkify-urls';
linkifyUrlsToHtml('See https://sindresorhus.com', {
attributes: {
class: 'unicorn',
one: 1,
foo: true,
multiple: ['a', 'b']
}
});
//=> 'See <a href="https://sindresorhus.com" class="unicorn" one="1" foo multiple="a b">https://sindresorhus.com</a>'
```
*/
export function linkifyUrlsToHtml(
string: string,
options?: Options
): string;
/**
Linkify URLs in a string, returns a `DocumentFragment`.
@param string - A string with URLs to linkify.
@returns a `DocumentFragment` ready to be appended in a DOM safely, like `DocumentFragment(TextNode('Visit '), HTMLAnchorElement('https://example.com'))`. This type only works in the browser.
@example
```
import {linkifyUrlsToDom} from 'linkify-urls';
const fragment = linkifyUrlsToDom('See https://sindresorhus.com', {
attributes: {
class: 'unicorn',
}
});
document.body.appendChild(fragment);
```
*/
export function linkifyUrlsToDom(
string: string,
options?: Options
): DocumentFragment;
export {HTMLAttributes} from 'create-html-element';