29 lines
2.0 KiB
JavaScript
29 lines
2.0 KiB
JavaScript
hljs.registerLanguage("markdown",(()=>{"use strict";function n(...n){
|
|
return n.map((n=>{return(e=n)?"string"==typeof e?e:e.source:null;var e
|
|
})).join("")}return e=>{const a={begin:/<\/?[A-Za-z_]/,end:">",
|
|
subLanguage:"xml",relevance:0},i={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0
|
|
},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,
|
|
relevance:2},{begin:n(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),
|
|
relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{
|
|
begin:/\[.+?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{
|
|
className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,
|
|
returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",
|
|
excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",
|
|
end:"\\]",excludeBegin:!0,excludeEnd:!0}]},s={className:"strong",contains:[],
|
|
variants:[{begin:/_{2}/,end:/_{2}/},{begin:/\*{2}/,end:/\*{2}/}]},c={
|
|
className:"emphasis",contains:[],variants:[{begin:/\*(?!\*)/,end:/\*/},{
|
|
begin:/_(?!_)/,end:/_/,relevance:0}]};s.contains.push(c),c.contains.push(s)
|
|
;let t=[a,i]
|
|
;return s.contains=s.contains.concat(t),c.contains=c.contains.concat(t),
|
|
t=t.concat(s,c),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{
|
|
className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:t},{
|
|
begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",
|
|
contains:t}]}]},a,{className:"bullet",begin:"^[ \t]*([*+-]|(\\d+\\.))(?=\\s+)",
|
|
end:"\\s+",excludeEnd:!0},s,c,{className:"quote",begin:"^>\\s+",contains:t,
|
|
end:"$"},{className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{
|
|
begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{
|
|
begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",
|
|
contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},{
|
|
begin:"^[-\\*]{3,}",end:"$"},i,{begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{
|
|
className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{
|
|
className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]}]}}})()); |