@astrojs/compiler 0.12.0 → 0.12.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 +8 -0
- package/astro.wasm +0 -0
- package/browser/utils.d.ts +1 -0
- package/browser/utils.js +29 -0
- package/node/utils.d.ts +1 -0
- package/node/utils.js +29 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @astrojs/compiler
|
|
2
2
|
|
|
3
|
+
## 0.12.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 097ac47: Parser: Always output the `attribute` property in an element node, even if empty
|
|
8
|
+
- ad62437: Add `serialize` util
|
|
9
|
+
- eb7eb95: Parse: fix escaping of `&` characters in AST output
|
|
10
|
+
|
|
3
11
|
## 0.12.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
package/astro.wasm
CHANGED
|
Binary file
|
package/browser/utils.d.ts
CHANGED
package/browser/utils.js
CHANGED
|
@@ -45,3 +45,32 @@ export function walk(node, callback) {
|
|
|
45
45
|
const walker = new Walker(callback);
|
|
46
46
|
walker.visit(node);
|
|
47
47
|
}
|
|
48
|
+
export function serialize(root) {
|
|
49
|
+
let output = '';
|
|
50
|
+
function visitor(node) {
|
|
51
|
+
if (is.root(node)) {
|
|
52
|
+
node.children.forEach((child) => visitor(child));
|
|
53
|
+
}
|
|
54
|
+
else if (is.frontmatter(node)) {
|
|
55
|
+
output += `---${node.value}---\n\n`;
|
|
56
|
+
}
|
|
57
|
+
else if (is.comment(node)) {
|
|
58
|
+
output += `<!--${node.value}-->`;
|
|
59
|
+
}
|
|
60
|
+
else if (is.expression(node)) {
|
|
61
|
+
output += `{`;
|
|
62
|
+
node.children.forEach((child) => visitor(child));
|
|
63
|
+
output += `}`;
|
|
64
|
+
}
|
|
65
|
+
else if (is.literal(node)) {
|
|
66
|
+
output += node.value;
|
|
67
|
+
}
|
|
68
|
+
else if (is.tag(node)) {
|
|
69
|
+
output += `<${node.name}>`;
|
|
70
|
+
node.children.forEach((child) => visitor(child));
|
|
71
|
+
output += `</${node.name}>`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
visitor(root);
|
|
75
|
+
return output;
|
|
76
|
+
}
|
package/node/utils.d.ts
CHANGED
package/node/utils.js
CHANGED
|
@@ -45,3 +45,32 @@ export function walk(node, callback) {
|
|
|
45
45
|
const walker = new Walker(callback);
|
|
46
46
|
walker.visit(node);
|
|
47
47
|
}
|
|
48
|
+
export function serialize(root) {
|
|
49
|
+
let output = '';
|
|
50
|
+
function visitor(node) {
|
|
51
|
+
if (is.root(node)) {
|
|
52
|
+
node.children.forEach((child) => visitor(child));
|
|
53
|
+
}
|
|
54
|
+
else if (is.frontmatter(node)) {
|
|
55
|
+
output += `---${node.value}---\n\n`;
|
|
56
|
+
}
|
|
57
|
+
else if (is.comment(node)) {
|
|
58
|
+
output += `<!--${node.value}-->`;
|
|
59
|
+
}
|
|
60
|
+
else if (is.expression(node)) {
|
|
61
|
+
output += `{`;
|
|
62
|
+
node.children.forEach((child) => visitor(child));
|
|
63
|
+
output += `}`;
|
|
64
|
+
}
|
|
65
|
+
else if (is.literal(node)) {
|
|
66
|
+
output += node.value;
|
|
67
|
+
}
|
|
68
|
+
else if (is.tag(node)) {
|
|
69
|
+
output += `<${node.name}>`;
|
|
70
|
+
node.children.forEach((child) => visitor(child));
|
|
71
|
+
output += `</${node.name}>`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
visitor(root);
|
|
75
|
+
return output;
|
|
76
|
+
}
|