-
Notifications
You must be signed in to change notification settings - Fork 20
Create or suggest new languages
Fell free to suggest new language by creating an new issue
Create or go to the file at languages/[language-name].js
The default export of that file should be an Array
export default []That array will contain all the matching rules as Object
The highlighter will try every match and take the first match in the String,
in the case where two matches start at the same spot the first in the Array will be kept
Match rules can be divided into 3 categories:
1. The most basic of all contain:
a match key regex with the global flag,
and a type is type/token
{
type: 'kwd',
match: /helloworld/g
}Therefore everything that match the regex /helloworld/g, will be consider as a token of type kwd/keyword
2. The easiest of all is just composed of the extand key
{
extand: 'str'
},It will use the data from the common.js file, it is a great way to quickly create new language will keeping size small
3. The slightly more complicated sub,
this property permit to imbricate another language
using a string with the language name
{
// this entire match will be highlighted using the rules of that sublanguage
match: /js/g,
// will load the js rules and then use it
sub: 'js'
}You can also inline it
{
// will be used as the default color for the sub language (only work for inline sublanguage)
type: '[default type of that sub thing]',
match: /sub/g,
sub: [
// inline sublanguage rules
]
}You can also change the default type/token of that entire language by exporting the type variable
export let type = 'oper';If you are creating a language similar to a language, you may want to use work that has already been done on that language
// import that language
import data from './[lang_name].js'
export default [
// new rules here:
{ match: /helloworld/g, type: 'kwd' },
// already implemented language spread using the spread operator
...data
]