@jsenv/ast 4.0.0 → 4.0.2
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/package.json +2 -2
- package/src/html/html_parse.js +9 -3
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/ast",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Parse and transform HTML,CSS and JS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/jsenv/core",
|
|
9
|
-
"directory": "packages/ast"
|
|
9
|
+
"directory": "packages/rest/ast"
|
|
10
10
|
},
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
package/src/html/html_parse.js
CHANGED
|
@@ -61,7 +61,11 @@ export const parseHtmlString = (
|
|
|
61
61
|
|
|
62
62
|
export const stringifyHtmlAst = (
|
|
63
63
|
htmlAst,
|
|
64
|
-
{
|
|
64
|
+
{
|
|
65
|
+
preserveLineBreaks = true,
|
|
66
|
+
cleanupJsenvAttributes = false,
|
|
67
|
+
cleanupPositionAttributes = false,
|
|
68
|
+
} = {},
|
|
65
69
|
) => {
|
|
66
70
|
if (cleanupJsenvAttributes || cleanupPositionAttributes) {
|
|
67
71
|
const htmlNode = findHtmlChildNode(
|
|
@@ -98,8 +102,10 @@ export const stringifyHtmlAst = (
|
|
|
98
102
|
});
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
if (preserveLineBreaks) {
|
|
106
|
+
// ensure body and html have \n
|
|
107
|
+
ensureLineBreaksBetweenHtmlNodes(htmlAst);
|
|
108
|
+
}
|
|
103
109
|
const htmlString = serialize(htmlAst);
|
|
104
110
|
return htmlString;
|
|
105
111
|
};
|