@adobe/helix-markdown-support 3.1.5 → 3.1.6
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 +7 -0
- package/package.json +4 -4
- package/src/mdast-sanitize-heading.js +31 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [3.1.6](https://github.com/adobe/helix-markdown-support/compare/v3.1.5...v3.1.6) (2022-05-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* move leading and trailing breaks out of heading ([#112](https://github.com/adobe/helix-markdown-support/issues/112)) ([87775dc](https://github.com/adobe/helix-markdown-support/commit/87775dcf189f024ccf789f8c883ab90d296c8d0d))
|
|
7
|
+
|
|
1
8
|
## [3.1.5](https://github.com/adobe/helix-markdown-support/compare/v3.1.4...v3.1.5) (2022-05-17)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-markdown-support",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.6",
|
|
4
4
|
"description": "Helix Markdown Support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"@adobe/eslint-config-helix": "1.3.2",
|
|
42
42
|
"@semantic-release/changelog": "6.0.1",
|
|
43
43
|
"@semantic-release/git": "10.0.1",
|
|
44
|
-
"c8": "7.11.
|
|
44
|
+
"c8": "7.11.3",
|
|
45
45
|
"codecov": "3.8.3",
|
|
46
|
-
"eslint": "8.
|
|
46
|
+
"eslint": "8.16.0",
|
|
47
47
|
"eslint-plugin-header": "3.1.1",
|
|
48
48
|
"eslint-plugin-import": "2.26.0",
|
|
49
49
|
"husky": "8.0.1",
|
|
50
50
|
"junit-report-builder": "3.0.0",
|
|
51
|
-
"lint-staged": "12.4.
|
|
51
|
+
"lint-staged": "12.4.2",
|
|
52
52
|
"mdast-builder": "1.1.1",
|
|
53
53
|
"mocha": "10.0.0",
|
|
54
54
|
"mocha-multi-reporters": "1.5.1",
|
|
@@ -42,24 +42,49 @@ export default function sanitizeHeading(tree, opts = {}) {
|
|
|
42
42
|
siblings.splice(index, 0, para);
|
|
43
43
|
// eslint-disable-next-line no-param-reassign
|
|
44
44
|
index += 1;
|
|
45
|
-
after
|
|
45
|
+
after += 1;
|
|
46
46
|
} else {
|
|
47
47
|
// move after heading
|
|
48
48
|
siblings.splice(after, 0, para);
|
|
49
49
|
after += 1;
|
|
50
50
|
}
|
|
51
|
-
} else if (child.type === 'break') {
|
|
52
|
-
child.type = 'html';
|
|
53
|
-
child.value = '<br>';
|
|
54
51
|
}
|
|
55
52
|
}
|
|
53
|
+
|
|
54
|
+
// move leading breaks before heading
|
|
55
|
+
while (children[0]?.type === 'break') {
|
|
56
|
+
const brk = children.shift();
|
|
57
|
+
siblings.splice(index, 0, brk);
|
|
58
|
+
// eslint-disable-next-line no-param-reassign
|
|
59
|
+
index += 1;
|
|
60
|
+
}
|
|
61
|
+
// move trailing breaks after heading
|
|
62
|
+
let last = children.length - 1;
|
|
63
|
+
while (children[last]?.type === 'break') {
|
|
64
|
+
const brk = children.pop();
|
|
65
|
+
siblings.splice(index + 1, 0, brk);
|
|
66
|
+
last -= 1;
|
|
67
|
+
}
|
|
68
|
+
// convert inline breaks to <br>
|
|
69
|
+
for (let i = 0; i < children.length; i += 1) {
|
|
70
|
+
if (children[i].type === 'break') {
|
|
71
|
+
children[i] = {
|
|
72
|
+
type: 'html',
|
|
73
|
+
value: '<br>',
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
56
78
|
// remove empty headings
|
|
57
79
|
if (!children.length) {
|
|
58
80
|
siblings.splice(index, 1);
|
|
59
|
-
|
|
81
|
+
// eslint-disable-next-line no-param-reassign
|
|
82
|
+
index -= 1;
|
|
60
83
|
}
|
|
84
|
+
return index + 1;
|
|
61
85
|
}
|
|
62
|
-
|
|
86
|
+
|
|
87
|
+
return index + 1;
|
|
63
88
|
});
|
|
64
89
|
return tree;
|
|
65
90
|
}
|