@adobe/helix-html-pipeline 6.6.0 → 6.7.0
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 +14 -0
- package/package.json +4 -4
- package/src/html-pipe.js +0 -2
- package/src/steps/fix-sections.js +0 -5
- package/src/steps/get-metadata.js +3 -8
- package/src/steps/parse-markdown.js +1 -10
- package/src/steps/split-sections.js +3 -11
- package/src/utils/section-handler.js +1 -52
- package/src/steps/removeHlxProps.js +0 -33
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [6.7.0](https://github.com/adobe/helix-html-pipeline/compare/v6.6.1...v6.7.0) (2024-03-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* remove front- and mid-matter support ([#546](https://github.com/adobe/helix-html-pipeline/issues/546)) ([a1ad474](https://github.com/adobe/helix-html-pipeline/commit/a1ad4744b32acf64b23ca5b08a2a4ba3a7e0b672)), closes [#396](https://github.com/adobe/helix-html-pipeline/issues/396)
|
|
7
|
+
|
|
8
|
+
## [6.6.1](https://github.com/adobe/helix-html-pipeline/compare/v6.6.0...v6.6.1) (2024-02-28)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** update adobe fixes ([#549](https://github.com/adobe/helix-html-pipeline/issues/549)) ([bae49e1](https://github.com/adobe/helix-html-pipeline/commit/bae49e12802176d386fd12453ebd84b7a443b0e0))
|
|
14
|
+
|
|
1
15
|
# [6.6.0](https://github.com/adobe/helix-html-pipeline/compare/v6.5.0...v6.6.0) (2024-02-21)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-html-pipeline",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.7.0",
|
|
4
4
|
"description": "Helix HTML Pipeline",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@adobe/helix-markdown-support": "7.1.0",
|
|
47
47
|
"@adobe/helix-shared-utils": "3.0.1",
|
|
48
|
-
"@adobe/mdast-util-gridtables": "4.0.
|
|
49
|
-
"@adobe/remark-gridtables": "3.0.
|
|
48
|
+
"@adobe/mdast-util-gridtables": "4.0.1",
|
|
49
|
+
"@adobe/remark-gridtables": "3.0.1",
|
|
50
50
|
"cookie": "0.6.0",
|
|
51
51
|
"github-slugger": "2.0.0",
|
|
52
52
|
"hast-util-raw": "9.0.2",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"@semantic-release/git": "10.0.1",
|
|
79
79
|
"@semantic-release/npm": "11.0.2",
|
|
80
80
|
"c8": "9.1.0",
|
|
81
|
-
"eslint": "8.
|
|
81
|
+
"eslint": "8.57.0",
|
|
82
82
|
"eslint-import-resolver-exports": "1.0.0-beta.5",
|
|
83
83
|
"eslint-plugin-header": "3.1.1",
|
|
84
84
|
"eslint-plugin-import": "2.29.1",
|
package/src/html-pipe.js
CHANGED
|
@@ -23,7 +23,6 @@ import folderMapping from './steps/folder-mapping.js';
|
|
|
23
23
|
import getMetadata from './steps/get-metadata.js';
|
|
24
24
|
import html from './steps/make-html.js';
|
|
25
25
|
import parseMarkdown from './steps/parse-markdown.js';
|
|
26
|
-
import removeHlxProps from './steps/removeHlxProps.js';
|
|
27
26
|
import render from './steps/render.js';
|
|
28
27
|
import renderCode from './steps/render-code.js';
|
|
29
28
|
import rewriteUrls from './steps/rewrite-urls.js';
|
|
@@ -171,7 +170,6 @@ export async function htmlPipe(state, req) {
|
|
|
171
170
|
await extractMetaData(state, req);
|
|
172
171
|
await addHeadingIds(state);
|
|
173
172
|
await render(state, req, res);
|
|
174
|
-
await removeHlxProps(state, req, res);
|
|
175
173
|
state.timer?.update('serialize');
|
|
176
174
|
await tohtml(state, req, res);
|
|
177
175
|
}
|
|
@@ -25,11 +25,6 @@ export default async function fixSections({ content }) {
|
|
|
25
25
|
// if there are no sections wrap everything in a div with appropriate class names from meta
|
|
26
26
|
if ($sections.length === 0) {
|
|
27
27
|
const $outerDiv = h('div');
|
|
28
|
-
if (content.meta && content.meta.class) {
|
|
29
|
-
$outerDiv.properties.className = content.meta.class.split(/[ ,]/)
|
|
30
|
-
.map((c) => c.trim())
|
|
31
|
-
.filter((c) => !!c);
|
|
32
|
-
}
|
|
33
28
|
wrapContent($outerDiv, hast);
|
|
34
29
|
}
|
|
35
30
|
}
|
|
@@ -13,9 +13,8 @@ import { select, selectAll } from 'unist-util-select';
|
|
|
13
13
|
import { toString as plain } from 'mdast-util-to-string';
|
|
14
14
|
import { rewriteUrl } from './utils.js';
|
|
15
15
|
|
|
16
|
-
function
|
|
17
|
-
section.meta =
|
|
18
|
-
.reduce((prev, { payload }) => Object.assign(prev, payload), Object.create(null));
|
|
16
|
+
function init(section) {
|
|
17
|
+
section.meta = {};
|
|
19
18
|
return section;
|
|
20
19
|
}
|
|
21
20
|
|
|
@@ -83,10 +82,6 @@ function sectiontype(section) {
|
|
|
83
82
|
|
|
84
83
|
node.meta = { types: [], ...node.meta };
|
|
85
84
|
|
|
86
|
-
if (type === 'yaml') {
|
|
87
|
-
return counter;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
85
|
const mycounter = {};
|
|
91
86
|
|
|
92
87
|
if (type === 'paragraph' && pChildren && pChildren.length > 0) {
|
|
@@ -156,7 +151,7 @@ export default function getMetadata(state) {
|
|
|
156
151
|
sections = [content.mdast];
|
|
157
152
|
}
|
|
158
153
|
|
|
159
|
-
[
|
|
154
|
+
[init, title, intro, image, sectiontype, fallback].forEach((fn) => {
|
|
160
155
|
sections.forEach((section) => fn(section, state));
|
|
161
156
|
});
|
|
162
157
|
|
|
@@ -13,30 +13,21 @@ import { unified } from 'unified';
|
|
|
13
13
|
import remarkParse from 'remark-parse';
|
|
14
14
|
import { removePosition } from 'unist-util-remove-position';
|
|
15
15
|
import { dereference, remarkGfmNoLink } from '@adobe/helix-markdown-support';
|
|
16
|
-
import { remarkMatter } from '@adobe/helix-markdown-support/matter';
|
|
17
16
|
import remarkGridTable from '@adobe/remark-gridtables';
|
|
18
17
|
|
|
19
|
-
export class FrontmatterParsingError extends Error {
|
|
20
|
-
}
|
|
21
|
-
|
|
22
18
|
/**
|
|
23
19
|
* Parses the markdown body
|
|
24
20
|
* @type PipelineStep
|
|
25
21
|
* @param {PipelineState} state
|
|
26
22
|
*/
|
|
27
23
|
export default function parseMarkdown(state) {
|
|
28
|
-
const {
|
|
24
|
+
const { content } = state;
|
|
29
25
|
|
|
30
26
|
// convert linebreaks
|
|
31
27
|
const converted = content.data.replace(/(\r\n|\n|\r)/gm, '\n');
|
|
32
28
|
content.mdast = unified()
|
|
33
29
|
.use(remarkParse)
|
|
34
30
|
.use(remarkGfmNoLink)
|
|
35
|
-
.use(remarkMatter, {
|
|
36
|
-
errorHandler: (e) => {
|
|
37
|
-
log.warn(new FrontmatterParsingError(e));
|
|
38
|
-
},
|
|
39
|
-
})
|
|
40
31
|
.use(remarkGridTable)
|
|
41
32
|
.parse(converted);
|
|
42
33
|
|
|
@@ -9,12 +9,6 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
import { selectAll } from 'unist-util-select';
|
|
13
|
-
|
|
14
|
-
// Compute the meta information for the section
|
|
15
|
-
function computeMeta(section) {
|
|
16
|
-
return selectAll('yaml', section).reduce((prev, { payload }) => Object.assign(prev, payload), Object.create(null));
|
|
17
|
-
}
|
|
18
12
|
|
|
19
13
|
/**
|
|
20
14
|
* Splits the sections in the mdast tree
|
|
@@ -24,8 +18,8 @@ function computeMeta(section) {
|
|
|
24
18
|
export default function split(state) {
|
|
25
19
|
const { content: { mdast } } = state;
|
|
26
20
|
|
|
27
|
-
// filter all children that are
|
|
28
|
-
const dividers = mdast.children.filter((node) => node.type === '
|
|
21
|
+
// filter all children that are break blocks
|
|
22
|
+
const dividers = mdast.children.filter((node) => node.type === 'thematicBreak')
|
|
29
23
|
// then get their index in the list of children
|
|
30
24
|
.map((node) => mdast.children.indexOf(node));
|
|
31
25
|
|
|
@@ -42,12 +36,10 @@ export default function split(state) {
|
|
|
42
36
|
.map(([start, end]) => {
|
|
43
37
|
// skip 'thematicBreak' nodes
|
|
44
38
|
const index = mdast.children[start].type === 'thematicBreak' ? start + 1 : start;
|
|
45
|
-
|
|
39
|
+
return {
|
|
46
40
|
type: 'section',
|
|
47
41
|
children: mdast.children.slice(index, end),
|
|
48
42
|
};
|
|
49
|
-
section.meta = computeMeta(section);
|
|
50
|
-
return section;
|
|
51
43
|
});
|
|
52
44
|
|
|
53
45
|
// unwrap sole section directly on the root
|
|
@@ -9,65 +9,14 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
const HELIX_NAMESPACE = 'hlx-';
|
|
13
|
-
const DEFAULT_SECTION_TAG = 'div';
|
|
14
|
-
const DEFAULT_SECTION_CLASS = `${HELIX_NAMESPACE}section`;
|
|
15
|
-
const SYSTEM_META_PROPERTIES = ['tagname'];
|
|
16
|
-
const SYSTEM_HTML_ATTRIBUTES = ['types'];
|
|
17
|
-
const GLOBAL_HTML_ATTRIBUTES = [
|
|
18
|
-
'accesskey', 'autocapitalize', 'class', 'contenteditable', 'contextmenu', 'dir', 'draggable', 'dropzone', 'hidden',
|
|
19
|
-
'id', 'inputmode', 'is', 'itemid', 'itemprop', 'itemref', 'itemscope', 'itemtype', 'lang', 'slot', 'spellcheck',
|
|
20
|
-
'style', 'tabindex', 'title', 'translate',
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Get the tag name for the specified section.
|
|
25
|
-
*
|
|
26
|
-
* @param {Node} section The MDAST section to get the tag name for
|
|
27
|
-
* @returns {string} The tag name for the section. Defaults to {@code div}.
|
|
28
|
-
*/
|
|
29
|
-
function getTagName(section) {
|
|
30
|
-
return (section.meta && section.meta.tagname) || DEFAULT_SECTION_TAG;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function toHtmlAttribute(value) {
|
|
34
|
-
return Array.isArray(value) ? value.join(' ') : value;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function getAttributes(section) {
|
|
38
|
-
const attributeKeys = Object.keys(section.meta);
|
|
39
|
-
// Add system properties as data-hlx-*
|
|
40
|
-
const attributes = attributeKeys
|
|
41
|
-
.filter((k) => SYSTEM_HTML_ATTRIBUTES.indexOf(k) > -1)
|
|
42
|
-
.reduce((result, attr) => Object.assign(result, { [`data-${HELIX_NAMESPACE}${attr}`]: toHtmlAttribute(section.meta[attr]) }), Object.create(null));
|
|
43
|
-
return attributeKeys
|
|
44
|
-
.filter((k) => [...SYSTEM_HTML_ATTRIBUTES, ...SYSTEM_META_PROPERTIES].indexOf(k) === -1)
|
|
45
|
-
.reduce((result, attr) => {
|
|
46
|
-
// Add invalid HTML attributes as data-*
|
|
47
|
-
if (GLOBAL_HTML_ATTRIBUTES.indexOf(attr) === -1 && !attr.startsWith('data-')) {
|
|
48
|
-
return Object.assign(result, { [`data-${attr}`]: toHtmlAttribute(section.meta[attr]) });
|
|
49
|
-
}
|
|
50
|
-
// Add valid HTML attributes
|
|
51
|
-
return Object.assign(result, { [attr]: toHtmlAttribute(section.meta[attr]) });
|
|
52
|
-
}, attributes);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
12
|
export default function sectionHandler() {
|
|
56
13
|
return function handler(state, node) {
|
|
57
14
|
const n = { ...node };
|
|
58
15
|
|
|
59
|
-
const tagName = getTagName(n);
|
|
60
|
-
const properties = getAttributes(n);
|
|
61
|
-
properties.className = [DEFAULT_SECTION_CLASS];
|
|
62
|
-
if (properties.class) {
|
|
63
|
-
properties.className.push(...properties.class.split(/\s+/));
|
|
64
|
-
}
|
|
65
|
-
delete properties.class;
|
|
66
16
|
const children = state.all(n);
|
|
67
17
|
return {
|
|
68
18
|
type: 'element',
|
|
69
|
-
tagName,
|
|
70
|
-
properties,
|
|
19
|
+
tagName: 'div',
|
|
71
20
|
children,
|
|
72
21
|
};
|
|
73
22
|
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2019 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import { selectAll } from 'hast-util-select';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Cleans the response document by removing `hlx-` stuff
|
|
16
|
-
* @param {PipelineState} state
|
|
17
|
-
* @param {PipelineRequest} req
|
|
18
|
-
* @param {PipelineResponse} res
|
|
19
|
-
*/
|
|
20
|
-
export default function clean(state, req, res) {
|
|
21
|
-
const { document } = res;
|
|
22
|
-
selectAll('[class]', document).forEach(({ properties }) => {
|
|
23
|
-
properties.className = properties.className.filter((name) => !name.startsWith('hlx-'));
|
|
24
|
-
if (properties.className.length === 0) {
|
|
25
|
-
delete properties.className;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Remove all `data-hlx-*` attributes on these elements
|
|
29
|
-
Object.keys(properties)
|
|
30
|
-
.filter((key) => key.match(/^dataHlx[A-Z].*/))
|
|
31
|
-
.forEach((key) => delete properties[key]);
|
|
32
|
-
});
|
|
33
|
-
}
|