discourse/vendor/assets/javascripts/highlightjs/languages/crystal.min.js

1 line
2.5 KiB
JavaScript

hljs.registerLanguage("crystal",function(e){function b(e,b){var c=[{b:e,e:b}];return c[0].c=c,c}var c="(_*[ui](8|16|32|64|128))?",i="(_*f(32|64))?",n="[a-zA-Z_]\\w*[!?=]?",r="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~|]|//|//=|&[-+*]=?|&\\*\\*|\\[\\][=?]?",s="[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?",t={keyword:"abstract alias annotation as as? asm begin break case class def do else elsif end ensure enum extend for fun if include instance_sizeof is_a? lib macro module next nil? of out pointerof private protected rescue responds_to? return require select self sizeof struct super then type typeof union uninitialized unless until verbatim when while with yield __DIR__ __END_LINE__ __FILE__ __LINE__",literal:"false nil true"},a={cN:"subst",b:"#{",e:"}",k:t},l={cN:"template-variable",v:[{b:"\\{\\{",e:"\\}\\}"},{b:"\\{%",e:"%\\}"}],k:t},u={cN:"string",c:[e.BE,a],v:[{b:/'/,e:/'/},{b:/"/,e:/"/},{b:/`/,e:/`/},{b:"%[Qwi]?\\(",e:"\\)",c:b("\\(","\\)")},{b:"%[Qwi]?\\[",e:"\\]",c:b("\\[","\\]")},{b:"%[Qwi]?{",e:"}",c:b("{","}")},{b:"%[Qwi]?<",e:">",c:b("<",">")},{b:"%[Qwi]?\\|",e:"\\|"},{b:/<<-\w+$/,e:/^\s*\w+$/}],r:0},_={cN:"string",v:[{b:"%q\\(",e:"\\)",c:b("\\(","\\)")},{b:"%q\\[",e:"\\]",c:b("\\[","\\]")},{b:"%q{",e:"}",c:b("{","}")},{b:"%q<",e:">",c:b("<",">")},{b:"%q\\|",e:"\\|"},{b:/<<-'\w+'$/,e:/^\s*\w+$/}],r:0},o={b:"(?!%})("+e.RSR+"|\\n|\\b(case|if|select|unless|until|when|while)\\b)\\s*",k:"case if select unless until when while",c:[{cN:"regexp",c:[e.BE,a],v:[{b:"//[a-z]*",r:0},{b:"/(?!\\/)",e:"/[a-z]*"}]}],r:0},f={cN:"regexp",c:[e.BE,a],v:[{b:"%r\\(",e:"\\)",c:b("\\(","\\)")},{b:"%r\\[",e:"\\]",c:b("\\[","\\]")},{b:"%r{",e:"}",c:b("{","}")},{b:"%r<",e:">",c:b("<",">")},{b:"%r\\|",e:"\\|"}],r:0},w={cN:"meta",b:"@\\[",e:"\\]",c:[e.inherit(e.QSM,{cN:"meta-string"})]},N=[l,u,_,f,o,w,e.HCM,{cN:"class",bK:"class module struct",e:"$|;",i:/=/,c:[e.HCM,e.inherit(e.TM,{b:s}),{b:"<"}]},{cN:"class",bK:"lib enum union",e:"$|;",i:/=/,c:[e.HCM,e.inherit(e.TM,{b:s})],r:10},{bK:"annotation",e:"$|;",i:/=/,c:[e.HCM,e.inherit(e.TM,{b:s})],r:10},{cN:"function",bK:"def",e:/\B\b/,c:[e.inherit(e.TM,{b:r,endsParent:!0})]},{cN:"function",bK:"fun macro",e:/\B\b/,c:[e.inherit(e.TM,{b:r,endsParent:!0})],r:5},{cN:"symbol",b:e.UIR+"(\\!|\\?)?:",r:0},{cN:"symbol",b:":",c:[u,{b:r}],r:0},{cN:"number",v:[{b:"\\b0b([01_]+)"+c},{b:"\\b0o([0-7_]+)"+c},{b:"\\b0x([A-Fa-f0-9_]+)"+c},{b:"\\b([1-9][0-9_]*[0-9]|[0-9])(\\.[0-9][0-9_]*)?([eE]_*[-+]?[0-9_]*)?"+i+"(?!_)"},{b:"\\b([1-9][0-9_]*|0)"+c}],r:0}];return a.c=N,l.c=N.slice(1),{aliases:["cr"],l:n,k:t,c:N}});