ether-code 0.6.2 → 0.6.3

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.6.2'
9
+ const VERSION = '0.6.3'
10
10
 
11
11
  const COLORS = {
12
12
  reset: '\x1b[0m',
package/ether-parser.js CHANGED
@@ -17,16 +17,16 @@ class EtherParser {
17
17
  initCompoundTerms() {
18
18
  this.compoundOperators = {
19
19
  'strictement egal': '===',
20
- 'strictement égal': '===',
20
+ 'strictement égal': '===',
21
21
  'strictement different': '!==',
22
- 'strictement différent': '!==',
22
+ 'strictement différent': '!==',
23
23
  'superieur ou egal': '>=',
24
- 'supérieur ou égal': '>=',
24
+ 'supérieur ou égal': '>=',
25
25
  'inferieur ou egal': '<=',
26
- 'inférieur ou égal': '<=',
26
+ 'inférieur ou égal': '<=',
27
27
  'coalescence nulle': '??',
28
28
  'chainage optionnel': '?.',
29
- 'chaînage optionnel': '?.'
29
+ 'chaînage optionnel': '?.'
30
30
  }
31
31
 
32
32
  this.compoundKeywords = {
@@ -36,7 +36,7 @@ class EtherParser {
36
36
  'fonction asynchrone': 'async function',
37
37
  'fonction async': 'async function',
38
38
  'fonction generatrice': 'function*',
39
- 'fonction génératrice': 'function*',
39
+ 'fonction génératrice': 'function*',
40
40
  'variable globale': 'var'
41
41
  }
42
42
 
@@ -281,7 +281,7 @@ class EtherParser {
281
281
  expect(type) {
282
282
  const token = this.current()
283
283
  if (!token || token.type !== type) {
284
- throw new Error(`Attendu ${type}, reçu ${token ? token.type : 'EOF'}`)
284
+ throw new Error(`Attendu ${type}, reçu ${token ? token.type : 'EOF'}`)
285
285
  }
286
286
  return this.advance()
287
287
  }
@@ -695,7 +695,7 @@ class EtherParser {
695
695
  'alignement': ['texte'],
696
696
  'decoration': ['texte'],
697
697
  'transformation': ['texte'],
698
- 'ombre': ['texte', 'boite', 'boîte'],
698
+ 'ombre': ['texte', 'boite', 'boîte'],
699
699
  'espacement': ['lettres'],
700
700
  'bordure': ['haut', 'bas', 'gauche', 'droite', 'couleur', 'style', 'largeur', 'arrondi'],
701
701
  'couleur': ['bordure', 'fond', 'texte', 'remplissage'],
@@ -706,19 +706,19 @@ class EtherParser {
706
706
  'direction': ['flex'],
707
707
  'enveloppe': ['flex'],
708
708
  'justifier': ['contenu'],
709
- 'aligner': ['elements', 'éléments', 'contenu'],
709
+ 'aligner': ['elements', 'éléments', 'contenu'],
710
710
  'colonnes': ['grille'],
711
711
  'lignes': ['grille'],
712
712
  'espace': ['ligne', 'colonne', 'blanc'],
713
- 'débordement': ['x', 'y'],
713
+ 'débordement': ['x', 'y'],
714
714
  'debordement': ['x', 'y'],
715
- 'événements': ['pointeur'],
715
+ 'événements': ['pointeur'],
716
716
  'evenements': ['pointeur'],
717
- 'modèle': ['boite', 'boîte'],
718
- 'modele': ['boite', 'boîte'],
717
+ 'modèle': ['boite', 'boîte'],
718
+ 'modele': ['boite', 'boîte'],
719
719
  'filtre': ['fond'],
720
720
  'decoupe': ['fond'],
721
- 'découpe': ['fond'],
721
+ 'découpe': ['fond'],
722
722
  'origine': ['transformation', 'perspective'],
723
723
  'liste': ['style', 'type', 'position', 'image'],
724
724
  }
@@ -1177,7 +1177,7 @@ class EtherParser {
1177
1177
 
1178
1178
  parseHTMLElement() {
1179
1179
  const tagToken = this.current()
1180
- let tagName = tagToken.value.toLowerCase()
1180
+ let tagName = this.normalizeAccents(tagToken.value)
1181
1181
  this.advance()
1182
1182
 
1183
1183
  const includeKeywords = ['inclure', 'requiert', 'include', 'require', 'importer']
@@ -1228,14 +1228,14 @@ class EtherParser {
1228
1228
 
1229
1229
  if ((tagName === 'liste' || tagName === 'list') && nextToken) {
1230
1230
  if (nextToken.type === TokenType.IDENTIFIER) {
1231
- const nextVal = nextToken.value.toLowerCase()
1231
+ const nextVal = this.normalizeAccents(nextToken.value)
1232
1232
  if (nextVal === 'ordonnee' || nextVal === 'ordered') {
1233
1233
  tagName = 'liste ordonnee'
1234
1234
  this.advance()
1235
1235
  } else if (nextVal === 'non') {
1236
1236
  this.advance()
1237
1237
  const thirdToken = this.current()
1238
- if (thirdToken && thirdToken.type === TokenType.IDENTIFIER && thirdToken.value.toLowerCase() === 'ordonnee') {
1238
+ if (thirdToken && thirdToken.type === TokenType.IDENTIFIER && this.normalizeAccents(thirdToken.value) === 'ordonnee') {
1239
1239
  tagName = 'liste non ordonnee'
1240
1240
  this.advance()
1241
1241
  }
@@ -1244,42 +1244,42 @@ class EtherParser {
1244
1244
  }
1245
1245
 
1246
1246
  if ((tagName === 'element' || tagName === 'item') && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1247
- if (nextToken.value.toLowerCase() === 'liste' || nextToken.value.toLowerCase() === 'list') {
1247
+ if (this.normalizeAccents(nextToken.value) === 'liste' || this.normalizeAccents(nextToken.value) === 'list') {
1248
1248
  tagName = 'element liste'
1249
1249
  this.advance()
1250
1250
  }
1251
1251
  }
1252
1252
 
1253
1253
  if ((tagName === 'zone' || tagName === 'area') && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1254
- if (nextToken.value.toLowerCase() === 'texte' || nextToken.value.toLowerCase() === 'text') {
1254
+ if (this.normalizeAccents(nextToken.value) === 'texte' || this.normalizeAccents(nextToken.value) === 'text') {
1255
1255
  tagName = 'zone texte'
1256
1256
  this.advance()
1257
1257
  }
1258
1258
  }
1259
1259
 
1260
1260
  if ((tagName === 'retour' || tagName === 'saut') && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1261
- if (nextToken.value.toLowerCase() === 'ligne' || nextToken.value.toLowerCase() === 'line') {
1261
+ if (this.normalizeAccents(nextToken.value) === 'ligne' || this.normalizeAccents(nextToken.value) === 'line') {
1262
1262
  tagName = 'retour ligne'
1263
1263
  this.advance()
1264
1264
  }
1265
1265
  }
1266
1266
 
1267
1267
  if (tagName === 'ligne' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1268
- if (nextToken.value.toLowerCase() === 'horizontale') {
1268
+ if (this.normalizeAccents(nextToken.value) === 'horizontale') {
1269
1269
  tagName = 'ligne horizontale'
1270
1270
  this.advance()
1271
1271
  }
1272
1272
  }
1273
1273
 
1274
1274
  if ((tagName === 'cellule' || tagName === 'cell') && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1275
- if (nextToken.value.toLowerCase() === 'entete' || nextToken.value.toLowerCase() === 'header') {
1275
+ if (this.normalizeAccents(nextToken.value) === 'entete' || this.normalizeAccents(nextToken.value) === 'header') {
1276
1276
  tagName = 'entete cellule'
1277
1277
  this.advance()
1278
1278
  }
1279
1279
  }
1280
1280
 
1281
1281
  if (tagName === 'groupe' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1282
- const next = nextToken.value.toLowerCase()
1282
+ const next = this.normalizeAccents(nextToken.value)
1283
1283
  if (next === 'titres') {
1284
1284
  tagName = 'groupe titres'
1285
1285
  this.advance()
@@ -1293,7 +1293,7 @@ class EtherParser {
1293
1293
  }
1294
1294
 
1295
1295
  if (tagName === 'entete' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1296
- const next = nextToken.value.toLowerCase()
1296
+ const next = this.normalizeAccents(nextToken.value)
1297
1297
  if (next === 'tableau' || next === 'table') {
1298
1298
  tagName = 'entete tableau'
1299
1299
  this.advance()
@@ -1301,7 +1301,7 @@ class EtherParser {
1301
1301
  }
1302
1302
 
1303
1303
  if (tagName === 'corps' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1304
- const next = nextToken.value.toLowerCase()
1304
+ const next = this.normalizeAccents(nextToken.value)
1305
1305
  if (next === 'tableau' || next === 'table') {
1306
1306
  tagName = 'corps tableau'
1307
1307
  this.advance()
@@ -1309,7 +1309,7 @@ class EtherParser {
1309
1309
  }
1310
1310
 
1311
1311
  if (tagName === 'pied' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1312
- const next = nextToken.value.toLowerCase()
1312
+ const next = this.normalizeAccents(nextToken.value)
1313
1313
  if (next === 'tableau' || next === 'table') {
1314
1314
  tagName = 'pied tableau'
1315
1315
  this.advance()
@@ -1317,7 +1317,7 @@ class EtherParser {
1317
1317
  }
1318
1318
 
1319
1319
  if (tagName === 'legende' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1320
- const next = nextToken.value.toLowerCase()
1320
+ const next = this.normalizeAccents(nextToken.value)
1321
1321
  if (next === 'tableau' || next === 'table') {
1322
1322
  tagName = 'legende tableau'
1323
1323
  this.advance()
@@ -1328,7 +1328,7 @@ class EtherParser {
1328
1328
  }
1329
1329
 
1330
1330
  if (tagName === 'ensemble' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1331
- const next = nextToken.value.toLowerCase()
1331
+ const next = this.normalizeAccents(nextToken.value)
1332
1332
  if (next === 'champs' || next === 'fields') {
1333
1333
  tagName = 'ensemble champs'
1334
1334
  this.advance()
@@ -1336,7 +1336,7 @@ class EtherParser {
1336
1336
  }
1337
1337
 
1338
1338
  if (tagName === 'liste' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1339
- const next = nextToken.value.toLowerCase()
1339
+ const next = this.normalizeAccents(nextToken.value)
1340
1340
  if (next === 'donnees' || next === 'data') {
1341
1341
  tagName = 'liste donnees'
1342
1342
  this.advance()
@@ -1347,7 +1347,7 @@ class EtherParser {
1347
1347
  }
1348
1348
 
1349
1349
  if (tagName === 'image' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1350
- const next = nextToken.value.toLowerCase()
1350
+ const next = this.normalizeAccents(nextToken.value)
1351
1351
  if (next === 'reactive' || next === 'responsive') {
1352
1352
  tagName = 'image reactive'
1353
1353
  this.advance()
@@ -1355,7 +1355,7 @@ class EtherParser {
1355
1355
  }
1356
1356
 
1357
1357
  if (tagName === 'cadre' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1358
- const next = nextToken.value.toLowerCase()
1358
+ const next = this.normalizeAccents(nextToken.value)
1359
1359
  if (next === 'en') {
1360
1360
  this.advance()
1361
1361
  const thirdToken = this.current()
@@ -1367,7 +1367,7 @@ class EtherParser {
1367
1367
  }
1368
1368
 
1369
1369
  if (tagName === 'citation' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1370
- const next = nextToken.value.toLowerCase()
1370
+ const next = this.normalizeAccents(nextToken.value)
1371
1371
  if (next === 'bloc' || next === 'block') {
1372
1372
  tagName = 'citation bloc'
1373
1373
  this.advance()
@@ -1375,7 +1375,7 @@ class EtherParser {
1375
1375
  }
1376
1376
 
1377
1377
  if (tagName === 'reference' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1378
- const next = nextToken.value.toLowerCase()
1378
+ const next = this.normalizeAccents(nextToken.value)
1379
1379
  if (next === 'citation') {
1380
1380
  tagName = 'reference citation'
1381
1381
  this.advance()
@@ -1383,15 +1383,55 @@ class EtherParser {
1383
1383
  }
1384
1384
 
1385
1385
  if (tagName === 'sans' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1386
- const next = nextToken.value.toLowerCase()
1386
+ const next = this.normalizeAccents(nextToken.value)
1387
1387
  if (next === 'script') {
1388
1388
  tagName = 'sans script'
1389
1389
  this.advance()
1390
1390
  }
1391
1391
  }
1392
1392
 
1393
+ if (tagName === 'isolation' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1394
+ const next = this.normalizeAccents(nextToken.value)
1395
+ if (next === 'bidi') {
1396
+ tagName = 'isolation bidi'
1397
+ this.advance()
1398
+ }
1399
+ }
1400
+
1401
+ if (tagName === 'remplacement' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1402
+ const next = this.normalizeAccents(nextToken.value)
1403
+ if (next === 'bidi') {
1404
+ tagName = 'remplacement bidi'
1405
+ this.advance()
1406
+ }
1407
+ }
1408
+
1409
+ if (tagName === 'annotation' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1410
+ const next = this.normalizeAccents(nextToken.value)
1411
+ if (next === 'ruby' || next === 'rubis') {
1412
+ tagName = 'annotation ruby'
1413
+ this.advance()
1414
+ }
1415
+ }
1416
+
1417
+ if ((tagName === 'parentheses' || tagName === 'parenthèses') && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1418
+ const next = this.normalizeAccents(nextToken.value)
1419
+ if (next === 'ruby' || next === 'rubis') {
1420
+ tagName = 'parentheses ruby'
1421
+ this.advance()
1422
+ }
1423
+ }
1424
+
1425
+ if (tagName === 'carte' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1426
+ const next = this.normalizeAccents(nextToken.value)
1427
+ if (next === 'image') {
1428
+ tagName = 'carte image'
1429
+ this.advance()
1430
+ }
1431
+ }
1432
+
1393
1433
  if ((tagName === 'texte' || tagName === 'text') && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1394
- const next = nextToken.value.toLowerCase()
1434
+ const next = this.normalizeAccents(nextToken.value)
1395
1435
  if (next === 'alternatif' || next === 'alt') {
1396
1436
  tagName = 'texte alternatif'
1397
1437
  this.advance()
@@ -1399,7 +1439,7 @@ class EtherParser {
1399
1439
  }
1400
1440
 
1401
1441
  if (tagName === 'entree' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1402
- const next = nextToken.value.toLowerCase()
1442
+ const next = this.normalizeAccents(nextToken.value)
1403
1443
  if (next === 'clavier') {
1404
1444
  tagName = 'entree clavier'
1405
1445
  this.advance()
@@ -1407,7 +1447,7 @@ class EtherParser {
1407
1447
  }
1408
1448
 
1409
1449
  if (tagName === 'sortie' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1410
- const next = nextToken.value.toLowerCase()
1450
+ const next = this.normalizeAccents(nextToken.value)
1411
1451
  if (next === 'exemple') {
1412
1452
  tagName = 'sortie exemple'
1413
1453
  this.advance()
@@ -1415,7 +1455,7 @@ class EtherParser {
1415
1455
  }
1416
1456
 
1417
1457
  if (tagName === 'definition' && nextToken && nextToken.type === TokenType.IDENTIFIER) {
1418
- const next = nextToken.value.toLowerCase()
1458
+ const next = this.normalizeAccents(nextToken.value)
1419
1459
  if (next === 'description') {
1420
1460
  tagName = 'definition description'
1421
1461
  this.advance()
@@ -1440,9 +1480,17 @@ class EtherParser {
1440
1480
  'encodage': ['formulaire'],
1441
1481
  'validation': ['formulaire', 'auto'],
1442
1482
  'cible': ['formulaire', 'popover'],
1443
- 'lecture': ['seule'],
1483
+ 'lecture': ['seule', 'auto'],
1444
1484
  'nouvelle': ['fenetre'],
1445
- 'a': ['popup']
1485
+ 'a': ['popup'],
1486
+ 'jeu': ['caracteres', 'caractères'],
1487
+ 'equivalent': ['http'],
1488
+ 'équivalent': ['http'],
1489
+ 'fusion': ['colonnes', 'lignes'],
1490
+ 'plein': ['ecran', 'écran'],
1491
+ 'bac': ['sable'],
1492
+ 'origine': ['croisee', 'croisée'],
1493
+ 'sources': ['reactives', 'réactives']
1446
1494
  }
1447
1495
 
1448
1496
  while (!this.isAtEnd()) {
@@ -1545,7 +1593,7 @@ class EtherParser {
1545
1593
 
1546
1594
  translateHTMLTag(tag) {
1547
1595
  const map = this.reverseMaps.html || {}
1548
- const lower = tag.toLowerCase()
1596
+ const lower = this.normalizeAccents(tag)
1549
1597
  const withSpaces = lower.replace(/-/g, ' ')
1550
1598
 
1551
1599
  const translations = {
@@ -1716,6 +1764,20 @@ class EtherParser {
1716
1764
  'cesure': 'wbr',
1717
1765
  'noscript': 'noscript',
1718
1766
  'sans script': 'noscript',
1767
+ 'isolation bidi': 'bdi',
1768
+ 'remplacement bidi': 'bdo',
1769
+ 'annotation ruby': 'rt',
1770
+ 'annotation rubis': 'rt',
1771
+ 'parentheses ruby': 'rp',
1772
+ 'parenthèses ruby': 'rp',
1773
+ 'parentheses rubis': 'rp',
1774
+ 'terme': 'dt',
1775
+ 'menu': 'menu',
1776
+ 'recherche': 'search',
1777
+ 'objet': 'object',
1778
+ 'integrer': 'embed',
1779
+ 'svg': 'svg',
1780
+ 'math': 'math',
1719
1781
 
1720
1782
  'zone': 'area'
1721
1783
  }
@@ -2495,16 +2557,16 @@ class EtherParser {
2495
2557
  let left = this.parseComparison(lang)
2496
2558
 
2497
2559
  while (true) {
2498
- if (this.matchValue('strictement egal') || this.matchValue('strictement égal')) {
2560
+ if (this.matchValue('strictement egal') || this.matchValue('strictement égal')) {
2499
2561
  const right = this.parseComparison(lang)
2500
2562
  left = { type: 'BinaryExpression', operator: '===', left, right }
2501
- } else if (this.matchValue('strictement different') || this.matchValue('strictement différent')) {
2563
+ } else if (this.matchValue('strictement different') || this.matchValue('strictement différent')) {
2502
2564
  const right = this.parseComparison(lang)
2503
2565
  left = { type: 'BinaryExpression', operator: '!==', left, right }
2504
- } else if (this.match(TokenType.DOUBLE_EQUALS) || this.matchValue('egal') || this.matchValue('egale') || this.matchValue('égal')) {
2566
+ } else if (this.match(TokenType.DOUBLE_EQUALS) || this.matchValue('egal') || this.matchValue('egale') || this.matchValue('égal')) {
2505
2567
  const right = this.parseComparison(lang)
2506
2568
  left = { type: 'BinaryExpression', operator: '===', left, right }
2507
- } else if (this.match(TokenType.NOT_EQUALS) || this.matchValue('different') || this.matchValue('différent')) {
2569
+ } else if (this.match(TokenType.NOT_EQUALS) || this.matchValue('different') || this.matchValue('différent')) {
2508
2570
  const right = this.parseComparison(lang)
2509
2571
  left = { type: 'BinaryExpression', operator: '!==', left, right }
2510
2572
  } else {
@@ -2519,16 +2581,16 @@ class EtherParser {
2519
2581
  let left = this.parseAdditive(lang)
2520
2582
 
2521
2583
  while (true) {
2522
- if (this.matchValue('superieur ou egal') || this.matchValue('supérieur ou égal') || this.match(TokenType.GTE)) {
2584
+ if (this.matchValue('superieur ou egal') || this.matchValue('supérieur ou égal') || this.match(TokenType.GTE)) {
2523
2585
  const right = this.parseAdditive(lang)
2524
2586
  left = { type: 'BinaryExpression', operator: '>=', left, right }
2525
- } else if (this.matchValue('inferieur ou egal') || this.matchValue('inférieur ou égal') || this.match(TokenType.LTE)) {
2587
+ } else if (this.matchValue('inferieur ou egal') || this.matchValue('inférieur ou égal') || this.match(TokenType.LTE)) {
2526
2588
  const right = this.parseAdditive(lang)
2527
2589
  left = { type: 'BinaryExpression', operator: '<=', left, right }
2528
- } else if (this.match(TokenType.LT) || this.matchValue('inferieur') || this.matchValue('inférieur')) {
2590
+ } else if (this.match(TokenType.LT) || this.matchValue('inferieur') || this.matchValue('inférieur')) {
2529
2591
  const right = this.parseAdditive(lang)
2530
2592
  left = { type: 'BinaryExpression', operator: '<', left, right }
2531
- } else if (this.match(TokenType.GT) || this.matchValue('superieur') || this.matchValue('supérieur')) {
2593
+ } else if (this.match(TokenType.GT) || this.matchValue('superieur') || this.matchValue('supérieur')) {
2532
2594
  const right = this.parseAdditive(lang)
2533
2595
  left = { type: 'BinaryExpression', operator: '>', left, right }
2534
2596
  } else {