ether-code 0.1.5 → 0.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/cli/ether.js +1 -1
- package/generators/html-generator.js +39 -1
- package/package.json +1 -1
package/cli/ether.js
CHANGED
|
@@ -489,10 +489,48 @@ class HTMLGenerator {
|
|
|
489
489
|
generateDocument(node) {
|
|
490
490
|
this.writeLine('<!DOCTYPE html>')
|
|
491
491
|
if (node.html) {
|
|
492
|
-
this.
|
|
492
|
+
this.generateNodeWithCharset(node.html)
|
|
493
493
|
}
|
|
494
494
|
}
|
|
495
495
|
|
|
496
|
+
generateNodeWithCharset(node) {
|
|
497
|
+
if (node.type === 'Element' && node.htmlTag === 'html') {
|
|
498
|
+
const tag = 'html'
|
|
499
|
+
const attributes = this.generateAttributes(node.attributes || [])
|
|
500
|
+
this.writeLine(`<${tag}${attributes}>`)
|
|
501
|
+
this.indent++
|
|
502
|
+
|
|
503
|
+
for (const child of (node.children || [])) {
|
|
504
|
+
if (child.htmlTag === 'head') {
|
|
505
|
+
this.generateHeadWithCharset(child)
|
|
506
|
+
} else {
|
|
507
|
+
this.generateNode(child)
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
this.indent--
|
|
512
|
+
this.writeLine(`</${tag}>`)
|
|
513
|
+
} else {
|
|
514
|
+
this.generateNode(node)
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
generateHeadWithCharset(node) {
|
|
519
|
+
const tag = 'head'
|
|
520
|
+
const attributes = this.generateAttributes(node.attributes || [])
|
|
521
|
+
this.writeLine(`<${tag}${attributes}>`)
|
|
522
|
+
this.indent++
|
|
523
|
+
|
|
524
|
+
this.writeLine('<meta charset="UTF-8">')
|
|
525
|
+
|
|
526
|
+
for (const child of (node.children || [])) {
|
|
527
|
+
this.generateNode(child)
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
this.indent--
|
|
531
|
+
this.writeLine(`</${tag}>`)
|
|
532
|
+
}
|
|
533
|
+
|
|
496
534
|
generateTextNode(node) {
|
|
497
535
|
if (node.value || node.content) {
|
|
498
536
|
this.writeLine(this.escapeHtml(node.value || node.content))
|