@adobe/helix-markdown-support 7.1.13 → 7.1.14
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 +6 -6
- package/src/mdast-sanitize-text-and-formats.js +15 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [7.1.14](https://github.com/adobe/helix-markdown-support/compare/v7.1.13...v7.1.14) (2025-10-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* allow snug em and strong ([#337](https://github.com/adobe/helix-markdown-support/issues/337)) ([921bdf4](https://github.com/adobe/helix-markdown-support/commit/921bdf4a4b046abed9d00f4cc1bb91cf6804b5ec))
|
|
7
|
+
|
|
1
8
|
## [7.1.13](https://github.com/adobe/helix-markdown-support/compare/v7.1.12...v7.1.13) (2025-10-06)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-markdown-support",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.14",
|
|
4
4
|
"description": "Helix Markdown Support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -59,16 +59,16 @@
|
|
|
59
59
|
"node": ">=14"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@adobe/eslint-config-helix": "3.0.
|
|
63
|
-
"@adobe/remark-gridtables": "3.0.
|
|
64
|
-
"@eslint/config-helpers": "0.
|
|
62
|
+
"@adobe/eslint-config-helix": "3.0.11",
|
|
63
|
+
"@adobe/remark-gridtables": "3.0.15",
|
|
64
|
+
"@eslint/config-helpers": "0.4.0",
|
|
65
65
|
"@semantic-release/changelog": "6.0.3",
|
|
66
66
|
"@semantic-release/git": "10.0.1",
|
|
67
67
|
"c8": "10.1.3",
|
|
68
68
|
"eslint": "9.4.0",
|
|
69
69
|
"husky": "9.1.7",
|
|
70
70
|
"junit-report-builder": "5.1.1",
|
|
71
|
-
"lint-staged": "16.
|
|
71
|
+
"lint-staged": "16.2.3",
|
|
72
72
|
"mdast-builder": "1.1.1",
|
|
73
73
|
"mocha": "11.7.2",
|
|
74
74
|
"mocha-multi-reporters": "1.5.1",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"remark-parse": "11.0.0",
|
|
79
79
|
"remark-rehype": "11.1.2",
|
|
80
80
|
"remark-stringify": "11.0.0",
|
|
81
|
-
"semantic-release": "24.2.
|
|
81
|
+
"semantic-release": "24.2.9",
|
|
82
82
|
"unified": "11.0.5",
|
|
83
83
|
"unist-util-inspect": "8.1.0"
|
|
84
84
|
},
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
import { visit, CONTINUE } from 'unist-util-visit';
|
|
13
|
-
import {
|
|
13
|
+
import { markdownSpace, unicodePunctuation } from 'micromark-util-character';
|
|
14
14
|
|
|
15
15
|
export function isFormat(type) {
|
|
16
16
|
return type === 'strong'
|
|
@@ -95,6 +95,12 @@ function collapse(tree) {
|
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* handles whitespace in formats:
|
|
100
|
+
* - move all whitespaces into the surrounding text
|
|
101
|
+
*
|
|
102
|
+
* @param tree
|
|
103
|
+
*/
|
|
98
104
|
function whitespace(tree) {
|
|
99
105
|
visit(tree, (node, index, parent) => {
|
|
100
106
|
const { children: siblings = [] } = parent || {};
|
|
@@ -151,20 +157,16 @@ function whitespace(tree) {
|
|
|
151
157
|
}
|
|
152
158
|
}
|
|
153
159
|
|
|
154
|
-
// ensure that text
|
|
160
|
+
// ensure that text has surrounding whitespace if both sides are "trapped"
|
|
161
|
+
// eg: foo**bar**zoo -> foo **bar** zoo
|
|
155
162
|
const prev = siblings[index - 1];
|
|
156
|
-
if (prev?.type === 'text' && !isSnug(node.type)) {
|
|
157
|
-
const code = prev.value.charCodeAt(prev.value.length - 1);
|
|
158
|
-
if (!asciiPunctuation(code) && !markdownSpace(code) && !unicodePunctuation(code)) {
|
|
159
|
-
prev.value += ' ';
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// ensure that text after format has leading whitespace
|
|
164
163
|
const next = siblings[index + 1];
|
|
165
|
-
if (
|
|
166
|
-
const
|
|
167
|
-
|
|
164
|
+
if (prev?.type === 'text' && next?.type === 'text' && !isSnug(node.type)) {
|
|
165
|
+
const ws = (code) => markdownSpace(code) || unicodePunctuation(code);
|
|
166
|
+
const prevCode = prev.value.charCodeAt(prev.value.length - 1);
|
|
167
|
+
const nextCode = next.value.charCodeAt(0);
|
|
168
|
+
if (!ws(prevCode) && !ws(nextCode)) {
|
|
169
|
+
prev.value += ' ';
|
|
168
170
|
next.value = ` ${next.value}`;
|
|
169
171
|
}
|
|
170
172
|
}
|