16 lines
1.1 KiB
JavaScript
16 lines
1.1 KiB
JavaScript
hljs.registerLanguage("ini",(()=>{"use strict";function e(e){
|
|
return e?"string"==typeof e?e:e.source:null}function n(...n){
|
|
return n.map((n=>e(n))).join("")}return s=>{const a={className:"number",
|
|
relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:s.NUMBER_RE}]
|
|
},i=s.COMMENT();i.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const t={
|
|
className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/
|
|
}]},r={className:"literal",begin:/\bon|off|true|false|yes|no\b/},l={
|
|
className:"string",contains:[s.BACKSLASH_ESCAPE],variants:[{begin:"'''",
|
|
end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'
|
|
},{begin:"'",end:"'"}]},c={begin:/\[/,end:/\]/,contains:[i,r,t,l,a,"self"],
|
|
relevance:0
|
|
},g="("+[/[A-Za-z0-9_-]+/,/"(\\"|[^"])*"/,/'[^']*'/].map((n=>e(n))).join("|")+")"
|
|
;return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,
|
|
contains:[i,{className:"section",begin:/\[+/,end:/\]+/},{
|
|
begin:n(g,"(\\s*\\.\\s*",g,")*",n("(?=",/\s*=\s*[^#\s]/,")")),className:"attr",
|
|
starts:{end:/$/,contains:[i,c,r,t,l,a]}}]}}})()); |