ether-code 0.2.4 → 0.2.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 +13 -9
- package/ether-parser.js +24 -1
- package/generators/html-generator.js +10 -1
- package/package.json +1 -1
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.2.
|
|
9
|
+
const VERSION = '0.2.6'
|
|
10
10
|
|
|
11
11
|
const COLORS = {
|
|
12
12
|
reset: '\x1b[0m',
|
|
@@ -248,7 +248,7 @@ function createDevServer(outDir, port) {
|
|
|
248
248
|
})
|
|
249
249
|
})
|
|
250
250
|
|
|
251
|
-
server.listen(port, () => {
|
|
251
|
+
server.listen(port, '127.0.0.1', () => {
|
|
252
252
|
logSuccess(`Serveur démarré sur ${COLORS.cyan}http://localhost:${port}${COLORS.reset}`)
|
|
253
253
|
})
|
|
254
254
|
|
|
@@ -849,18 +849,22 @@ async function cmdDev(options) {
|
|
|
849
849
|
logInfo(`Sortie vers ${outDir}`)
|
|
850
850
|
console.log('')
|
|
851
851
|
|
|
852
|
-
try {
|
|
853
|
-
await cmdBuild({ ...options, quiet: true })
|
|
854
|
-
} catch (err) {
|
|
855
|
-
logWarning(`Erreur lors de la compilation initiale: ${err.message}`)
|
|
856
|
-
}
|
|
857
|
-
|
|
858
852
|
let devServer = null
|
|
859
853
|
if (!options.noServer) {
|
|
860
854
|
devServer = createDevServer(outDir, port)
|
|
861
|
-
console.log('')
|
|
862
855
|
}
|
|
863
856
|
|
|
857
|
+
console.log('')
|
|
858
|
+
logInfo('Compilation initiale...')
|
|
859
|
+
|
|
860
|
+
try {
|
|
861
|
+
await cmdBuild({ ...options, quiet: true })
|
|
862
|
+
logSuccess('Compilation terminée')
|
|
863
|
+
} catch (err) {
|
|
864
|
+
logWarning(`Erreur de compilation: ${err.message}`)
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
console.log('')
|
|
864
868
|
logInfo('En attente de modifications... (Ctrl+C pour arrêter)')
|
|
865
869
|
console.log('')
|
|
866
870
|
|
package/ether-parser.js
CHANGED
|
@@ -815,10 +815,20 @@ class EtherParser {
|
|
|
815
815
|
}
|
|
816
816
|
this.advance()
|
|
817
817
|
}
|
|
818
|
+
|
|
819
|
+
if (this.current() && this.current().type === TokenType.COMMA) {
|
|
820
|
+
this.advance()
|
|
821
|
+
}
|
|
818
822
|
} else {
|
|
819
823
|
attributes[attrName] = true
|
|
820
824
|
this.advance()
|
|
825
|
+
|
|
826
|
+
if (this.current() && this.current().type === TokenType.COMMA) {
|
|
827
|
+
this.advance()
|
|
828
|
+
}
|
|
821
829
|
}
|
|
830
|
+
} else if (current.type === TokenType.COMMA) {
|
|
831
|
+
this.advance()
|
|
822
832
|
} else {
|
|
823
833
|
break
|
|
824
834
|
}
|
|
@@ -864,6 +874,7 @@ class EtherParser {
|
|
|
864
874
|
translateHTMLTag(tag) {
|
|
865
875
|
const map = this.reverseMaps.html || {}
|
|
866
876
|
const lower = tag.toLowerCase()
|
|
877
|
+
const withSpaces = lower.replace(/-/g, ' ')
|
|
867
878
|
|
|
868
879
|
const translations = {
|
|
869
880
|
'document': 'html',
|
|
@@ -872,11 +883,14 @@ class EtherParser {
|
|
|
872
883
|
'corps': 'body',
|
|
873
884
|
'entete': 'header',
|
|
874
885
|
'piedpage': 'footer',
|
|
886
|
+
'pied': 'footer',
|
|
875
887
|
'navigation': 'nav',
|
|
888
|
+
'nav': 'nav',
|
|
876
889
|
'principal': 'main',
|
|
877
890
|
'section': 'section',
|
|
878
891
|
'article': 'article',
|
|
879
892
|
'cote': 'aside',
|
|
893
|
+
'aside': 'aside',
|
|
880
894
|
'titre': 'title',
|
|
881
895
|
'titre1': 'h1',
|
|
882
896
|
'titre2': 'h2',
|
|
@@ -888,12 +902,16 @@ class EtherParser {
|
|
|
888
902
|
'paragraphe': 'p',
|
|
889
903
|
'texte': 'span',
|
|
890
904
|
'division': 'div',
|
|
905
|
+
'div': 'div',
|
|
891
906
|
'bloc': 'div',
|
|
907
|
+
'span': 'span',
|
|
892
908
|
'lien': 'a',
|
|
893
909
|
'image': 'img',
|
|
894
910
|
'liste': 'ul',
|
|
895
911
|
'liste ordonnee': 'ol',
|
|
912
|
+
'liste non ordonnee': 'ul',
|
|
896
913
|
'element': 'li',
|
|
914
|
+
'element liste': 'li',
|
|
897
915
|
'tableau': 'table',
|
|
898
916
|
'ligne': 'tr',
|
|
899
917
|
'cellule': 'td',
|
|
@@ -906,15 +924,20 @@ class EtherParser {
|
|
|
906
924
|
'option': 'option',
|
|
907
925
|
'etiquette': 'label',
|
|
908
926
|
'gras': 'strong',
|
|
927
|
+
'fort': 'strong',
|
|
909
928
|
'italique': 'em',
|
|
929
|
+
'emphase': 'em',
|
|
910
930
|
'souligne': 'u',
|
|
911
931
|
'barre': 's',
|
|
912
932
|
'code': 'code',
|
|
933
|
+
'pre': 'pre',
|
|
913
934
|
'preformate': 'pre',
|
|
914
935
|
'citation': 'blockquote',
|
|
915
936
|
'retour ligne': 'br',
|
|
916
937
|
'saut ligne': 'br',
|
|
938
|
+
'br': 'br',
|
|
917
939
|
'ligne horizontale': 'hr',
|
|
940
|
+
'hr': 'hr',
|
|
918
941
|
'video': 'video',
|
|
919
942
|
'audio': 'audio',
|
|
920
943
|
'source': 'source',
|
|
@@ -956,7 +979,7 @@ class EtherParser {
|
|
|
956
979
|
'zone': 'area'
|
|
957
980
|
}
|
|
958
981
|
|
|
959
|
-
return translations[lower] || map[lower] || tag
|
|
982
|
+
return translations[lower] || translations[withSpaces] || map[lower] || map[withSpaces] || tag
|
|
960
983
|
}
|
|
961
984
|
|
|
962
985
|
parseJS() {
|
|
@@ -81,7 +81,8 @@ class HTMLGenerator {
|
|
|
81
81
|
|
|
82
82
|
translateTag(tag) {
|
|
83
83
|
const lower = tag.toLowerCase()
|
|
84
|
-
|
|
84
|
+
const withSpaces = lower.replace(/-/g, ' ')
|
|
85
|
+
let result = this.tagMap[lower] || this.tagMap[withSpaces] || this.translateGenericTag(tag)
|
|
85
86
|
result = result.replace(/^<|>$/g, '').trim()
|
|
86
87
|
return result
|
|
87
88
|
}
|
|
@@ -103,7 +104,9 @@ class HTMLGenerator {
|
|
|
103
104
|
'script': 'script',
|
|
104
105
|
'entete': 'header',
|
|
105
106
|
'piedpage': 'footer',
|
|
107
|
+
'pied': 'footer',
|
|
106
108
|
'navigation': 'nav',
|
|
109
|
+
'nav': 'nav',
|
|
107
110
|
'principal': 'main',
|
|
108
111
|
'section': 'section',
|
|
109
112
|
'article': 'article',
|
|
@@ -119,6 +122,7 @@ class HTMLGenerator {
|
|
|
119
122
|
'titre6': 'h6',
|
|
120
123
|
'paragraphe': 'p',
|
|
121
124
|
'division': 'div',
|
|
125
|
+
'div': 'div',
|
|
122
126
|
'span': 'span',
|
|
123
127
|
'portee': 'span',
|
|
124
128
|
'lien': 'a',
|
|
@@ -127,7 +131,9 @@ class HTMLGenerator {
|
|
|
127
131
|
'legende': 'figcaption',
|
|
128
132
|
'liste': 'ul',
|
|
129
133
|
'liste ordonnee': 'ol',
|
|
134
|
+
'liste non ordonnee': 'ul',
|
|
130
135
|
'element': 'li',
|
|
136
|
+
'element liste': 'li',
|
|
131
137
|
'definition': 'dl',
|
|
132
138
|
'terme': 'dt',
|
|
133
139
|
'description': 'dd',
|
|
@@ -170,6 +176,7 @@ class HTMLGenerator {
|
|
|
170
176
|
'petit': 'small',
|
|
171
177
|
'marque': 'mark',
|
|
172
178
|
'code': 'code',
|
|
179
|
+
'pre': 'pre',
|
|
173
180
|
'preformate': 'pre',
|
|
174
181
|
'citation': 'blockquote',
|
|
175
182
|
'citation courte': 'q',
|
|
@@ -183,6 +190,8 @@ class HTMLGenerator {
|
|
|
183
190
|
'ligne horizontale': 'hr',
|
|
184
191
|
'saut ligne': 'br',
|
|
185
192
|
'retour ligne': 'br',
|
|
193
|
+
'br': 'br',
|
|
194
|
+
'hr': 'hr',
|
|
186
195
|
'details': 'details',
|
|
187
196
|
'resume': 'summary',
|
|
188
197
|
'dialogue': 'dialog',
|