@adobe/helix-shared-config 1.7.23 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/package.json +10 -7
- package/src/config-wrapper.js +0 -6
- package/src/index.js +0 -12
- package/src/Condition.js +0 -573
- package/src/ConfigValidator.js +0 -95
- package/src/DataEmbedValidator.js +0 -51
- package/src/DynamicRedirect.js +0 -125
- package/src/HelixConfig.js +0 -133
- package/src/MarkupConfig.js +0 -35
- package/src/Origin.js +0 -159
- package/src/Performance.js +0 -80
- package/src/Redirect.js +0 -64
- package/src/RedirectConfig.js +0 -64
- package/src/RedirectRuleHandler.js +0 -46
- package/src/Static.js +0 -119
- package/src/Strain.js +0 -332
- package/src/Strains.js +0 -68
- package/src/schemas/conditions.schema.json +0 -140
- package/src/schemas/config.description.md +0 -7
- package/src/schemas/config.example.1.json +0 -26
- package/src/schemas/config.schema.json +0 -44
- package/src/schemas/data-embed-response.schema.json +0 -40
- package/src/schemas/giturl.schema.json +0 -62
- package/src/schemas/markup.schema.json +0 -22
- package/src/schemas/markupconfig.schema.json +0 -38
- package/src/schemas/markupmapping.description.md +0 -242
- package/src/schemas/markupmapping.schema.json +0 -122
- package/src/schemas/origin.description.md +0 -5
- package/src/schemas/origin.schema.json +0 -86
- package/src/schemas/performance.schema.json +0 -210
- package/src/schemas/proxystrain.description.md +0 -20
- package/src/schemas/proxystrain.schema.json +0 -87
- package/src/schemas/redirect.schema.json +0 -34
- package/src/schemas/redirectrule.schema.json +0 -46
- package/src/schemas/redirects.description.md +0 -1
- package/src/schemas/redirects.schema.json +0 -41
- package/src/schemas/row.schema.json +0 -23
- package/src/schemas/runtimestrain.schema.json +0 -144
- package/src/schemas/sheet.schema.json +0 -57
- package/src/schemas/staticgiturl.schema.json +0 -80
- package/src/schemas/strains.schema.json +0 -39
- package/src/schemas/vanity.schema.json +0 -38
- package/src/schemas/version-lock.description.md +0 -3
- package/src/schemas/version-lock.schema.json +0 -35
- package/src/schemas/workbook.schema.json +0 -49
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta:license": [
|
|
3
|
-
"Copyright 2018 Adobe. All rights reserved.",
|
|
4
|
-
"This file is licensed to you under the Apache License, Version 2.0 (the \"License\");",
|
|
5
|
-
"you may not use this file except in compliance with the License. You may obtain a copy",
|
|
6
|
-
"of the License at http://www.apache.org/licenses/LICENSE-2.0",
|
|
7
|
-
"",
|
|
8
|
-
"Unless required by applicable law or agreed to in writing, software distributed under",
|
|
9
|
-
"the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS",
|
|
10
|
-
"OF ANY KIND, either express or implied. See the License for the specific language",
|
|
11
|
-
"governing permissions and limitations under the License."
|
|
12
|
-
],
|
|
13
|
-
"$id": "https://ns.adobe.com/helix/shared/conditions",
|
|
14
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
15
|
-
"title": "Conditions",
|
|
16
|
-
"type": "object",
|
|
17
|
-
"meta:status": "stabilizing",
|
|
18
|
-
"description": "A condition expression",
|
|
19
|
-
"additionalProperties": false,
|
|
20
|
-
"minProperties": 1,
|
|
21
|
-
"maxProperties": 1,
|
|
22
|
-
"properties": {
|
|
23
|
-
"and": {
|
|
24
|
-
"type": "array",
|
|
25
|
-
"items": { "$ref": "https://ns.adobe.com/helix/shared/conditions" },
|
|
26
|
-
"description": "All conditions in this list must be met"
|
|
27
|
-
},
|
|
28
|
-
"or": {
|
|
29
|
-
"type": "array",
|
|
30
|
-
"items": { "$ref": "https://ns.adobe.com/helix/shared/conditions" },
|
|
31
|
-
"description": "Any conditions in this list must be met"
|
|
32
|
-
},
|
|
33
|
-
"not": {
|
|
34
|
-
"$ref": "https://ns.adobe.com/helix/shared/conditions"
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
"patternProperties": {
|
|
38
|
-
"^url[=~]?$": {
|
|
39
|
-
"type": "string",
|
|
40
|
-
"description": "Matches the full URL, including request parameters"
|
|
41
|
-
},
|
|
42
|
-
"^url\\.hostname[=~]?$": {
|
|
43
|
-
"type": "string",
|
|
44
|
-
"description": "Matches the hostname only"
|
|
45
|
-
},
|
|
46
|
-
"^url\\.path[=~]?$": {
|
|
47
|
-
"type": "string",
|
|
48
|
-
"description": "Matches the path only. Path does not include the query string."
|
|
49
|
-
},
|
|
50
|
-
"^referer[=~]?$": {
|
|
51
|
-
"type": "string",
|
|
52
|
-
"description": "Matches the Referrer (note the spelling)"
|
|
53
|
-
},
|
|
54
|
-
"^client_name[=~]?$": {
|
|
55
|
-
"type": "string",
|
|
56
|
-
"description": "Matches the client's company or ISP name"
|
|
57
|
-
},
|
|
58
|
-
"^client_city[=~]?$": {
|
|
59
|
-
"type": "string",
|
|
60
|
-
"description": "Matches the client's city"
|
|
61
|
-
},
|
|
62
|
-
"^client_country_code[=~]?$": {
|
|
63
|
-
"type": "string",
|
|
64
|
-
"description": "Matches the ISO 3166-1 country code (two letters)"
|
|
65
|
-
},
|
|
66
|
-
"^user_agent[=~]?$": {
|
|
67
|
-
"type": "string",
|
|
68
|
-
"description": "Matches the User Agent"
|
|
69
|
-
},
|
|
70
|
-
"^accept_language[=~]?$": {
|
|
71
|
-
"type": "string",
|
|
72
|
-
"description": "Matches the Accept-Language header"
|
|
73
|
-
},
|
|
74
|
-
"^client_lat[<=>]?$": {
|
|
75
|
-
"type": "number",
|
|
76
|
-
"description": "Compares the latitude"
|
|
77
|
-
},
|
|
78
|
-
"^client_lon[<=>]?$": {
|
|
79
|
-
"type": "number",
|
|
80
|
-
"description": "Compares the longitude"
|
|
81
|
-
},
|
|
82
|
-
"^client_gmt_offset[<=>]?$": {
|
|
83
|
-
"type": "number",
|
|
84
|
-
"description": "UTC offset for the client's time zone. Values look like -100 or 300."
|
|
85
|
-
},
|
|
86
|
-
"^time[<=>]?$": {
|
|
87
|
-
"type": "string",
|
|
88
|
-
"format": "date-time",
|
|
89
|
-
"description": "Absolute time of the request, evaluated against UTC"
|
|
90
|
-
},
|
|
91
|
-
"^time_day[<=>]?$": {
|
|
92
|
-
"type": "number",
|
|
93
|
-
"description": "Day of the week, same as Date.getDay() – adjusted for GMT offset"
|
|
94
|
-
},
|
|
95
|
-
"^time_date[<=>]?$": {
|
|
96
|
-
"type": "number",
|
|
97
|
-
"description": "Day of the month, same as Date.getDate() – adjusted for GMT offset"
|
|
98
|
-
},
|
|
99
|
-
"^time_hours[<=>]?$": {
|
|
100
|
-
"type": "number",
|
|
101
|
-
"description": "Hour of the day, same as Date.getHours() – adjusted for GMT offset"
|
|
102
|
-
},
|
|
103
|
-
"^time_minutes[<=>]?$": {
|
|
104
|
-
"type": "number",
|
|
105
|
-
"description": "Minute of the hour, same as Date.getMinutes() – adjusted for GMT offset"
|
|
106
|
-
},
|
|
107
|
-
"^time_month[<=>]?$": {
|
|
108
|
-
"type": "number",
|
|
109
|
-
"description": "Month of the year, same as Date.getMonth() – adjusted for GMT offset"
|
|
110
|
-
},
|
|
111
|
-
"^time_year[<=>]?$": {
|
|
112
|
-
"type": "number",
|
|
113
|
-
"description": "Year, same as Date.getFullYear() – adjusted for GMT offset"
|
|
114
|
-
},
|
|
115
|
-
"^url_param\\..+[~]?$": {
|
|
116
|
-
"type": "string",
|
|
117
|
-
"description": "Matches a URL parameter's value as a string"
|
|
118
|
-
},
|
|
119
|
-
"^url_param\\..+[<>]$": {
|
|
120
|
-
"type": "number",
|
|
121
|
-
"description": "Matches a URL parameter's value as a number"
|
|
122
|
-
},
|
|
123
|
-
"^url_param\\..+[=]$": {
|
|
124
|
-
"type": ["number", "string"],
|
|
125
|
-
"description": "Matches a URL parameter's value as a number or string"
|
|
126
|
-
},
|
|
127
|
-
"^preflight\\..+[~]?$": {
|
|
128
|
-
"type": "string",
|
|
129
|
-
"description": "Matches a preflight response header value as a string"
|
|
130
|
-
},
|
|
131
|
-
"^preflight\\..+[<>]$": {
|
|
132
|
-
"type": "number",
|
|
133
|
-
"description": "Matches a preflight response header value as a number"
|
|
134
|
-
},
|
|
135
|
-
"^preflight\\..+[=]$": {
|
|
136
|
-
"type": ["number", "string"],
|
|
137
|
-
"description": "Matches a preflight response header value as a number or string"
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
The Strains configuration for a Project Helix website.
|
|
2
|
-
|
|
3
|
-
The `helix-config.yaml` file contains the list of Strains that have been configured for a Helix site.
|
|
4
|
-
|
|
5
|
-
Each strain represents a variant of the site. It is required to have a default strain for each website. A strain is either a [Runtime strain](runtimestrain.md), if it's powered by the Helix pipeline on Adobe I/O Runtime, or a [Proxy strain](proxystrain.md), if it's serving content from another host.
|
|
6
|
-
|
|
7
|
-
All strains can have [Conditions](conditions.md) that determine if a visitor is eligible to see a certain strain. If a request fulfills the conditions of multiple strains, the first eligible strain will be served. This is why order of the strains in `helix-config.yaml` is important.
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"strains": [
|
|
3
|
-
{
|
|
4
|
-
"name": "preview",
|
|
5
|
-
"owner": "adobe",
|
|
6
|
-
"repo": "project-helix.io",
|
|
7
|
-
"ref": "preview",
|
|
8
|
-
"condition": {
|
|
9
|
-
"url": "https://preview.project.helix.io/"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"name": "legacy",
|
|
14
|
-
"origin": "https://www.adobe.io/helix",
|
|
15
|
-
"condition": {
|
|
16
|
-
"url": "https://www.project.helix.io/"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"name": "default",
|
|
21
|
-
"owner": "adobe",
|
|
22
|
-
"repo": "project-helix.io",
|
|
23
|
-
"ref": "master"
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta:license": [
|
|
3
|
-
"Copyright 2018 Adobe. All rights reserved.",
|
|
4
|
-
"This file is licensed to you under the Apache License, Version 2.0 (the \"License\");",
|
|
5
|
-
"you may not use this file except in compliance with the License. You may obtain a copy",
|
|
6
|
-
"of the License at http://www.apache.org/licenses/LICENSE-2.0",
|
|
7
|
-
"",
|
|
8
|
-
"Unless required by applicable law or agreed to in writing, software distributed under",
|
|
9
|
-
"the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS",
|
|
10
|
-
"OF ANY KIND, either express or implied. See the License for the specific language",
|
|
11
|
-
"governing permissions and limitations under the License."
|
|
12
|
-
],
|
|
13
|
-
"$id": "https://ns.adobe.com/helix/shared/config",
|
|
14
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
15
|
-
"title": "Configuration",
|
|
16
|
-
"type": "object",
|
|
17
|
-
"meta:status": "stabilizing",
|
|
18
|
-
"description": "A Configuration File for Project Helix.",
|
|
19
|
-
"additionalProperties": false,
|
|
20
|
-
"properties": {
|
|
21
|
-
"definitions": {
|
|
22
|
-
"type": "object",
|
|
23
|
-
"description": "A container for referencable objects that can be re-used elsewhere in the configuration."
|
|
24
|
-
},
|
|
25
|
-
"version": {
|
|
26
|
-
"type":["string", "number"],
|
|
27
|
-
"enum": ["1", 1],
|
|
28
|
-
"default": 1,
|
|
29
|
-
"description": "The helix-config file format version"
|
|
30
|
-
},
|
|
31
|
-
"strains": {
|
|
32
|
-
"$ref": "https://ns.adobe.com/helix/shared/strains"
|
|
33
|
-
},
|
|
34
|
-
"preflight": {
|
|
35
|
-
"type": "string",
|
|
36
|
-
"format": "uri",
|
|
37
|
-
"pattern": "^https://adobeioruntime\\.net/|^https://[^.]*\\.anywhere\\.run/",
|
|
38
|
-
"description": "The URL of a preflight check that should be performed before assigning a strain to a request. The headers returned by this preflight request can be used in strain conditions."
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"required": [
|
|
42
|
-
"strains"
|
|
43
|
-
]
|
|
44
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta:license": [
|
|
3
|
-
"Copyright 2021 Adobe. All rights reserved.",
|
|
4
|
-
"This file is licensed to you under the Apache License, Version 2.0 (the \"License\");",
|
|
5
|
-
"you may not use this file except in compliance with the License. You may obtain a copy",
|
|
6
|
-
"of the License at http://www.apache.org/licenses/LICENSE-2.0",
|
|
7
|
-
"",
|
|
8
|
-
"Unless required by applicable law or agreed to in writing, software distributed under",
|
|
9
|
-
"the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS",
|
|
10
|
-
"OF ANY KIND, either express or implied. See the License for the specific language",
|
|
11
|
-
"governing permissions and limitations under the License."
|
|
12
|
-
],
|
|
13
|
-
"$id": "https://ns.adobe.com/helix/data-embed/response",
|
|
14
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
15
|
-
"title": "Response",
|
|
16
|
-
"type": "object",
|
|
17
|
-
"meta:status": "stabilizing",
|
|
18
|
-
"description": "The Helix Data Embed Response format",
|
|
19
|
-
"allOf": [
|
|
20
|
-
{
|
|
21
|
-
"oneOf": [
|
|
22
|
-
{ "$ref": "https://ns.adobe.com/helix/data-embed/sheet" },
|
|
23
|
-
{ "$ref": "https://ns.adobe.com/helix/data-embed/workbook" }
|
|
24
|
-
]
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
":version": {
|
|
28
|
-
"type": "number",
|
|
29
|
-
"enum": [3],
|
|
30
|
-
"default": 3,
|
|
31
|
-
"description": "The workbook response format version"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
],
|
|
35
|
-
"required": [
|
|
36
|
-
":version",
|
|
37
|
-
":type"
|
|
38
|
-
],
|
|
39
|
-
"minProperties": 4
|
|
40
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta:license": [
|
|
3
|
-
"Copyright 2018 Adobe. All rights reserved.",
|
|
4
|
-
"This file is licensed to you under the Apache License, Version 2.0 (the \"License\");",
|
|
5
|
-
"you may not use this file except in compliance with the License. You may obtain a copy",
|
|
6
|
-
"of the License at http://www.apache.org/licenses/LICENSE-2.0",
|
|
7
|
-
"",
|
|
8
|
-
"Unless required by applicable law or agreed to in writing, software distributed under",
|
|
9
|
-
"the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS",
|
|
10
|
-
"OF ANY KIND, either express or implied. See the License for the specific language",
|
|
11
|
-
"governing permissions and limitations under the License."
|
|
12
|
-
],
|
|
13
|
-
"$id": "https://ns.adobe.com/helix/shared/giturl",
|
|
14
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
15
|
-
"title": "Git URL",
|
|
16
|
-
"type": "object",
|
|
17
|
-
"meta:status": "stabilizing",
|
|
18
|
-
"description": "Representation of the fragments of a Git URL",
|
|
19
|
-
"additionalProperties": false,
|
|
20
|
-
"properties": {
|
|
21
|
-
"protocol": {
|
|
22
|
-
"description": "The protocol to access the Git repository",
|
|
23
|
-
"enum": ["https", "http", "ssh"],
|
|
24
|
-
"type":"string"
|
|
25
|
-
},
|
|
26
|
-
"hostname": {
|
|
27
|
-
"description": "The hostname without port",
|
|
28
|
-
"type":"string",
|
|
29
|
-
"format": "hostname"
|
|
30
|
-
},
|
|
31
|
-
"host": {
|
|
32
|
-
"description": "The hostname with port",
|
|
33
|
-
"type":"string"
|
|
34
|
-
},
|
|
35
|
-
"port": {
|
|
36
|
-
"description": "The port to access the Git Repository",
|
|
37
|
-
"type":["integer", "string"]
|
|
38
|
-
},
|
|
39
|
-
"owner": {
|
|
40
|
-
"description": "The owner or username that the repository belongs to",
|
|
41
|
-
"type":"string"
|
|
42
|
-
},
|
|
43
|
-
"path": {
|
|
44
|
-
"description": "The path within the repository",
|
|
45
|
-
"type":"string"
|
|
46
|
-
},
|
|
47
|
-
"repo": {
|
|
48
|
-
"description": "The repository name",
|
|
49
|
-
"type":"string"
|
|
50
|
-
},
|
|
51
|
-
"ref": {
|
|
52
|
-
"description": "The branch, tag, or sha of the tree in the repository to use",
|
|
53
|
-
"default": "master",
|
|
54
|
-
"type":"string"
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
"required": [
|
|
58
|
-
"owner",
|
|
59
|
-
"repo",
|
|
60
|
-
"ref"
|
|
61
|
-
]
|
|
62
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta:license": [
|
|
3
|
-
"Copyright 2019 Adobe. All rights reserved.",
|
|
4
|
-
"This file is licensed to you under the Apache License, Version 2.0 (the \"License\");",
|
|
5
|
-
"you may not use this file except in compliance with the License. You may obtain a copy",
|
|
6
|
-
"of the License at http://www.apache.org/licenses/LICENSE-2.0",
|
|
7
|
-
"",
|
|
8
|
-
"Unless required by applicable law or agreed to in writing, software distributed under",
|
|
9
|
-
"the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS",
|
|
10
|
-
"OF ANY KIND, either express or implied. See the License for the specific language",
|
|
11
|
-
"governing permissions and limitations under the License."
|
|
12
|
-
],
|
|
13
|
-
"$id": "https://ns.adobe.com/helix/shared/markup",
|
|
14
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
15
|
-
"title": "Markup Configuration",
|
|
16
|
-
"type": "object",
|
|
17
|
-
"meta:status": "stabilizing",
|
|
18
|
-
"description": "A container for markup mappings. Each markup mapping is a named key.",
|
|
19
|
-
"additionalProperties": {
|
|
20
|
-
"$ref": "https://ns.adobe.com/helix/shared/markupmapping"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta:license": [
|
|
3
|
-
"Copyright 2019 Adobe. All rights reserved.",
|
|
4
|
-
"This file is licensed to you under the Apache License, Version 2.0 (the \"License\");",
|
|
5
|
-
"you may not use this file except in compliance with the License. You may obtain a copy",
|
|
6
|
-
"of the License at http://www.apache.org/licenses/LICENSE-2.0",
|
|
7
|
-
"",
|
|
8
|
-
"Unless required by applicable law or agreed to in writing, software distributed under",
|
|
9
|
-
"the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS",
|
|
10
|
-
"OF ANY KIND, either express or implied. See the License for the specific language",
|
|
11
|
-
"governing permissions and limitations under the License."
|
|
12
|
-
],
|
|
13
|
-
"$id": "https://ns.adobe.com/helix/shared/markupconfig",
|
|
14
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
15
|
-
"title": "Configuration",
|
|
16
|
-
"type": "object",
|
|
17
|
-
"meta:status": "stabilizing",
|
|
18
|
-
"description": "A Markup Configuration File for Project Helix.",
|
|
19
|
-
"additionalProperties": false,
|
|
20
|
-
"properties": {
|
|
21
|
-
"definitions": {
|
|
22
|
-
"type": "object",
|
|
23
|
-
"description": "A container for referencable objects that can be re-used elsewhere in the configuration."
|
|
24
|
-
},
|
|
25
|
-
"version": {
|
|
26
|
-
"type":["string", "number"],
|
|
27
|
-
"enum": ["1", 1],
|
|
28
|
-
"default": 1,
|
|
29
|
-
"description": "The helix-config file format version"
|
|
30
|
-
},
|
|
31
|
-
"markup": {
|
|
32
|
-
"$ref": "https://ns.adobe.com/helix/shared/markup"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"required": [
|
|
36
|
-
"markup"
|
|
37
|
-
]
|
|
38
|
-
}
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
A markup mapping defines how Helix should generate markup for certain Markdown or DOM patterns.
|
|
2
|
-
|
|
3
|
-
A configuration consits of a mandatory `match` expression, which is a matching expression that works differently depending on the value of the `type` attribute.
|
|
4
|
-
|
|
5
|
-
- If `type=html`, then `match` is a CSS selector that operates on the generated HTML
|
|
6
|
-
- If `type=markdown`, then `match` is a CSS selector that operates on the source Markdown
|
|
7
|
-
- If `type=url`, then `match` is a URL path expression
|
|
8
|
-
- If `type=content`, then `match` is a content intelligence expression that selects sections based on the order of their children
|
|
9
|
-
|
|
10
|
-
Furthermore, a configuration can have any number of actions (including none at all), for example:
|
|
11
|
-
|
|
12
|
-
- `wrap`: adds more HTML elements around the generated HTML
|
|
13
|
-
- `replace`: replaces the generated HTML with the provided markup
|
|
14
|
-
- `classnames` adds `class` attribute values into the generated HTML element
|
|
15
|
-
- `attribute` adds other attributes and values into the generated HTML element
|
|
16
|
-
|
|
17
|
-
## Referencing AST values
|
|
18
|
-
|
|
19
|
-
In the `wrap` and `replace` expressions you can use pattern expressions like `wrap: pre.zupp[data-embed="${url}"]` inside the Emmet syntax, allowing you to reference properties of the matched MDAST or DOM node.
|
|
20
|
-
|
|
21
|
-
## Examples
|
|
22
|
-
|
|
23
|
-
### On the DOM tree
|
|
24
|
-
|
|
25
|
-
The most intuitive usage for most developers will be directly operating on the resulting DOM tree.
|
|
26
|
-
The `match` method just takes a regular CSS selector and then applies the desired markup on the resulting element.
|
|
27
|
-
|
|
28
|
-
#### Adding a class
|
|
29
|
-
|
|
30
|
-
`index.md`
|
|
31
|
-
```markdown
|
|
32
|
-
# Lorem ipsum dolor sit amet
|
|
33
|
-
|
|
34
|
-
consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
|
|
35
|
-
|
|
36
|
-

|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
`helix-markup.yaml`
|
|
40
|
-
```yaml
|
|
41
|
-
version: 1
|
|
42
|
-
markup:
|
|
43
|
-
foo:
|
|
44
|
-
match: p
|
|
45
|
-
classnames:
|
|
46
|
-
- foo
|
|
47
|
-
type: html
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
`index.html`
|
|
51
|
-
```html
|
|
52
|
-
<h1>Lorem ipsum dolor sit amet</h1>
|
|
53
|
-
<p class="foo">consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p>
|
|
54
|
-
<img src="http://dolor.sit/amet.jpeg" alt="Lorem ipsum"/>
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
#### Adding an attribute
|
|
58
|
-
|
|
59
|
-
`index.md`
|
|
60
|
-
```markdown
|
|
61
|
-
# Lorem ipsum dolor sit amet
|
|
62
|
-
|
|
63
|
-
consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
|
|
64
|
-
|
|
65
|
-

|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
`helix-markup.yaml`
|
|
69
|
-
```yaml
|
|
70
|
-
version: 1
|
|
71
|
-
markup:
|
|
72
|
-
foo:
|
|
73
|
-
match: p
|
|
74
|
-
attribute:
|
|
75
|
-
bar: baz
|
|
76
|
-
type: html
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
`index.html`
|
|
80
|
-
```html
|
|
81
|
-
<h1>Lorem ipsum dolor sit amet</h1>
|
|
82
|
-
<p bar="baz">consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p>
|
|
83
|
-
<img src="http://dolor.sit/amet.jpeg" alt="Lorem ipsum"/>
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
#### Wrapping with another element
|
|
87
|
-
|
|
88
|
-
`index.md`
|
|
89
|
-
```markdown
|
|
90
|
-
# Lorem ipsum dolor sit amet
|
|
91
|
-
|
|
92
|
-
consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
|
|
93
|
-
|
|
94
|
-

|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
`helix-markup.yaml`
|
|
98
|
-
```yaml
|
|
99
|
-
version: 1
|
|
100
|
-
markup:
|
|
101
|
-
foo:
|
|
102
|
-
match: p
|
|
103
|
-
wrap: section.qux
|
|
104
|
-
type: html
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
`index.html`
|
|
108
|
-
```html
|
|
109
|
-
<h1>Lorem ipsum dolor sit amet</h1>
|
|
110
|
-
<section class="qux">
|
|
111
|
-
<p>consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p>
|
|
112
|
-
</section>
|
|
113
|
-
<img src="http://dolor.sit/amet.jpeg" alt="Lorem ipsum"/>
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### On the Markdown abstract tree
|
|
117
|
-
|
|
118
|
-
As an alternative, it is also possible to directly operate on the Markdown abstract syntax tree before it is converted to HTML. This is especially useful if you are heavily modifying the markup via the `*.pre.js` and need to already annotate your tree before processing. The `match` property takes a CSS like selector, but instead of DOM elements, you are targeting [MDAST nodes](https://github.com/syntax-tree/mdast#nodes).
|
|
119
|
-
|
|
120
|
-
#### Adding a class
|
|
121
|
-
|
|
122
|
-
`index.md`
|
|
123
|
-
```markdown
|
|
124
|
-
# Lorem ipsum dolor sit amet
|
|
125
|
-
|
|
126
|
-
consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
|
|
127
|
-
|
|
128
|
-

|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
`helix-markup.yaml`
|
|
132
|
-
```yaml
|
|
133
|
-
version: 1
|
|
134
|
-
markup:
|
|
135
|
-
foo:
|
|
136
|
-
match: paragraph
|
|
137
|
-
classnames:
|
|
138
|
-
- foo
|
|
139
|
-
type: markdown
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
`index.html`
|
|
143
|
-
```html
|
|
144
|
-
<h1>Lorem ipsum dolor sit amet</h1>
|
|
145
|
-
<p class="foo">consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p>
|
|
146
|
-
<img src="http://dolor.sit/amet.jpeg" alt="Lorem ipsum"/>
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
#### Adding an attribute
|
|
150
|
-
|
|
151
|
-
`index.md`
|
|
152
|
-
```markdown
|
|
153
|
-
# Lorem ipsum dolor sit amet
|
|
154
|
-
|
|
155
|
-
consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
|
|
156
|
-
|
|
157
|
-

|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
`helix-markup.yaml`
|
|
161
|
-
```yaml
|
|
162
|
-
version: 1
|
|
163
|
-
markup:
|
|
164
|
-
foo:
|
|
165
|
-
match: paragraph
|
|
166
|
-
attribute:
|
|
167
|
-
bar: baz
|
|
168
|
-
type: markdown
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
`index.html`
|
|
172
|
-
```html
|
|
173
|
-
<h1>Lorem ipsum dolor sit amet</h1>
|
|
174
|
-
<p bar="baz">consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p>
|
|
175
|
-
<img src="http://dolor.sit/amet.jpeg" alt="Lorem ipsum"/>
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
#### Wrapping with another element
|
|
179
|
-
|
|
180
|
-
`index.md`
|
|
181
|
-
```markdown
|
|
182
|
-
# Lorem ipsum dolor sit amet
|
|
183
|
-
|
|
184
|
-
consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
|
|
185
|
-
|
|
186
|
-

|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
`helix-markup.yaml`
|
|
190
|
-
```yaml
|
|
191
|
-
version: 1
|
|
192
|
-
markup:
|
|
193
|
-
foo:
|
|
194
|
-
match: paragraph
|
|
195
|
-
wrap: section.qux
|
|
196
|
-
type: markdown
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
`index.html`
|
|
200
|
-
```html
|
|
201
|
-
<h1>Lorem ipsum dolor sit amet</h1>
|
|
202
|
-
<section class="qux">
|
|
203
|
-
<p>consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p>
|
|
204
|
-
</section>
|
|
205
|
-
<img src="http://dolor.sit/amet.jpeg" alt="Lorem ipsum"/>
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
### Mixed
|
|
209
|
-
|
|
210
|
-
For the sake of completeness, we provide here an example of mixed rules
|
|
211
|
-
|
|
212
|
-
`index.md`
|
|
213
|
-
```markdown
|
|
214
|
-
# Lorem ipsum dolor sit amet
|
|
215
|
-
|
|
216
|
-
consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
|
|
217
|
-
|
|
218
|
-

|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
`helix-markup.yaml`
|
|
222
|
-
```yaml
|
|
223
|
-
version: 1
|
|
224
|
-
markup:
|
|
225
|
-
foo:
|
|
226
|
-
match: paragraph
|
|
227
|
-
classnames:
|
|
228
|
-
- foo
|
|
229
|
-
type: markdown
|
|
230
|
-
bar:
|
|
231
|
-
match: p
|
|
232
|
-
attribute:
|
|
233
|
-
bar: baz
|
|
234
|
-
type: html
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
`index.html`
|
|
238
|
-
```html
|
|
239
|
-
<h1>Lorem ipsum dolor sit amet</h1>
|
|
240
|
-
<p class="foo" bar="baz">consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p>
|
|
241
|
-
<img src="http://dolor.sit/amet.jpeg" alt="Lorem ipsum"/>
|
|
242
|
-
```
|