@@ -30,20 +30,20 @@ function getUnit(units, v) {
3030}
3131
3232var LANGS = [
33- { lang : 'bash' , ext : '.sh' , style : '#' } ,
34- { lang : 'c' , ext : '.c' , style : 'c' } ,
35- { lang : 'cpp' , ext : '.cpp' , style : 'c' } ,
36- { lang : 'csharp' , ext : '.cs' , style : 'c' } ,
37- { lang : 'golang' , ext : '.go' , style : 'c' } ,
38- { lang : 'java' , ext : '.java' , style : 'c' } ,
39- { lang : 'javascript' , ext : '.js' , style : 'c' } ,
40- { lang : 'kotlin' , ext : '.kt' , style : 'c' } ,
41- { lang : 'mysql' , ext : '.sql' , style : '#' } ,
42- { lang : 'python' , ext : '.py' , style : '#' } ,
43- { lang : 'python3' , ext : '.py3' , style : '#' } ,
44- { lang : 'ruby' , ext : '.rb' , style : '#' } ,
45- { lang : 'scala' , ext : '.scala' , style : 'c' } ,
46- { lang : 'swift' , ext : '.swift' , style : 'c' }
33+ { lang : 'bash' , ext : '.sh' , style : '#' } ,
34+ { lang : 'c' , ext : '.c' , style : 'c' } ,
35+ { lang : 'cpp' , ext : '.cpp' , style : 'c' } ,
36+ { lang : 'csharp' , ext : '.cs' , style : 'c' } ,
37+ { lang : 'golang' , ext : '.go' , style : 'c' } ,
38+ { lang : 'java' , ext : '.java' , style : 'c' } ,
39+ { lang : 'javascript' , ext : '.js' , style : 'c' } ,
40+ { lang : 'kotlin' , ext : '.kt' , style : 'c' } ,
41+ { lang : 'mysql' , ext : '.sql' , style : '#' } ,
42+ { lang : 'python' , ext : '.py' , style : '#' } ,
43+ { lang : 'python3' , ext : '.python3.py' , style : '#' } ,
44+ { lang : 'ruby' , ext : '.rb' , style : '#' } ,
45+ { lang : 'scala' , ext : '.scala' , style : 'c' } ,
46+ { lang : 'swift' , ext : '.swift' , style : 'c' }
4747] ;
4848
4949var h = { } ;
@@ -130,11 +130,18 @@ h.langToExt = function(lang) {
130130} ;
131131
132132h . extToLang = function ( fullpath ) {
133- var ext = path . extname ( fullpath ) ;
134- var res = _ . find ( LANGS , function ( x ) {
135- return x . ext === ext ;
136- } ) ;
137- return res ? res . lang : 'unknown' ;
133+ // HACK: compatible with old ext
134+ if ( fullpath . endsWith ( '.py3' ) ) return 'python3' ;
135+
136+ var res = _ . chain ( LANGS )
137+ . filter ( function ( x ) {
138+ return fullpath . endsWith ( x . ext ) ;
139+ } )
140+ . sortBy ( function ( x ) {
141+ return - x . ext . length ;
142+ } )
143+ . value ( ) ;
144+ return res . length ? res [ 0 ] . lang : 'unknown' ;
138145} ;
139146
140147h . langToCommentStyle = function ( lang ) {
0 commit comments