elixir.min.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. /*! `elixir` grammar compiled for Highlight.js 11.7.0 */
  2. var hljsGrammar=(()=>{"use strict";return e=>{
  3. const n=e.regex,a="[a-zA-Z_][a-zA-Z0-9_.]*(!|\\?)?",i={$pattern:a,
  4. keyword:["after","alias","and","case","catch","cond","defstruct","defguard","do","else","end","fn","for","if","import","in","not","or","quote","raise","receive","require","reraise","rescue","try","unless","unquote","unquote_splicing","use","when","with|0"],
  5. literal:["false","nil","true"]},s={className:"subst",begin:/#\{/,end:/\}/,
  6. keywords:i},c={match:/\\[\s\S]/,scope:"char.escape",relevance:0},r=[{begin:/"/,
  7. end:/"/},{begin:/'/,end:/'/},{begin:/\//,end:/\//},{begin:/\|/,end:/\|/},{
  8. begin:/\(/,end:/\)/},{begin:/\[/,end:/\]/},{begin:/\{/,end:/\}/},{begin:/</,
  9. end:/>/}],t=e=>({scope:"char.escape",begin:n.concat(/\\/,e),relevance:0}),d={
  10. className:"string",begin:"~[a-z](?=[/|([{<\"'])",
  11. contains:r.map((n=>e.inherit(n,{contains:[t(n.end),c,s]})))},o={
  12. className:"string",begin:"~[A-Z](?=[/|([{<\"'])",
  13. contains:r.map((n=>e.inherit(n,{contains:[t(n.end)]})))},b={className:"regex",
  14. variants:[{begin:"~r(?=[/|([{<\"'])",contains:r.map((a=>e.inherit(a,{
  15. end:n.concat(a.end,/[uismxfU]{0,7}/),contains:[t(a.end),c,s]})))},{
  16. begin:"~R(?=[/|([{<\"'])",contains:r.map((a=>e.inherit(a,{
  17. end:n.concat(a.end,/[uismxfU]{0,7}/),contains:[t(a.end)]})))}]},l={
  18. className:"string",contains:[e.BACKSLASH_ESCAPE,s],variants:[{begin:/"""/,
  19. end:/"""/},{begin:/'''/,end:/'''/},{begin:/~S"""/,end:/"""/,contains:[]},{
  20. begin:/~S"/,end:/"/,contains:[]},{begin:/~S'''/,end:/'''/,contains:[]},{
  21. begin:/~S'/,end:/'/,contains:[]},{begin:/'/,end:/'/},{begin:/"/,end:/"/}]},g={
  22. className:"function",beginKeywords:"def defp defmacro defmacrop",end:/\B\b/,
  23. contains:[e.inherit(e.TITLE_MODE,{begin:a,endsParent:!0})]},m=e.inherit(g,{
  24. className:"class",beginKeywords:"defimpl defmodule defprotocol defrecord",
  25. end:/\bdo\b|$|;/}),u=[l,b,o,d,e.HASH_COMMENT_MODE,m,g,{begin:"::"},{
  26. className:"symbol",begin:":(?![\\s:])",contains:[l,{
  27. begin:"[a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?"
  28. }],relevance:0},{className:"symbol",begin:a+":(?!:)",relevance:0},{
  29. className:"title.class",begin:/(\b[A-Z][a-zA-Z0-9_]+)/,relevance:0},{
  30. className:"number",
  31. begin:"(\\b0o[0-7_]+)|(\\b0b[01_]+)|(\\b0x[0-9a-fA-F_]+)|(-?\\b[0-9][0-9_]*(\\.[0-9_]+([eE][-+]?[0-9]+)?)?)",
  32. relevance:0},{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))"}]
  33. ;return s.contains=u,{name:"Elixir",aliases:["ex","exs"],keywords:i,contains:u}}
  34. })();export default hljsGrammar;