ether-code 0.1.4 → 0.1.5
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/compiler.js +16 -4
- package/cli/ether.js +1 -1
- package/package.json +1 -1
package/cli/compiler.js
CHANGED
|
@@ -126,11 +126,15 @@ class EtherCompiler {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
parse(content, target) {
|
|
129
|
+
const normalizedTarget = this.normalizeTarget(target)
|
|
130
|
+
|
|
131
|
+
if (normalizedTarget === 'html') {
|
|
132
|
+
return this.parseHTML(content)
|
|
133
|
+
}
|
|
134
|
+
|
|
129
135
|
const lexer = new EtherLexer(content)
|
|
130
136
|
const tokens = lexer.tokenize()
|
|
131
137
|
|
|
132
|
-
const normalizedTarget = this.normalizeTarget(target)
|
|
133
|
-
|
|
134
138
|
try {
|
|
135
139
|
const ParserClass = this.loadParser(normalizedTarget)
|
|
136
140
|
if (ParserClass) {
|
|
@@ -143,6 +147,13 @@ class EtherCompiler {
|
|
|
143
147
|
return this.buildGenericAST(tokens, target)
|
|
144
148
|
}
|
|
145
149
|
|
|
150
|
+
parseHTML(content) {
|
|
151
|
+
const { HTMLParser } = require('../parsers/html-parser')
|
|
152
|
+
const i18nPath = path.join(__dirname, '..', 'i18n', 'i18n-html.json')
|
|
153
|
+
const parser = new HTMLParser(i18nPath)
|
|
154
|
+
return parser.parse(content)
|
|
155
|
+
}
|
|
156
|
+
|
|
146
157
|
loadParser(target) {
|
|
147
158
|
try {
|
|
148
159
|
const parserPath = path.join(__dirname, '..', 'parsers', `${target}-parser.js`)
|
|
@@ -212,8 +223,9 @@ class EtherCompiler {
|
|
|
212
223
|
inferTargetFromContent(content) {
|
|
213
224
|
const patterns = {
|
|
214
225
|
html: [
|
|
215
|
-
|
|
216
|
-
/\b(
|
|
226
|
+
/^html\b/im,
|
|
227
|
+
/\b(html|page|document|entête|entete|corps|section|div|paragraphe|titre|lien|image|formulaire|bouton)\b/i,
|
|
228
|
+
/\b(balise|élément|element|attribut)\b/i
|
|
217
229
|
],
|
|
218
230
|
css: [
|
|
219
231
|
/\b(style|couleur|taille|marge|bordure|fond|police|largeur|hauteur)\s*[:=]/i,
|
package/cli/ether.js
CHANGED