ether-code 0.6.4 → 0.6.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/ether-parser.js +8 -0
- package/generators/html-generator.js +8 -1
- package/lexer/ether-lexer.js +2 -2
- package/package.json +1 -1
package/cli/ether.js
CHANGED
package/ether-parser.js
CHANGED
|
@@ -1178,6 +1178,7 @@ class EtherParser {
|
|
|
1178
1178
|
parseHTMLElement() {
|
|
1179
1179
|
const tagToken = this.current()
|
|
1180
1180
|
let tagName = this.normalizeAccents(tagToken.value)
|
|
1181
|
+
const originalTagName = tagName
|
|
1181
1182
|
this.advance()
|
|
1182
1183
|
|
|
1183
1184
|
const includeKeywords = ['inclure', 'requiert', 'include', 'require', 'importer']
|
|
@@ -1813,6 +1814,13 @@ class EtherParser {
|
|
|
1813
1814
|
}
|
|
1814
1815
|
}
|
|
1815
1816
|
|
|
1817
|
+
if (originalTagName === 'document') {
|
|
1818
|
+
return {
|
|
1819
|
+
type: 'Doctype',
|
|
1820
|
+
children: children
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1816
1824
|
return {
|
|
1817
1825
|
type: 'Element',
|
|
1818
1826
|
tag: tag,
|
|
@@ -546,8 +546,10 @@ class HTMLGenerator {
|
|
|
546
546
|
|
|
547
547
|
if (children.length > 0) {
|
|
548
548
|
const firstChild = children[0]
|
|
549
|
+
const firstType = (firstChild.type || '').toLowerCase()
|
|
549
550
|
const firstTag = (firstChild.tag || firstChild.tagName || '').toLowerCase()
|
|
550
|
-
|
|
551
|
+
|
|
552
|
+
if (firstType !== 'doctype' && (firstTag === 'html' || firstTag === 'document')) {
|
|
551
553
|
this.output += '<!DOCTYPE html>\n'
|
|
552
554
|
}
|
|
553
555
|
}
|
|
@@ -907,6 +909,11 @@ class HTMLGenerator {
|
|
|
907
909
|
|
|
908
910
|
generateDoctype(node) {
|
|
909
911
|
this.output += '<!DOCTYPE html>\n'
|
|
912
|
+
if (node.children && node.children.length > 0) {
|
|
913
|
+
for (const child of node.children) {
|
|
914
|
+
this.generateNode(child)
|
|
915
|
+
}
|
|
916
|
+
}
|
|
910
917
|
}
|
|
911
918
|
|
|
912
919
|
generateInclude(node) {
|
package/lexer/ether-lexer.js
CHANGED
|
@@ -306,8 +306,8 @@ class EtherLexer {
|
|
|
306
306
|
this.indentStack.pop()
|
|
307
307
|
this.tokens.push(new Token(TokenType.DEDENT, '', this.line, 1, indent))
|
|
308
308
|
}
|
|
309
|
-
if (this.indentStack[this.indentStack.length - 1] !== indent) {
|
|
310
|
-
this.
|
|
309
|
+
if (this.indentStack[this.indentStack.length - 1] !== indent && indent > 0) {
|
|
310
|
+
this.indentStack.push(indent)
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
}
|