-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtypes.ts
More file actions
103 lines (85 loc) · 2.02 KB
/
types.ts
File metadata and controls
103 lines (85 loc) · 2.02 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import { DefaultTreeAdapterMap } from "parse5";
export type Element = DefaultTreeAdapterMap["element"];
export type Document = DefaultTreeAdapterMap["document"];
export type Attribute = Element["attrs"][number];
export type Node = DefaultTreeAdapterMap["node"];
export type TextNode = DefaultTreeAdapterMap["textNode"];
import { BackcompatRoot } from "./backcompat";
export interface ParserOptions {
baseUrl: string;
experimental?: {
lang?: boolean;
textContent?: boolean;
metaformats?: boolean;
authorship?: boolean;
};
}
export type ExperimentalName = keyof NonNullable<ParserOptions["experimental"]>;
export interface ParsingOptions extends ParserOptions {
implyProperties?: boolean;
idRefs: IdRefs;
inherited: {
roots: BackcompatRoot[];
lang?: string;
};
rels: Rels;
}
export interface ParsedDocument {
rels: Rels;
"rel-urls": RelUrls;
items: MicroformatRoot[];
}
export type MicroformatProperties = Record<string, MicroformatProperty[]>;
export interface MicroformatRoot {
id?: string;
lang?: string;
type?: string[];
properties: MicroformatProperties;
children?: MicroformatRoot[];
value?: MicroformatProperty;
}
export interface Author {
name?: string;
value: string;
photo?: string;
url?: string;
}
export interface Image {
alt: string;
value?: string;
}
export interface Html {
html: string;
value: string;
lang?: string;
}
export type MicroformatProperty =
| MicroformatRoot
| Author
| Image
| Html
| string;
export type Rels = Record<string, string[]>;
export type RelUrls = Record<
string,
{
rels: string[];
text: string;
title?: string;
media?: string;
hreflang?: string;
type?: string;
}
>;
export type IdRefs = Record<string, Element>;
export type PropertyType = "p" | "u" | "e" | "dt";
export interface ParsedProperty {
key: string;
value: MicroformatProperty | undefined;
type: PropertyType;
}
export interface Backcompat {
type: string[];
properties: Record<string, string>;
rels?: Record<string, string>;
}