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 CHANGED
@@ -6,7 +6,7 @@ const http = require('http')
6
6
  const { EtherCompiler } = require('./compiler')
7
7
  const { Watcher } = require('./watcher')
8
8
 
9
- const VERSION = '0.1.5'
9
+ const VERSION = '0.1.6'
10
10
 
11
11
  const COLORS = {
12
12
  reset: '\x1b[0m',
@@ -489,10 +489,48 @@ class HTMLGenerator {
489
489
  generateDocument(node) {
490
490
  this.writeLine('<!DOCTYPE html>')
491
491
  if (node.html) {
492
- this.generateNode(node.html)
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))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ether-code",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Ether - Le langage intentionnel",
5
5
  "main": "cli/compiler.js",
6
6
  "bin": {