@adobe/helix-markdown-support 3.1.2 → 3.1.5
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.
|
@@ -9,9 +9,9 @@ jobs:
|
|
|
9
9
|
runs-on: ubuntu-latest
|
|
10
10
|
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
|
11
11
|
steps:
|
|
12
|
-
- uses: actions/checkout@
|
|
12
|
+
- uses: actions/checkout@v3
|
|
13
13
|
- name: Use Node.js 14.x
|
|
14
|
-
uses: actions/setup-node@
|
|
14
|
+
uses: actions/setup-node@v3
|
|
15
15
|
with:
|
|
16
16
|
node-version: '14.x'
|
|
17
17
|
- run: npm install
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## [3.1.5](https://github.com/adobe/helix-markdown-support/compare/v3.1.4...v3.1.5) (2022-05-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* (re)move breaks in links and headings ([621c85b](https://github.com/adobe/helix-markdown-support/commit/621c85b664621e56111e00e9cbb9cd7d648471d6)), closes [#106](https://github.com/adobe/helix-markdown-support/issues/106)
|
|
7
|
+
|
|
8
|
+
## [3.1.4](https://github.com/adobe/helix-markdown-support/compare/v3.1.3...v3.1.4) (2022-05-10)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* preserve spans ([#109](https://github.com/adobe/helix-markdown-support/issues/109)) ([9d6ba00](https://github.com/adobe/helix-markdown-support/commit/9d6ba00e2623349bf469ab56bb093f5dbed976fc))
|
|
14
|
+
|
|
15
|
+
## [3.1.3](https://github.com/adobe/helix-markdown-support/compare/v3.1.2...v3.1.3) (2022-05-10)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* keep html in table paragraphs ([#108](https://github.com/adobe/helix-markdown-support/issues/108)) ([9b3ea28](https://github.com/adobe/helix-markdown-support/commit/9b3ea28a1fd785e575a56bb99d47f1c07ef2a88e))
|
|
21
|
+
|
|
1
22
|
## [3.1.2](https://github.com/adobe/helix-markdown-support/compare/v3.1.1...v3.1.2) (2022-01-24)
|
|
2
23
|
|
|
3
24
|
|
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.5",
|
|
4
4
|
"description": "Helix Markdown Support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -41,22 +41,22 @@
|
|
|
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.2",
|
|
45
45
|
"codecov": "3.8.3",
|
|
46
|
-
"eslint": "8.
|
|
46
|
+
"eslint": "8.15.0",
|
|
47
47
|
"eslint-plugin-header": "3.1.1",
|
|
48
|
-
"eslint-plugin-import": "2.
|
|
49
|
-
"husky": "
|
|
48
|
+
"eslint-plugin-import": "2.26.0",
|
|
49
|
+
"husky": "8.0.1",
|
|
50
50
|
"junit-report-builder": "3.0.0",
|
|
51
|
-
"lint-staged": "12.
|
|
51
|
+
"lint-staged": "12.4.1",
|
|
52
52
|
"mdast-builder": "1.1.1",
|
|
53
|
-
"mocha": "
|
|
53
|
+
"mocha": "10.0.0",
|
|
54
54
|
"mocha-multi-reporters": "1.5.1",
|
|
55
55
|
"remark-gfm": "3.0.1",
|
|
56
56
|
"remark-parse": "10.0.1",
|
|
57
57
|
"remark-stringify": "10.0.2",
|
|
58
58
|
"semantic-release": "19.0.2",
|
|
59
|
-
"unified": "10.1.
|
|
59
|
+
"unified": "10.1.2",
|
|
60
60
|
"unist-util-inspect": "7.0.0"
|
|
61
61
|
},
|
|
62
62
|
"lint-staged": {
|
|
@@ -29,20 +29,26 @@ export default function robustTables(tree) {
|
|
|
29
29
|
(node.children /* c8 ignore next */ || []).forEach((row) => {
|
|
30
30
|
html += ' <tr>\n';
|
|
31
31
|
(row.children /* c8 ignore next */ || []).forEach((cell) => {
|
|
32
|
-
let
|
|
32
|
+
let attrs = '';
|
|
33
33
|
if (cell.align === 'right') {
|
|
34
|
-
|
|
34
|
+
attrs = ' align="right"';
|
|
35
35
|
} else if (cell.align === 'center') {
|
|
36
|
-
|
|
36
|
+
attrs = ' align="center"';
|
|
37
37
|
} else if (cell.align === 'both') {
|
|
38
|
-
|
|
38
|
+
attrs = ' align="justify"';
|
|
39
39
|
}
|
|
40
40
|
if (cell.valign === 'middle') {
|
|
41
|
-
|
|
41
|
+
attrs += ' valign="middle"';
|
|
42
42
|
} else if (cell.valign === 'bottom') {
|
|
43
|
-
|
|
43
|
+
attrs += ' valign="bottom"';
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
if (cell.rowSpan > 1) {
|
|
46
|
+
attrs += ` rowspan="${cell.rowSpan}"`;
|
|
47
|
+
}
|
|
48
|
+
if (cell.colSpan > 1) {
|
|
49
|
+
attrs += ` colspan="${cell.colSpan}"`;
|
|
50
|
+
}
|
|
51
|
+
html += ` <td${attrs}>`;
|
|
46
52
|
|
|
47
53
|
// if cell contains only 1 single paragraph, unwrap it
|
|
48
54
|
let { children } = cell;
|
|
@@ -54,7 +60,8 @@ export default function robustTables(tree) {
|
|
|
54
60
|
if (child.type === 'html') {
|
|
55
61
|
html += child.value;
|
|
56
62
|
} else {
|
|
57
|
-
const
|
|
63
|
+
const hast = md2hast(child, { allowDangerousHtml: true });
|
|
64
|
+
const cellHtml = hast2html(hast, { allowDangerousHtml: true });
|
|
58
65
|
if (child.type === 'code') {
|
|
59
66
|
// code needs special treatment, otherwise the newlines disappear.
|
|
60
67
|
html += cellHtml.replace(/\r?\n/g, '<br>');
|
|
@@ -14,6 +14,7 @@ import { visit } from 'unist-util-visit';
|
|
|
14
14
|
/**
|
|
15
15
|
* Sanitizes headings:
|
|
16
16
|
* - (re)move images ('before', 'both', 'after')
|
|
17
|
+
* - converts BREAKs inside headings to <br>.
|
|
17
18
|
*
|
|
18
19
|
* @param {object} tree
|
|
19
20
|
* @param {object} [opts] options
|
|
@@ -47,6 +48,9 @@ export default function sanitizeHeading(tree, opts = {}) {
|
|
|
47
48
|
siblings.splice(after, 0, para);
|
|
48
49
|
after += 1;
|
|
49
50
|
}
|
|
51
|
+
} else if (child.type === 'break') {
|
|
52
|
+
child.type = 'html';
|
|
53
|
+
child.value = '<br>';
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
// remove empty headings
|
|
@@ -15,6 +15,8 @@ import find from 'unist-util-find';
|
|
|
15
15
|
/**
|
|
16
16
|
* Sanitizes links:
|
|
17
17
|
* - unwraps formatting in links if possible. eg: [_text_](...) -> _[test](...)_
|
|
18
|
+
* - moves leading, trailing BREAKs out of link
|
|
19
|
+
* - converts BREAKs inside link to <br>.
|
|
18
20
|
*
|
|
19
21
|
* @param {object} tree
|
|
20
22
|
* @returns {object} The modified (original) tree.
|
|
@@ -60,6 +62,31 @@ export default function sanitizeLinks(tree) {
|
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
}
|
|
65
|
+
} else if (node.type === 'link' && children.length > 1) {
|
|
66
|
+
// move leading breaks outside of link
|
|
67
|
+
while (children[0]?.type === 'break') {
|
|
68
|
+
const brk = children.shift();
|
|
69
|
+
parent.children.splice(index, 0, brk);
|
|
70
|
+
// eslint-disable-next-line no-param-reassign
|
|
71
|
+
index += 1;
|
|
72
|
+
}
|
|
73
|
+
// move trailing breaks after link
|
|
74
|
+
let last = children.length - 1;
|
|
75
|
+
while (children[last]?.type === 'break') {
|
|
76
|
+
const brk = children.pop();
|
|
77
|
+
parent.children.splice(index + 1, 0, brk);
|
|
78
|
+
last -= 1;
|
|
79
|
+
}
|
|
80
|
+
// convert inline breaks to <br>
|
|
81
|
+
for (let i = 0; i < children.length; i += 1) {
|
|
82
|
+
if (children[i].type === 'break') {
|
|
83
|
+
children[i] = {
|
|
84
|
+
type: 'html',
|
|
85
|
+
value: '<br>',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return index + 1;
|
|
63
90
|
}
|
|
64
91
|
return CONTINUE;
|
|
65
92
|
});
|