@adobe/helix-html-pipeline 1.3.0 → 1.3.1

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 CHANGED
@@ -1,3 +1,11 @@
1
+ ## [1.3.1](https://github.com/adobe/helix-html-pipeline/compare/v1.3.0...v1.3.1) (2022-03-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency @adobe/helix-shared-utils to v2.0.6 ([#26](https://github.com/adobe/helix-html-pipeline/issues/26)) ([186c376](https://github.com/adobe/helix-html-pipeline/commit/186c376d0252b0c96ee461670cf45a711aa93f4f))
7
+ * preserve formatting of script tags ([#25](https://github.com/adobe/helix-html-pipeline/issues/25)) ([7009f20](https://github.com/adobe/helix-html-pipeline/commit/7009f20d37190f5704b7f9363c59912b4272c0bf)), closes [#23](https://github.com/adobe/helix-html-pipeline/issues/23)
8
+
1
9
  # [1.3.0](https://github.com/adobe/helix-html-pipeline/compare/v1.2.1...v1.3.0) (2022-03-17)
2
10
 
3
11
 
package/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
  This package contains the common code for `helix-pipeline-service` and `helix-cloudflare-pipeline` for rendering the html response for helix3. it has the following design goals:
4
4
 
5
5
  - be platform neutral, i.e. not using node or browser specific modules or dependencies.
6
- - +/-0 runtime dependencies
7
- - offer extension interfaces where platform abstraction is required (e.g. reading from s3)
6
+ - +/-0 runtime dependencies (eg. node [crypto](https://nodejs.org/api/crypto.html))
7
+ - offer extension interfaces where platform abstraction is required (e.g. reading from S3, sending to SQS)
8
8
 
9
9
  ## Status
10
10
  [![codecov](https://img.shields.io/codecov/c/github/adobe/helix-html-pipeline.svg)](https://codecov.io/gh/adobe/helix-html-pipeline)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@adobe/helix-markdown-support": "3.1.2",
36
- "@adobe/helix-shared-utils": "2.0.5",
36
+ "@adobe/helix-shared-utils": "2.0.6",
37
37
  "github-slugger": "1.4.0",
38
38
  "hast-util-raw": "7.2.1",
39
39
  "hast-util-select": "5.0.1",
@@ -12,6 +12,8 @@
12
12
  import { toHtml } from 'hast-util-to-html';
13
13
  // import rehypeFormat from 'rehype-format';
14
14
  import rehypeMinifyWhitespace from 'rehype-minify-whitespace';
15
+ import { visit } from 'unist-util-visit';
16
+
15
17
  /**
16
18
  * Serializes the response document to HTML
17
19
  * @param {PipelineState} state
@@ -32,7 +34,25 @@ export default function stringify(state, req, res) {
32
34
  // TODO: for the next breaking release, pretty print the HTML with rehypeFormat.
33
35
  // TODO: but for backward compatibility, output all on 1 line.
34
36
  // rehypeFormat()(doc);
37
+
38
+ // due to a bug in rehype-minify-whitespace, script content is also minified to 1 line, which
39
+ // can result in errors https://github.com/rehypejs/rehype-minify/issues/44
40
+ // so we 'save' all text first and revert it afterwards
41
+ visit(doc, (node) => {
42
+ if (node.tagName === 'script' && node.children[0]?.type === 'text') {
43
+ node.children[0].savedValue = node.children[0].value;
44
+ }
45
+ });
46
+
35
47
  rehypeMinifyWhitespace()(doc);
48
+
49
+ visit(doc, (node) => {
50
+ if (node.tagName === 'script' && node.children[0]?.type === 'text') {
51
+ node.children[0].value = node.children[0].savedValue;
52
+ delete node.children[0].savedValue;
53
+ }
54
+ });
55
+
36
56
  res.body = toHtml(doc, {
37
57
  upperDoctype: true,
38
58
  });