1// @tiptap/[email protected] downloaded from https://ga.jspm.io/npm:@tiptap/[email protected]/dist/index.js 2 3import e from"@tiptap/extension-code-block";import{findChildren as t}from"@tiptap/core";import{Plugin as n,PluginKey as i}from"@tiptap/pm/state";import{Decoration as o,DecorationSet as s}from"@tiptap/pm/view";function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function deepFreeze(e){e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")});Object.freeze(e);Object.getOwnPropertyNames(e).forEach((t=>{const n=e[t];const i=typeof n;i!=="object"&&i!=="function"||Object.isFrozen(n)||deepFreeze(n)}));return e} 4/** @typedef {import('highlight.js').CallbackResponse} CallbackResponse */ 5/** @typedef {import('highlight.js').CompiledMode} CompiledMode */class Response{ 6/** 7 * @param {CompiledMode} mode 8 */ 9constructor(e){e.data===void 0&&(e.data={});this.data=e.data;this.isMatchIgnored=false}ignoreMatch(){this.isMatchIgnored=true}} 10/** 11 * @param {string} value 12 * @returns {string} 13 */function escapeHTML(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")} 14/** 15 * performs a shallow merge of multiple objects into one 16 * 17 * @template T 18 * @param {T} original 19 * @param {Record<string,any>[]} objects 20 * @returns {T} a single new object 21 */function inherit$1(e,...t){ 22/** @type Record<string,any> */ 23const n=Object.create(null);for(const t in e)n[t]=e[t];t.forEach((function(e){for(const t in e)n[t]=e[t]}));/** @type {T} */ 24return n} 25/** 26 * @typedef {object} Renderer 27 * @property {(text: string) => void} addText 28 * @property {(node: Node) => void} openNode 29 * @property {(node: Node) => void} closeNode 30 * @property {() => string} value 31 */ 32/** @typedef {{scope?: string, language?: string, sublanguage?: boolean}} Node */ 33/** @typedef {{walk: (r: Renderer) => void}} Tree */const r="</span>"; 34/** 35 * Determines if a node needs to be wrapped in <span> 36 * 37 * @param {Node} node */const emitsWrappingTags=e=>!!e.scope; 38/** 39 * 40 * @param {string} name 41 * @param {{prefix:string}} options 42 */const scopeToCSSClass=(e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const n=e.split(".");return[`${t}${n.shift()}`,...n.map(((e,t)=>`${e}${"_".repeat(t+1)}`))].join(" ")}return`${t}${e}`}; 43/** @type {Renderer} */class HTMLRenderer{ 44/** 45 * Creates a new HTMLRenderer 46 * 47 * @param {Tree} parseTree - the parse tree (must support `walk` API) 48 * @param {{classPrefix: string}} options 49 */ 50constructor(e,t){this.buffer="";this.classPrefix=t.classPrefix;e.walk(this)} 51/** 52 * Adds texts to the output stream 53 * 54 * @param {string} text */addText(e){this.buffer+=escapeHTML(e)} 55/** 56 * Adds a node open to the output stream (if needed) 57 * 58 * @param {Node} node */openNode(e){if(!emitsWrappingTags(e))return;const t=scopeToCSSClass(e.scope,{prefix:this.classPrefix});this.span(t)} 59/** 60 * Adds a node close to the output stream (if needed) 61 * 62 * @param {Node} node */closeNode(e){emitsWrappingTags(e)&&(this.buffer+=r)}value(){return this.buffer} 63/** 64 * Builds a span element 65 * 66 * @param {string} className */ 67span(e){this.buffer+=`<span class="${e}">`}} 68/** @typedef {{scope?: string, language?: string, children: Node[]} | string} Node */ 69/** @typedef {{scope?: string, language?: string, children: Node[]} } DataNode */ 70/** @typedef {import('highlight.js').Emitter} Emitter */ 71/** @returns {DataNode} */const newNode=(e={})=>{ 72/** @type DataNode */ 73const t={children:[]};Object.assign(t,e);return t};class TokenTree{constructor(){ 74/** @type DataNode */ 75this.rootNode=newNode();this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode} 76/** @param {Node} node */add(e){this.top.children.push(e)} 77/** @param {string} scope */openNode(e){ 78/** @type Node */ 79const t=newNode({scope:e});this.add(t);this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){while(this.closeNode());}toJSON(){return JSON.stringify(this.rootNode,null,4)} 80/**
81 * @typedef { import("./html_renderer").Renderer } Renderer 82 * @param {Renderer} builder 83 */walk(e){return this.constructor._walk(e,this.rootNode)} 84/** 85 * @param {Renderer} builder 86 * @param {Node} node 87 */static _walk(e,t){if(typeof t==="string")e.addText(t);else if(t.children){e.openNode(t);t.children.forEach((t=>this._walk(e,t)));e.closeNode(t)}return e} 88/** 89 * @param {Node} node 90 */static _collapse(e){typeof e!=="string"&&e.children&&(e.children.every((e=>typeof e==="string"))?e.children=[e.children.join("")]:e.children.forEach((e=>{TokenTree._collapse(e)})))}}class TokenTreeEmitter extends TokenTree{ 91/** 92 * @param {*} options 93 */ 94constructor(e){super();this.options=e} 95/** 96 * @param {string} text 97 */addText(e){e!==""&&this.add(e)} 98/** @param {string} scope */startScope(e){this.openNode(e)}endScope(){this.closeNode()} 99/** 100 * @param {Emitter & {root: DataNode}} emitter 101 * @param {string} name 102 */__addSublanguage(e,t){ 103/** @type DataNode */ 104const n=e.root;t&&(n.scope=`language:${t}`);this.add(n)}toHTML(){const e=new HTMLRenderer(this,this.options);return e.value()}finalize(){this.closeAllNodes();return true}} 105/** 106 * @param {string} value 107 * @returns {RegExp} 108 * */ 109/** 110 * @param {RegExp | string } re 111 * @returns {string} 112 */function source(e){return e?typeof e==="string"?e:e.source:null} 113/** 114 * @param {RegExp | string } re 115 * @returns {string} 116 */function lookahead(e){return concat("(?=",e,")")} 117/** 118 * @param {RegExp | string } re 119 * @returns {string} 120 */function anyNumberOfTimes(e){return concat("(?:",e,")*")} 121/** 122 * @param {RegExp | string } re 123 * @returns {string} 124 */function optional(e){return concat("(?:",e,")?")} 125/** 126 * @param {...(RegExp | string) } args 127 * @returns {string} 128 */function concat(...e){const t=e.map((e=>source(e))).join("");return t} 129/** 130 * @param { Array<string | RegExp | Object> } args 131 * @returns {object} 132 */function stripOptionsFromArgs(e){const t=e[e.length-1];if(typeof t==="object"&&t.constructor===Object){e.splice(e.length-1,1);return t}return{}} 133/** @typedef { {capture?: boolean} } RegexEitherOptions */ 134/** 135 * Any of the passed expresssions may match 136 * 137 * Creates a huge this | this | that | that match 138 * @param {(RegExp | string)[] | [...(RegExp | string)[], RegexEitherOptions]} args 139 * @returns {string} 140 */function either(...e){ 141/** @type { object & {capture?: boolean} } */ 142const t=stripOptionsFromArgs(e);const n="("+(t.capture?"":"?:")+e.map((e=>source(e))).join("|")+")";return n} 143/** 144 * @param {RegExp | string} re 145 * @returns {number} 146 */function countMatchGroups(e){return new RegExp(e.toString()+"|").exec("").length-1} 147/** 148 * Does lexeme start with a regular expression match at the beginning 149 * @param {RegExp} re 150 * @param {string} lexeme 151 */function startsWith(e,t){const n=e&&e.exec(t);return n&&n.index===0}const a=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./; 152/** 153 * @param {(string | RegExp)[]} regexps 154 * @param {{joinWith: string}} opts 155 * @returns {string} 156 */function _rewriteBackreferences(e,{joinWith:t}){let n=0;return e.map((e=>{n+=1;const t=n;let i=source(e);let o="";while(i.length>0){const e=a.exec(i);if(!e){o+=i;break}o+=i.substring(0,e.index);i=i.substring(e.index+e[0].length);if(e[0][0]==="\\"&&e[1])o+="\\"+String(Number(e[1])+t);else{o+=e[0];e[0]==="("&&n++}}return o})).map((e=>`(${e})`)).join(t)} 157/** @typedef {import('highlight.js').Mode} Mode */ 158/** @typedef {import('highlight.js').ModeCallback} ModeCallback */const c=/\b\B/;const l="[a-zA-Z]\\w*";const g="[a-zA-Z_]\\w*";const u="\\b\\d+(\\.\\d+)?";const h="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";const d="\\b(0b[01]+)";const f="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~"; 159/** 160* @param { Partial<Mode> & {binary?: string | RegExp} } opts 161*/const SHEBANG=(e={})=>{const t=/^#![ ]*\//;e.binary&&(e.begin=concat(t,/.*\b/,e.binary,/\b.*/));return inherit$1({scope:"meta",begin:t,end:/$/,relevance:0, 162/** @type {ModeCallback} */ 163"on:begin":(e,t)=>{e.index!==0&&t.ignoreMatch()}},e)};const p={begin:"\\\\[\\s\\S]",relevance:0};const m={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[p]};const b={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[p]};const w={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/}; 164/** 165 * Creates a comment mode 166 * 167 * @param {string | RegExp} begin 168 * @param {string | RegExp} end 169 * @param {Mode | {}} [modeOptions]
170 * @returns {Partial<Mode>} 171 */const COMMENT=function(e,t,n={}){const i=inherit$1({scope:"comment",begin:e,end:t,contains:[]},n);i.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:true,relevance:0});const o=either("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);i.contains.push({begin:concat(/[ ]+/,"(",o,/[.]?[:]?([.][ ]|[ ])/,"){3}")});return i};const x=COMMENT("//","$");const y=COMMENT("/\\*","\\*/");const E=COMMENT("#","$");const M={scope:"number",begin:u,relevance:0};const _={scope:"number",begin:h,relevance:0};const L={scope:"number",begin:d,relevance:0};const k={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[p,{begin:/\[/,end:/\]/,relevance:0,contains:[p]}]};const O={scope:"title",begin:l,relevance:0};const N={scope:"title",begin:g,relevance:0};const v={begin:"\\.\\s*"+g,relevance:0}; 172/** 173 * Adds end same as begin mechanics to a mode 174 * 175 * Your mode must include at least a single () match group as that first match 176 * group is what is used for comparison 177 * @param {Partial<Mode>} mode 178 */const END_SAME_AS_BEGIN=function(e){return Object.assign(e,{ 179/** @type {ModeCallback} */ 180"on:begin":(e,t)=>{t.data._beginMatch=e[1]}, 181/** @type {ModeCallback} */ 182"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})};var R=Object.freeze({__proto__:null,APOS_STRING_MODE:m,BACKSLASH_ESCAPE:p,BINARY_NUMBER_MODE:L,BINARY_NUMBER_RE:d,COMMENT:COMMENT,C_BLOCK_COMMENT_MODE:y,C_LINE_COMMENT_MODE:x,C_NUMBER_MODE:_,C_NUMBER_RE:h,END_SAME_AS_BEGIN:END_SAME_AS_BEGIN,HASH_COMMENT_MODE:E,IDENT_RE:l,MATCH_NOTHING_RE:c,METHOD_GUARD:v,NUMBER_MODE:M,NUMBER_RE:u,PHRASAL_WORDS_MODE:w,QUOTE_STRING_MODE:b,REGEXP_MODE:k,RE_STARTERS_RE:f,SHEBANG:SHEBANG,TITLE_MODE:O,UNDERSCORE_IDENT_RE:g,UNDERSCORE_TITLE_MODE:N}); 183/** 184@typedef {import('highlight.js').CallbackResponse} CallbackResponse 185@typedef {import('highlight.js').CompilerExt} CompilerExt 186*/ 187/** 188 * Skip a match if it has a preceding dot 189 * 190 * This is used for `beginKeywords` to prevent matching expressions such as 191 * `bob.keyword.do()`. The mode compiler automatically wires this up as a 192 * special _internal_ 'on:begin' callback for modes with `beginKeywords` 193 * @param {RegExpMatchArray} match 194 * @param {CallbackResponse} response 195 */function skipIfHasPrecedingDot(e,t){const n=e.input[e.index-1];n==="."&&t.ignoreMatch()} 196/** 197 * 198 * @type {CompilerExt} 199 */function scopeClassName(e,t){if(e.className!==void 0){e.scope=e.className;delete e.className}} 200/** 201 * `beginKeywords` syntactic sugar 202 * @type {CompilerExt} 203 */function beginKeywords(e,t){if(t&&e.beginKeywords){e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)";e.__beforeBegin=skipIfHasPrecedingDot;e.keywords=e.keywords||e.beginKeywords;delete e.beginKeywords;e.relevance===void 0&&(e.relevance=0)}} 204/** 205 * Allow `illegal` to contain an array of illegal values 206 * @type {CompilerExt} 207 */function compileIllegal(e,t){Array.isArray(e.illegal)&&(e.illegal=either(...e.illegal))} 208/** 209 * `match` to match a single expression for readability 210 * @type {CompilerExt} 211 */function compileMatch(e,t){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match;delete e.match}} 212/** 213 * provides the default 1 relevance to all modes 214 * @type {CompilerExt} 215 */function compileRelevance(e,t){e.relevance===void 0&&(e.relevance=1)}const beforeMatchExt=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");const n=Object.assign({},e);Object.keys(e).forEach((t=>{delete e[t]}));e.keywords=n.keywords;e.begin=concat(n.beforeMatch,lookahead(n.begin));e.starts={relevance:0,contains:[Object.assign(n,{endsParent:true})]};e.relevance=0;delete n.beforeMatch};const S=["of","and","for","in","not","or","if","then","parent","list","value"];const A="keyword"; 216/** 217 * Given raw keywords from a language definition, compile them. 218 * 219 * @param {string | Record<string,string|string[]> | Array<string>} rawKeywords 220 * @param {boolean} caseInsensitive 221 */function compileKeywords(e,t,n=A){ 222/** @type {import("highlight.js/private").KeywordDict} */ 223const i=Object.create(null);typeof e==="string"?compileList(n,e.split(" ")):Array.isArray(e)?compileList(n,e):Object.keys(e).forEach((function(n){Object.assign(i,compileKeywords(e[n],t,n))}));return i; 224/** 225 * Compiles an individual list of keywords 226 * 227 * Ex: "for if when while|5" 228 * 229 * @param {string} scopeName 230 * @param {Array<string>} keywordList 231 */function compileList(e,n){t&&(n=n.map((e=>e.toLowerCase())));
231n.forEach((function(t){const n=t.split("|");i[n[0]]=[e,scoreForKeyword(n[0],n[1])]}))}} 232/** 233 * Returns the proper score for a given keyword 234 * 235 * Also takes into account comment keywords, which will be scored 0 UNLESS 236 * another score has been manually assigned. 237 * @param {string} keyword 238 * @param {string} [providedScore] 239 */function scoreForKeyword(e,t){return t?Number(t):commonKeyword(e)?0:1} 240/** 241 * Determines if a given keyword is common or not 242 * 243 * @param {string} keyword */function commonKeyword(e){return S.includes(e.toLowerCase())} 244/** 245 * @type {Record<string, boolean>} 246 */const T={}; 247/** 248 * @param {string} message 249 */const error=e=>{console.error(e)}; 250/** 251 * @param {string} message 252 * @param {any} args 253 */const warn=(e,...t)=>{console.log(`WARN: ${e}`,...t)}; 254/** 255 * @param {string} version 256 * @param {string} message 257 */const deprecated=(e,t)=>{if(!T[`${e}/${t}`]){console.log(`Deprecated as of ${e}. ${t}`);T[`${e}/${t}`]=true}}; 258/** 259@typedef {import('highlight.js').CompiledMode} CompiledMode 260*/const j=new Error; 261/** 262 * Renumbers labeled scope names to account for additional inner match 263 * groups that otherwise would break everything. 264 * 265 * Lets say we 3 match scopes: 266 * 267 * { 1 => ..., 2 => ..., 3 => ... } 268 * 269 * So what we need is a clean match like this: 270 * 271 * (a)(b)(c) => [ "a", "b", "c" ] 272 * 273 * But this falls apart with inner match groups: 274 * 275 * (a)(((b)))(c) => ["a", "b", "b", "b", "c" ] 276 * 277 * Our scopes are now "out of alignment" and we're repeating `b` 3 times. 278 * What needs to happen is the numbers are remapped: 279 * 280 * { 1 => ..., 2 => ..., 5 => ... } 281 * 282 * We also need to know that the ONLY groups that should be output 283 * are 1, 2, and 5. This function handles this behavior. 284 * 285 * @param {CompiledMode} mode 286 * @param {Array<RegExp | string>} regexes 287 * @param {{key: "beginScope"|"endScope"}} opts 288 */function remapScopeNames(e,t,{key:n}){let i=0;const o=e[n]; 289/** @type Record<number,boolean> */const s={}; 290/** @type Record<number,string> */const r={};for(let e=1;e<=t.length;e++){r[e+i]=o[e];s[e+i]=true;i+=countMatchGroups(t[e-1])}e[n]=r;e[n]._emit=s;e[n]._multi=true} 291/** 292 * @param {CompiledMode} mode 293 */function beginMultiClass(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin){error("skip, excludeBegin, returnBegin not compatible with beginScope: {}");throw j}if(typeof e.beginScope!=="object"||e.beginScope===null){error("beginScope must be object");throw j}remapScopeNames(e,e.begin,{key:"beginScope"});e.begin=_rewriteBackreferences(e.begin,{joinWith:""})}} 294/** 295 * @param {CompiledMode} mode 296 */function endMultiClass(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd){error("skip, excludeEnd, returnEnd not compatible with endScope: {}");throw j}if(typeof e.endScope!=="object"||e.endScope===null){error("endScope must be object");throw j}remapScopeNames(e,e.end,{key:"endScope"});e.end=_rewriteBackreferences(e.end,{joinWith:""})}} 297/** 298 * this exists only to allow `scope: {}` to be used beside `match:` 299 * Otherwise `beginScope` would necessary and that would look weird 300 301 { 302 match: [ /def/, /\w+/ ] 303 scope: { 1: "keyword" , 2: "title" } 304 } 305 306 * @param {CompiledMode} mode 307 */function scopeSugar(e){if(e.scope&&typeof e.scope==="object"&&e.scope!==null){e.beginScope=e.scope;delete e.scope}} 308/** 309 * @param {CompiledMode} mode 310 */function MultiClass(e){scopeSugar(e);typeof e.beginScope==="string"&&(e.beginScope={_wrap:e.beginScope});typeof e.endScope==="string"&&(e.endScope={_wrap:e.endScope});beginMultiClass(e);endMultiClass(e)} 311/** 312@typedef {import('highlight.js').Mode} Mode 313@typedef {import('highlight.js').CompiledMode} CompiledMode 314@typedef {import('highlight.js').Language} Language 315@typedef {import('highlight.js').HLJSPlugin} HLJSPlugin 316@typedef {import('highlight.js').CompiledLanguage} CompiledLanguage 317*/ 318/** 319 * Compiles a language definition result 320 * 321 * Given the raw result of a language definition (Language), compiles this so 322 * that it is ready for highlighting code. 323 * @param {Language} language 324 * @returns {CompiledLanguage} 325 */function compileLanguage(e){ 326/** 327 * Builds a regex with the case sensitivity of the current language 328 * 329 * @param {RegExp | string} value 330 * @param {boolean} [global] 331 */ 332function langRe(t,n){return new RegExp(source(t),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(n?"g":""))}class MultiRegex{constructor(){this.matchIndexes={};this.regexes=[];this.matchAt=1;this.position=0}addRule(e,t){t.position=this.position++;this.matchIndexes[this.matchAt]=t;this.regexes.push([t,e]);this.matchAt+=countMatchGroups(e)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const e=this.regexes.map((e=>e[1]));this.matcherRe=langRe(_rewriteBackreferences(e,{joinWith:"|"}),true);this.lastIndex=0} 333/** @param {string} s */exec(e){this.matcherRe.lastIndex=this.lastIndex;const t=this.matcherRe.exec(e);if(!t)return null;const n=t.findIndex(((e,t)=>t>0&&e!==void 0));const i=this.matchIndexes[n];t.splice(0,n);return Object.assign(t,i)}}class ResumableMultiRegex{constructor(){this.rules=[];this.multiRegexes=[];this.count=0;this.lastIndex=0;this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];const t=new MultiRegex;this.rules.slice(e).forEach((([e,n])=>t.addRule(e,n)));t.compile();this.multiRegexes[e]=t;return t}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]);t.type==="begin"&&this.count++} 334/** @param {string} s */exec(e){const t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition())if(n&&n.index===this.lastIndex);else{const t=this.getMatcher(0);t.lastIndex=this.lastIndex+1;n=t.exec(e)}if(n){this.regexIndex+=n.position+1;this.regexIndex===this.count&&this.considerAll()}return n}} 335/** 336 * Given a mode, builds a huge ResumableMultiRegex that can be used to walk 337 * the content and find matches. 338 * 339 * @param {CompiledMode} mode 340 * @returns {ResumableMultiRegex} 341 */function buildModeRegex(e){const t=new ResumableMultiRegex;e.contains.forEach((e=>t.addRule(e.begin,{rule:e,type:"begin"})));e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:"end"});e.illegal&&t.addRule(e.illegal,{type:"illegal"});return t} 342/** 343 * Compiles an individual mode 344 * 345 * This can raise an error if the mode contains certain detectable known logic 346 * issues. 347 * @param {Mode} mode 348 * @param {CompiledMode | null} [parent] 349 * @returns {CompiledMode | never} 350 */function compileMode(t,n){const i=/** @type CompiledMode */t;if(t.isCompiled)return i;[scopeClassName,compileMatch,MultiClass,beforeMatchExt].forEach((e=>e(t,n)));e.compilerExtensions.forEach((e=>e(t,n)));t.__beforeBegin=null;[beginKeywords,compileIllegal,compileRelevance].forEach((e=>e(t,n)));t.isCompiled=true;let o=null;if(typeof t.keywords==="object"&&t.keywords.$pattern){t.keywords=Object.assign({},t.keywords);o=t.keywords.$pattern;delete t.keywords.$pattern}o=o||/\w+/;
350t.keywords&&(t.keywords=compileKeywords(t.keywords,e.case_insensitive));i.keywordPatternRe=langRe(o,true);if(n){t.begin||(t.begin=/\B|\b/);i.beginRe=langRe(i.begin);t.end||t.endsWithParent||(t.end=/\B|\b/);t.end&&(i.endRe=langRe(i.end));i.terminatorEnd=source(i.end)||"";t.endsWithParent&&n.terminatorEnd&&(i.terminatorEnd+=(t.end?"|":"")+n.terminatorEnd)}t.illegal&&(i.illegalRe=langRe(/** @type {RegExp | string} */t.illegal));t.contains||(t.contains=[]);t.contains=[].concat(...t.contains.map((function(e){return expandOrCloneMode(e==="self"?t:e)})));t.contains.forEach((function(e){compileMode(/** @type Mode */e,i)}));t.starts&&compileMode(t.starts,n);i.matcher=buildModeRegex(i);return i}e.compilerExtensions||(e.compilerExtensions=[]);if(e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");e.classNameAliases=inherit$1(e.classNameAliases||{});return compileMode(/** @type Mode */e)} 351/** 352 * Determines if a mode has a dependency on it's parent or not 353 * 354 * If a mode does have a parent dependency then often we need to clone it if 355 * it's used in multiple places so that each copy points to the correct parent, 356 * where-as modes without a parent can often safely be re-used at the bottom of 357 * a mode chain. 358 * 359 * @param {Mode | null} mode 360 * @returns {boolean} - is there a dependency on the parent? 361 * */function dependencyOnParent(e){return!!e&&(e.endsWithParent||dependencyOnParent(e.starts))} 362/** 363 * Expands a mode or clones it if necessary 364 * 365 * This is necessary for modes with parental dependenceis (see notes on 366 * `dependencyOnParent`) and for nodes that have `variants` - which must then be 367 * exploded into their own individual modes at compile time. 368 * 369 * @param {Mode} mode 370 * @returns {Mode | Mode[]} 371 * */function expandOrCloneMode(e){e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((function(t){return inherit$1(e,{variants:null},t)})));return e.cachedVariants?e.cachedVariants:dependencyOnParent(e)?inherit$1(e,{starts:e.starts?inherit$1(e.starts):null}):Object.isFrozen(e)?inherit$1(e):e}var I="11.10.0";class HTMLInjectionError extends Error{constructor(e,t){super(e);this.name="HTMLInjectionError";this.html=t}} 372/** 373@typedef {import('highlight.js').Mode} Mode 374@typedef {import('highlight.js').CompiledMode} CompiledMode 375@typedef {import('highlight.js').CompiledScope} CompiledScope 376@typedef {import('highlight.js').Language} Language 377@typedef {import('highlight.js').HLJSApi} HLJSApi 378@typedef {import('highlight.js').HLJSPlugin} HLJSPlugin 379@typedef {import('highlight.js').PluginEvent} PluginEvent 380@typedef {import('highlight.js').HLJSOptions} HLJSOptions 381@typedef {import('highlight.js').LanguageFn} LanguageFn 382@typedef {import('highlight.js').HighlightedHTMLElement} HighlightedHTMLElement 383@typedef {import('highlight.js').BeforeHighlightContext} BeforeHighlightContext 384@typedef {import('highlight.js/private').MatchType} MatchType 385@typedef {import('highlight.js/private').KeywordData} KeywordData 386@typedef {import('highlight.js/private').EnhancedMatch} EnhancedMatch 387@typedef {import('highlight.js/private').AnnotatedError} AnnotatedError 388@typedef {import('highlight.js').AutoHighlightResult} AutoHighlightResult 389@typedef {import('highlight.js').HighlightOptions} HighlightOptions 390@typedef {import('highlight.js').HighlightResult} HighlightResult 391*/const B=escapeHTML;
391const H=inherit$1;const C=Symbol("nomatch");const P=7; 392/** 393 * @param {any} hljs - object that is extended (legacy) 394 * @returns {HLJSApi} 395 */const HLJS=function(e){ 396/** @type {Record<string, Language>} */ 397const t=Object.create(null); 398/** @type {Record<string, string>} */const n=Object.create(null); 399/** @type {HLJSPlugin[]} */const i=[];let o=true;const s="Could not find the language '{}', did you forget to load/include a language module?"; 400/** @type {Language} */const r={disableAutodetect:true,name:"Plain text",contains:[]}; 401/** @type HLJSOptions */let a={ignoreUnescapedHTML:false,throwUnescapedHTML:false,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:TokenTreeEmitter}; 402/** 403 * Tests a language name to see if highlighting should be skipped 404 * @param {string} languageName 405 */function shouldNotHighlight(e){return a.noHighlightRe.test(e)} 406/** 407 * @param {HighlightedHTMLElement} block - the HTML element to determine language for 408 */function blockLanguage(e){let t=e.className+" ";t+=e.parentNode?e.parentNode.className:"";const n=a.languageDetectRe.exec(t);if(n){const t=getLanguage(n[1]);if(!t){warn(s.replace("{}",n[1]));warn("Falling back to no-highlight mode for this block.",e)}return t?n[1]:"no-highlight"}return t.split(/\s+/).find((e=>shouldNotHighlight(e)||getLanguage(e)))} 409/** 410 * Core highlighting function. 411 * 412 * OLD API 413 * highlight(lang, code, ignoreIllegals, continuation) 414 * 415 * NEW API 416 * highlight(code, {lang, ignoreIllegals}) 417 * 418 * @param {string} codeOrLanguageName - the language to use for highlighting 419 * @param {string | HighlightOptions} optionsOrCode - the code to highlight 420 * @param {boolean} [ignoreIllegals] - whether to ignore illegal matches, default is to bail 421 * 422 * @returns {HighlightResult} Result - an object that represents the result 423 * @property {string} language - the language name 424 * @property {number} relevance - the relevance score 425 * @property {string} value - the highlighted HTML code 426 * @property {string} code - the original raw code 427 * @property {CompiledMode} top - top of the current mode stack 428 * @property {boolean} illegal - indicates whether any illegal matches were found 429 */function highlight(e,t,n){let i="";let o="";if(typeof t==="object"){i=e;n=t.ignoreIllegals;o=t.language}else{deprecated("10.7.0","highlight(lang, code, ...args) has been deprecated.");deprecated("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277");o=e;i=t}n===void 0&&(n=true) 430/** @type {BeforeHighlightContext} */;const s={code:i,language:o};fire("before:highlight",s);const r=s.result?s.result:_highlight(s.language,s.code,n);r.code=s.code;fire("after:highlight",r);return r} 431/** 432 * private highlight that's used internally and does not fire callbacks 433 * 434 * @param {string} languageName - the language to use for highlighting 435 * @param {string} codeToHighlight - the code to highlight 436 * @param {boolean?} [ignoreIllegals] - whether to ignore illegal matches, default is to bail 437 * @param {CompiledMode?} [continuation] - current continuation mode, if any 438 * @returns {HighlightResult} - result of the highlight operation 439 */function _highlight(e,n,i,r){const c=Object.create(null); 440/** 441 * Return keyword data if a match is a keyword 442 * @param {CompiledMode} mode - current mode 443 * @param {string} matchText - the textual match 444 * @returns {KeywordData | false} 445 */function keywordData(e,t){return e.keywords[t]}function processKeywords(){if(!d.keywords){p.addText(m);return}let e=0;d.keywordPatternRe.lastIndex=0;let t=d.keywordPatternRe.exec(m);let n="";while(t){n+=m.substring(e,t.index);const i=g.case_insensitive?t[0].toLowerCase():t[0];const o=keywordData(d,i);if(o){const[e,s]=o;p.addText(n);n="";c[i]=(c[i]||0)+1;c[i]<=P&&(b+=s);if(e.startsWith("_"))n+=t[0];else{const n=g.classNameAliases[e]||e;emitKeyword(t[0],n)}}else n+=t[0];e=d.keywordPatternRe.lastIndex;t=d.keywordPatternRe.exec(m)}n+=m.substring(e);p.addText(n)}function processSubLanguage(){if(m==="")return; 446/** @type HighlightResult */let e=null;if(typeof d.subLanguage==="string"){if(!t[d.subLanguage]){p.addText(m);return}e=_highlight(d.subLanguage,m,true,f[d.subLanguage]);f[d.subLanguage]=/** @type {CompiledMode} */e._top}else e=highlightAuto(m,d.subLanguage.length?d.subLanguage:null);d.relevance>0&&(b+=e.relevance);p.__addSublanguage(e._emitter,e.language)}function processBuffer(){d.subLanguage!=null?processSubLanguage():processKeywords();m=""} 447/** 448 * @param {string} text 449 * @param {string} scope 450 */function emitKeyword(e,t){if(e!==""){p.startScope(t);p.addText(e);p.endScope()}} 451/** 452 * @param {CompiledScope} scope 453 * @param {RegExpMatchArray} match 454 */function emitMultiClass(e,t){let n=1;const i=t.length-1;while(n<=i){if(!e._emit[n]){n++;continue}const i=g.classNameAliases[e[n]]||e[n];const o=t[n];if(i)emitKeyword(o,i);else{m=o;processKeywords();m=""}n++}} 455/** 456 * @param {CompiledMode} mode - new mode to start 457 * @param {RegExpMatchArray} match 458 */function startNewMode(e,t){e.scope&&typeof e.scope==="string"&&p.openNode(g.classNameAliases[e.scope]||e.scope);if(e.beginScope)if(e.beginScope._wrap){emitKeyword(m,g.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap);m=""}else if(e.beginScope._multi){emitMultiClass(e.beginScope,t);m=""}d=Object.create(e,{parent:{value:d}});return d} 459/** 460 * @param {CompiledMode } mode - the mode to potentially end 461 * @param {RegExpMatchArray} match - the latest match 462 * @param {string} matchPlusRemainder - match plus remainder of content 463 * @returns {CompiledMode | void} - the next mode, or if void continue on in current mode 464 */function endOfMode(e,t,n){let i=startsWith(e.endRe,n);if(i){if(e["on:end"]){const n=new Response(e);e["on:end"](t,n);n.isMatchIgnored&&(i=false)}if(i){while(e.endsParent&&e.parent)e=e.parent;return e}}if(e.endsWithParent)return endOfMode(e.parent,t,n)} 465/** 466 * Handle matching but then ignoring a sequence of text 467 * 468 * @param {string} lexeme - string containing full match text 469 */function doIgnore(e){if(d.matcher.regexIndex===0){m+=e[0];return 1}y=true;return 0} 470/** 471 * Handle the start of a new potential mode match 472 * 473 * @param {EnhancedMatch} match - the current match 474 * @returns {number} how far to advance the parse cursor 475 */function doBeginMatch(e){const t=e[0];const n=e.rule;const i=new Response(n);const o=[n.__beforeBegin,n["on:begin"]];for(const n of o)if(n){n(e,i);if(i.isMatchIgnored)return doIgnore(t)}
475if(n.skip)m+=t;else{n.excludeBegin&&(m+=t);processBuffer();n.returnBegin||n.excludeBegin||(m=t)}startNewMode(n,e);return n.returnBegin?0:t.length} 476/** 477 * Handle the potential end of mode 478 * 479 * @param {RegExpMatchArray} match - the current match 480 */function doEndMatch(e){const t=e[0];const i=n.substring(e.index);const o=endOfMode(d,e,i);if(!o)return C;const s=d;if(d.endScope&&d.endScope._wrap){processBuffer();emitKeyword(t,d.endScope._wrap)}else if(d.endScope&&d.endScope._multi){processBuffer();emitMultiClass(d.endScope,e)}else if(s.skip)m+=t;else{s.returnEnd||s.excludeEnd||(m+=t);processBuffer();s.excludeEnd&&(m=t)}do{d.scope&&p.closeNode();d.skip||d.subLanguage||(b+=d.relevance);d=d.parent}while(d!==o.parent);o.starts&&startNewMode(o.starts,e);return s.returnEnd?0:t.length}function processContinuations(){const e=[];for(let t=d;t!==g;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach((e=>p.openNode(e)))} 481/** @type {{type?: MatchType, index?: number, rule?: Mode}}} */let l={}; 482/** 483 * Process an individual match 484 * 485 * @param {string} textBeforeMatch - text preceding the match (since the last match) 486 * @param {EnhancedMatch} [match] - the match itself 487 */function processLexeme(t,s){const r=s&&s[0];m+=t;if(r==null){processBuffer();return 0}if(l.type==="begin"&&s.type==="end"&&l.index===s.index&&r===""){m+=n.slice(s.index,s.index+1);if(!o){ 488/** @type {AnnotatedError} */ 489const t=new Error(`0 width match regex (${e})`);t.languageName=e;t.badRule=l.rule;throw t}return 1}l=s;if(s.type==="begin")return doBeginMatch(s);if(s.type==="illegal"&&!i){ 490/** @type {AnnotatedError} */ 491const e=new Error('Illegal lexeme "'+r+'" for mode "'+(d.scope||"<unnamed>")+'"');e.mode=d;throw e}if(s.type==="end"){const e=doEndMatch(s);if(e!==C)return e}if(s.type==="illegal"&&r==="")return 1;if(x>1e5&&x>s.index*3){const e=new Error("potential infinite loop, way more iterations than matches");throw e}m+=r;return r.length}const g=getLanguage(e);if(!g){error(s.replace("{}",e));throw new Error('Unknown language: "'+e+'"')}const u=compileLanguage(g);let h=""; 492/** @type {CompiledMode} */let d=r||u; 493/** @type Record<string,CompiledMode> */const f={};const p=new a.__emitter(a);processContinuations();let m="";let b=0;let w=0;let x=0;let y=false;try{if(g.__emitTokens)g.__emitTokens(n,p);else{d.matcher.considerAll();for(;;){x++;y?y=false:d.matcher.considerAll();d.matcher.lastIndex=w;const e=d.matcher.exec(n);if(!e)break;const t=n.substring(w,e.index);const i=processLexeme(t,e);w=e.index+i}processLexeme(n.substring(w))}p.finalize();h=p.toHTML();return{language:e,value:h,relevance:b,illegal:false,_emitter:p,_top:d}}catch(t){if(t.message&&t.message.includes("Illegal"))return{language:e,value:B(n),illegal:true,relevance:0,_illegalBy:{message:t.message,index:w,context:n.slice(w-100,w+100),mode:t.mode,resultSoFar:h},_emitter:p};if(o)return{language:e,value:B(n),illegal:false,relevance:0,errorRaised:t,_emitter:p,_top:d};throw t}} 494/** 495 * returns a valid highlight result, without actually doing any actual work, 496 * auto highlight starts with this and it's possible for small snippets that 497 * auto-detection may not find a better match 498 * @param {string} code 499 * @returns {HighlightResult} 500 */function justTextHighlightResult(e){const t={value:B(e),illegal:false,relevance:0,_top:r,_emitter:new a.__emitter(a)};t._emitter.addText(e);return t} 501/** 502 Highlighting with language detection. Accepts a string with the code to 503 highlight. Returns an object with the following properties: 504 505 - language (detected language) 506 - relevance (int) 507 - value (an HTML string with highlighting markup) 508 - secondBest (object with the same structure for second-best heuristically 509 detected language, may be absent) 510 511 @param {string} code 512 @param {Array<string>} [languageSubset] 513 @returns {AutoHighlightResult} 514 */function highlightAuto(e,n){n=n||a.languages||Object.keys(t);const i=justTextHighlightResult(e);const o=n.filter(getLanguage).filter(autoDetection).map((t=>_highlight(t,e,false)));o.unshift(i);const s=o.sort(((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(getLanguage(e.language).supersetOf===t.language)return 1;if(getLanguage(t.language).supersetOf===e.language)return-1}return 0}));const[r,c]=s; 515/** @type {AutoHighlightResult} */const l=r;l.secondBest=c;return l} 516/**
517 * Builds new class name for block given the language name 518 * 519 * @param {HTMLElement} element 520 * @param {string} [currentLang] 521 * @param {string} [resultLang] 522 */function updateClassName(e,t,i){const o=t&&n[t]||i;e.classList.add("hljs");e.classList.add(`language-${o}`)} 523/** 524 * Applies highlighting to a DOM node containing code. 525 * 526 * @param {HighlightedHTMLElement} element - the HTML element to highlight 527 */function highlightElement(e){ 528/** @type HTMLElement */ 529let t=null;const n=blockLanguage(e);if(shouldNotHighlight(n))return;fire("before:highlightElement",{el:e,language:n});if(e.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);return}if(e.children.length>0){if(!a.ignoreUnescapedHTML){console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk.");console.warn("https://github.com/highlightjs/highlight.js/wiki/security");console.warn("The element with unescaped HTML:");console.warn(e)}if(a.throwUnescapedHTML){const t=new HTMLInjectionError("One of your co
529de blocks includes unescaped HTML.",e.innerHTML);throw t}}t=e;const i=t.textContent;const o=n?highlight(i,{language:n,ignoreIllegals:true}):highlightAuto(i);e.innerHTML=o.value;e.dataset.highlighted="yes";updateClassName(e,n,o.language);e.result={language:o.language,re:o.relevance,relevance:o.relevance};o.secondBest&&(e.secondBest={language:o.secondBest.language,relevance:o.secondBest.relevance});fire("after:highlightElement",{el:e,result:o,text:i})} 530/** 531 * Updates highlight.js global options with the passed options 532 * 533 * @param {Partial<HLJSOptions>} userOptions 534 */function configure(e){a=H(a,e)}const initHighlighting=()=>{highlightAll();deprecated("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function initHighlightingOnLoad(){highlightAll();deprecated("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let c=false;function highlightAll(){if(document.readyState==="loading"){c=true;return}const e=document.querySelectorAll(a.cssSelector);e.forEach(highlightElement)}function boot(){c&&highlightAll()}typeof window!=="undefined"&&window.addEventListener&&window.addEventListener("DOMContentLoaded",boot,false) 535/** 536 * Register a language grammar module 537 * 538 * @param {string} languageName 539 * @param {LanguageFn} languageDefinition 540 */;function registerLanguage(n,i){let s=null;try{s=i(e)}catch(e){error("Language definition for '{}' could not be registered.".replace("{}",n));if(!o)throw e;error(e);s=r}s.name||(s.name=n);t[n]=s;s.rawDefinition=i.bind(null,e);s.aliases&®isterAliases(s.aliases,{languageName:n})} 541/** 542 * Remove a language grammar module 543 * 544 * @param {string} languageName 545 */function unregisterLanguage(e){delete t[e];for(const t of Object.keys(n))n[t]===e&&delete n[t]} 546/** 547 * @returns {string[]} List of language internal names 548 */function listLanguages(){return Object.keys(t)} 549/** 550 * @param {string} name - name of the language to retrieve 551 * @returns {Language | undefined} 552 */function getLanguage(e){e=(e||"").toLowerCase();return t[e]||t[n[e]]} 553/** 554 * 555 * @param {string|string[]} aliasList - single alias or list of aliases 556 * @param {{languageName: string}} opts 557 */function registerAliases(e,{languageName:t}){typeof e==="string"&&(e=[e]);e.forEach((e=>{n[e.toLowerCase()]=t}))} 558/** 559 * Determines if a given language has auto-detection enabled 560 * @param {string} name - name of the language 561 */function autoDetection(e){const t=getLanguage(e);return t&&!t.disableAutodetect} 562/** 563 * Upgrades the old highlightBlock plugins to the new 564 * highlightElement API 565 * @param {HLJSPlugin} plugin 566 */function upgradePluginAPI(e){e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=t=>{e["before:highlightBlock"](Object.assign({block:t.el},t))});e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=t=>{e["after:highlightBlock"](Object.assign({block:t.el},t))})} 567/** 568 * @param {HLJSPlugin} plugin 569 */function addPlugin(e){upgradePluginAPI(e);i.push(e)} 570/** 571 * @param {HLJSPlugin} plugin 572 */function removePlugin(e){const t=i.indexOf(e);t!==-1&&i.splice(t,1)} 573/** 574 * 575 * @param {PluginEvent} event 576 * @param {any} args 577 */function fire(e,t){const n=e;i.forEach((function(e){e[n]&&e[n](t)}))} 578/** 579 * DEPRECATED 580 * @param {HighlightedHTMLElement} el 581 */function deprecateHighlightBlock(e){deprecated("10.7.0","highlightBlock will be removed entirely in v12.0");deprecated("10.7.0","Please use highlightElement now.");return highlightElement(e)}Object.assign(e,{highlight:highlight,highlightAuto:highlightAuto,highlightAll:highlightAll,highlightElement:highlightElement,highlightBlock:deprecateHighlightBlock,configure:configure,initHighlighting:initHighlighting,initHighlightingOnLoad:initHighlightingOnLoad,registerLanguage:registerLanguage,unregisterLanguage:unregisterLanguage,listLanguages:listLanguages,getLanguage:getLanguage,registerAliases:registerAliases,autoDetection:autoDetection,inherit:H,addPlugin:addPlugin,removePlugin:removePlugin});e.debugMode=function(){o=false};e.safeMode=function(){o=true};e.versionString=I;e.regex={concat:concat,lookahead:lookahead,either:either,optional:optional,anyNumberOfTimes:anyNumberOfTimes};for(const e in R)typeof R[e]==="object"&&deepFreeze(R[e]);Object.assign(e,R);return e};const D=HLJS({});D.newInstance=()=>HLJS({});var $=D;D.HighlightJS=D;D.default=D;var K=getDefaultExportFromCjs($);function parseNodes(e,t=[]){return e.map((e=>{const n=[...t,...e.properties?e.properties.className:[]];return e.children?parseNodes(e.children,n):{text:e.value,classes:n}})).flat()}function getHighlightNodes(e){return e.value||e.children||[]}function registered(e){return Boolean(K.getLanguage(e))}function getDecorations({doc:e,name:n,lowlight:i,defaultLanguage:r}){const a=[];t(e,(e=>
581e.type.name===n)).forEach((e=>{var t;let n=e.pos+1;const s=e.node.attrs.language||r;const c=i.listLanguages();const l=s&&(c.includes(s)||registered(s)||((t=i.registered)===null||t===void 0?void 0:t.call(i,s)))?getHighlightNodes(i.highlight(s,e.node.textContent)):getHighlightNodes(i.highlightAuto(e.node.textContent));parseNodes(l).forEach((e=>{const t=n+e.text.length;if(e.classes.length){const i=o.inline(n,t,{class:e.classes.join(" ")});a.push(i)}n=t}))}));return s.create(e,a)}function isFunction(e){return typeof e==="function"}function LowlightPlugin({name:e,lowlight:o,defaultLanguage:s}){if(!["highlight","highlightAuto","listLanguages"].every((e=>isFunction(o[e]))))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new n({key:new i("lowlight"),state:{init:(t,{doc:n})=>getDecorations({doc:n,name:e,lowlight:o,defaultLanguage:s}),apply:(n,i,r,a)=>{const c=r.selection.$head.parent.type.name;const l=a.selection.$head.parent.type.name;const g=t(r.doc,(t=>t.type.name===e));const u=t(a.doc,(t=>t.type.name===e));return n.docChanged&&([c,l].includes(e)||u.length!==g.length||n.steps.some((e=>e.from!==void 0&&e.to!==void 0&&g.some((t=>t.pos>=e.from&&t.pos+t.node.nodeSize<=e.to)))))?getDecorations({doc:n.doc,name:e,lowlight:o,defaultLanguage:s}):i.map(n.mapping,n.doc)}},props:{decorations(e){return r.getState(e)}}});return r}const U=e.extend({addOptions(){var e;return{...(e=this.parent)===null||e===void 0?void 0:e.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:true,exitOnArrowDown:true,defaultLanguage:null,HTMLAttributes:{}}},addProseMirrorPlugins(){var e;return[...((e=this.parent)===null||e===void 0?void 0:e.call(this))||[],LowlightPlugin({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}});export{U as CodeBlockLowlight,U as default}; 582
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.