File tree 5 files changed +13
-13
lines changed
5 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ Parser Engine:
4
4
5
5
- (parser) Adds ` keywords.$pattern ` key to grammar definitions (#2519 ) [ Josh Goebel] [ ]
6
6
- (parser) Adds SHEBANG utility mode [ Josh Goebel] [ ]
7
- - (parser) Adds ` registerAlias ` method (#2540 ) [ Taufik Nurrohman] [ ]
7
+ - (parser) Adds ` registerAliases ` method (#2540 ) [ Taufik Nurrohman] [ ]
8
8
- (enh) Added ` on:begin ` callback for modes (#2261 ) [ Josh Goebel] [ ]
9
9
- (enh) Added ` on:end ` callback for modes (#2261 ) [ Josh Goebel] [ ]
10
10
- (enh) Added ability to programatically ignore begin and end matches (#2261 ) [ Josh Goebel] [ ]
Original file line number Diff line number Diff line change @@ -112,8 +112,8 @@ Adds new language to the library under the specified name. Used mostly internall
112
112
to use common regular expressions defined within it.
113
113
114
114
115
- ``registerAlias (alias|aliases, {languageName}) ``
116
- ------------------------------------------------
115
+ ``registerAliases (alias|aliases, {languageName}) ``
116
+ --------------------------------------------------
117
117
118
118
Adds new language alias or aliases to the library for the specified language name defined under ``languageName `` key.
119
119
Original file line number Diff line number Diff line change @@ -658,7 +658,7 @@ const HLJS = function(hljs) {
658
658
lang . rawDefinition = language . bind ( null , hljs ) ;
659
659
660
660
if ( lang . aliases ) {
661
- lang . aliases . forEach ( function ( alias ) { aliases [ alias ] = name ; } ) ;
661
+ registerAliases ( lang . aliases , { languageName : name } ) ;
662
662
}
663
663
}
664
664
@@ -685,12 +685,11 @@ const HLJS = function(hljs) {
685
685
return languages [ name ] || languages [ aliases [ name ] ] ;
686
686
}
687
687
688
- function registerAlias ( alias , { languageName} ) {
689
- let list = alias ;
690
- if ( typeof list === 'string' ) {
691
- list = [ alias ]
688
+ function registerAliases ( aliasList , { languageName} ) {
689
+ if ( typeof aliasList === 'string' ) {
690
+ aliasList = [ aliasList ]
692
691
}
693
- list . forEach ( alias => aliases [ alias ] = languageName ) ;
692
+ aliasList . forEach ( alias => aliases [ alias ] = languageName ) ;
694
693
}
695
694
696
695
function autoDetection ( name ) {
@@ -724,7 +723,7 @@ const HLJS = function(hljs) {
724
723
registerLanguage,
725
724
listLanguages,
726
725
getLanguage,
727
- registerAlias ,
726
+ registerAliases ,
728
727
requireLanguage,
729
728
autoDetection,
730
729
inherit,
Original file line number Diff line number Diff line change @@ -12,4 +12,5 @@ describe('hljs', function() {
12
12
require ( './highlight' ) ;
13
13
require ( './fixmarkup' ) ;
14
14
require ( './keywords' ) ;
15
+ require ( './registerAlias' ) ;
15
16
} ) ;
Original file line number Diff line number Diff line change 3
3
const hljs = require ( '../../build' ) ;
4
4
const should = require ( 'should' ) ;
5
5
6
- describe ( '.registerAlias ()' , ( ) => {
6
+ describe ( '.registerAliases ()' , ( ) => {
7
7
it ( 'should get an existing language by alias' , ( ) => {
8
- hljs . registerAlias ( 'jquery' , {
8
+ hljs . registerAliases ( 'jquery' , {
9
9
languageName : 'javascript'
10
10
} ) ;
11
11
const result = hljs . getLanguage ( 'jquery' ) ;
@@ -14,7 +14,7 @@ describe('.registerAlias()', () => {
14
14
} ) ;
15
15
16
16
it ( 'should get an existing language by aliases' , ( ) => {
17
- hljs . registerAlias ( [ 'jquery' , 'jqueryui' ] , {
17
+ hljs . registerAliases ( [ 'jquery' , 'jqueryui' ] , {
18
18
languageName : 'javascript'
19
19
} ) ;
20
20
const result = hljs . getLanguage ( 'jquery' ) ;
You can’t perform that action at this time.
0 commit comments