UNPKG

@lexical/code

Version:

This package contains the functionality for the code blocks and code highlighting for Lexical.

10 lines (8 loc) 18.9 kB
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import{isHTMLElement as t,addClassNamesToElement as e,removeClassNamesFromElement as n,$getAdjacentCaret as r,mergeRegister as i}from"@lexical/utils";import{ElementNode as o,$createParagraphNode as s,$isTextNode as l,$isTabNode as u,$createTabNode as c,$createLineBreakNode as g,$create as a,TextNode as f,$applyNodeReplacement as p,$getSiblingCaret as h,getTextDirection as d,$isElementNode as m,$isLineBreakNode as y,defineExtension as x,$createTextNode as _,$getNodeByKey as S,$getSelection as v,$isRangeSelection as T,$createPoint as b,INDENT_CONTENT_COMMAND as C,OUTDENT_CONTENT_COMMAND as N,INSERT_TAB_COMMAND as j,$setSelectionFromCaretRange as w,$getCaretRangeInDirection as k,$getCaretRange as A,$getTextPointCaret as P,$normalizeCaret as L,KEY_ARROW_UP_COMMAND as O,MOVE_TO_START as H,KEY_TAB_COMMAND as E,COMMAND_PRIORITY_LOW as z,$insertNodes as B,KEY_ARROW_DOWN_COMMAND as D,MOVE_TO_END as F}from"lexical";import"prismjs";import"prismjs/components/prism-clike.js";import"prismjs/components/prism-javascript.js";import"prismjs/components/prism-markup.js";import"prismjs/components/prism-markdown.js";import"prismjs/components/prism-c.js";import"prismjs/components/prism-css.js";import"prismjs/components/prism-objectivec.js";import"prismjs/components/prism-sql.js";import"prismjs/components/prism-powershell.js";import"prismjs/components/prism-python.js";import"prismjs/components/prism-rust.js";import"prismjs/components/prism-swift.js";import"prismjs/components/prism-typescript.js";import"prismjs/components/prism-java.js";import"prismjs/components/prism-cpp.js";function I(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const M="javascript",J=()=>M;function R(e,n){for(const r of e.childNodes){if(t(r)&&r.tagName===n)return!0;R(r,n)}return!1}const K="data-language",$="data-highlight-language",W="data-theme";class q extends o{__language;__theme;__isSyntaxHighlightSupported;static getType(){return"code"}static clone(t){return new q(t.__language,t.__key)}constructor(t,e){super(e),this.__language=t||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(t){super.afterCloneFrom(t),this.__language=t.__language,this.__theme=t.__theme,this.__isSyntaxHighlightSupported=t.__isSyntaxHighlightSupported}createDOM(t){const n=document.createElement("code");e(n,t.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(K,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute($,r));const i=this.getTheme();i&&n.setAttribute(W,i);const o=this.getStyle();return o&&n.setAttribute("style",o),n}updateDOM(t,e,n){const r=this.__language,i=t.__language;r?r!==i&&e.setAttribute(K,r):i&&e.removeAttribute(K);const o=this.__isSyntaxHighlightSupported;t.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&e.setAttribute($,r):e.removeAttribute($):o&&r&&e.setAttribute($,r);const s=this.__theme,l=t.__theme;s?s!==l&&e.setAttribute(W,s):l&&e.removeAttribute(W);const u=this.__style,c=t.__style;return u?u!==c&&e.setAttribute("style",u):c&&e.removeAttribute("style"),!1}exportDOM(t){const n=document.createElement("pre");e(n,t._config.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(K,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute($,r));const i=this.getTheme();i&&n.setAttribute(W,i);const o=this.getStyle();return o&&n.setAttribute("style",o),{element:n}}static importDOM(){return{code:t=>null!=t.textContent&&(/\r?\n/.test(t.textContent)||R(t,"BR"))?{conversion:Q,priority:1}:null,div:()=>({conversion:G,priority:1}),pre:()=>({conversion:Q,priority:0}),table:t=>tt(t)?{conversion:V,priority:3}:null,td:t=>{const e=t,n=e.closest("table");return e.classList.contains("js-file-line")||n&&tt(n)?{conversion:Y,priority:3}:null},tr:t=>{const e=t.closest("table");return e&&tt(e)?{conversion:Y,priority:3}:null}}}static importJSON(t){return U().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setLanguage(t.language).setTheme(t.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(t,e=!0){const n=this.getChildren(),r=n.length;if(r>=2&&"\n"===n[r-1].getTextContent()&&"\n"===n[r-2].getTextContent()&&t.isCollapsed()&&t.anchor.key===this.__key&&t.anchor.offset===r){n[r-1].remove(),n[r-2].remove();const t=s();return this.insertAfter(t,e),t}const{anchor:i,focus:o}=t,a=(i.isBefore(o)?i:o).getNode();if(l(a)){let t=st(a);const e=[];for(;;)if(u(t))e.push(c()),t=t.getNextSibling();else{if(!it(t))break;{let n=0;const r=t.getTextContent(),i=t.getTextContentSize();for(;n<i&&" "===r[n];)n++;if(0!==n&&e.push(rt(" ".repeat(n))),n!==i)break;t=t.getNextSibling()}}const n=a.splitText(i.offset)[0],r=0===i.offset?0:1,o=n.getIndexWithinParent()+r,s=a.getParentOrThrow(),l=[g(),...e];s.splice(o,0,l);const f=e[e.length-1];f?f.select():0===i.offset?n.selectPrevious():n.getNextSibling().selectNext(0,0)}if(X(a)){const{offset:e}=t.anchor;a.splice(e,0,[g()]),a.select(e+1,e+1)}return null}canIndent(){return!1}collapseAtStart(){const t=s();return this.getChildren().forEach(e=>t.append(e)),this.replace(t),!0}setLanguage(t){const e=this.getWritable();return e.__language=t||void 0,e}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(t){const e=this.getWritable();return e.__isSyntaxHighlightSupported=t,e}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(t){const e=this.getWritable();return e.__theme=t||void 0,e}getTheme(){return this.getLatest().__theme}}function U(t,e){return a(q).setLanguage(t).setTheme(e)}function X(t){return t instanceof q}function Q(t){return{node:U(t.getAttribute(K))}}function G(t){const e=t,n=Z(e);return n||function(t){let e=t.parentElement;for(;null!==e;){if(Z(e))return!0;e=e.parentElement}return!1}(e)?{node:n?U():null}:{node:null}}function V(){return{node:U()}}function Y(){return{node:null}}function Z(t){return null!==t.style.fontFamily.match("monospace")}function tt(t){return t.classList.contains("js-file-line-container")}class et extends f{__highlightType;constructor(t="",e,n){super(t,n),this.__highlightType=e}static getType(){return"code-highlight"}static clone(t){return new et(t.__text,t.__highlightType||void 0,t.__key)}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(t){const e=this.getWritable();return e.__highlightType=t||void 0,e}canHaveFormat(){return!1}createDOM(t){const n=super.createDOM(t),r=nt(t.theme,this.__highlightType);return e(n,r),n}updateDOM(t,r,i){const o=super.updateDOM(t,r,i),s=nt(i.theme,t.__highlightType),l=nt(i.theme,this.__highlightType);return s!==l&&(s&&n(r,s),l&&e(r,l)),o}static importJSON(t){return rt().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setHighlightType(t.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(t){return this}isParentRequired(){return!0}createParentElementNode(){return U()}}function nt(t,e){return e&&t&&t.codeHighlight&&t.codeHighlight[e]}function rt(t="",e){return p(new et(t,e))}function it(t){return t instanceof et}function ot(t,e){let n=t;for(let i=h(t,e);i&&(it(i.origin)||u(i.origin));i=r(i))n=i.origin;return n}function st(t){return ot(t,"previous")}function lt(t){return ot(t,"next")}function ut(t){const e=st(t),n=lt(t);let r=e;for(;null!==r;){if(it(r)){const t=d(r.getTextContent());if(null!==t)return t}if(r===n)break;r=r.getNextSibling()}const i=e.getParent();if(m(i)){const t=i.getDirection();if("ltr"===t||"rtl"===t)return t}return null}function ct(t,e){let n=null,r=null,i=t,o=e,s=t.getTextContent();for(;;){if(0===o){if(i=i.getPreviousSibling(),null===i)break;if(it(i)||u(i)||y(i)||I(167),y(i)){n={node:i,offset:1};break}o=Math.max(0,i.getTextContentSize()-1),s=i.getTextContent()}else o--;const t=s[o];it(i)&&" "!==t&&(r={node:i,offset:o})}if(null!==r)return r;let l=null;if(e<t.getTextContentSize())it(t)&&(l=t.getTextContent()[e]);else{const e=t.getNextSibling();it(e)&&(l=e.getTextContent()[0])}if(null!==l&&" "!==l)return n;{const r=function(t,e){let n=t,r=e,i=t.getTextContent(),o=t.getTextContentSize();for(;;){if(!it(n)||r===o){if(n=n.getNextSibling(),null===n||y(n))return null;it(n)&&(r=0,i=n.getTextContent(),o=n.getTextContentSize())}if(it(n)){if(" "!==i[r])return{node:n,offset:r};r++}}}(t,e);return null!==r?r:n}}function gt(t){const e=lt(t);return y(e)&&I(168),e}const at=x({name:"@lexical/code",nodes:[q,et]});!function(t){t.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d.*$/m]};var e={"deleted-sign":"-","deleted-arrow":"<","inserted-sign":"+","inserted-arrow":">",unchanged:" ",diff:"!"};Object.keys(e).forEach(function(n){var r=e[n],i=[];/^\w+$/.test(n)||i.push(/\w+/.exec(n)[0]),"diff"===n&&i.push("bold"),t.languages.diff[n]={pattern:RegExp("^(?:["+r+"].*(?:\r\n?|\n|(?![\\s\\S])))+","m"),alias:i,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:!0},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(n)[0]}}}}),Object.defineProperty(t.languages.diff,"PREFIXES",{value:e})}(Prism);const ft=globalThis.Prism||window.Prism,pt={c:"C",clike:"C-like",cpp:"C++",css:"CSS",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",powershell:"PowerShell",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},ht={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function dt(t){return ht[t]||t}function mt(t){const e=dt(t);return pt[e]||e}const yt=()=>Object.keys(ft.languages).filter(t=>"function"!=typeof ft.languages[t]).sort();function xt(){const t=[];for(const[e,n]of Object.entries(pt))t.push([e,n]);return t}function _t(){return[]}function St(t){return"string"==typeof t?t:Array.isArray(t)?t.map(St).join(""):St(t.content)}function vt(t,e){const n=/^diff-([\w-]+)/i.exec(e),r=t.getTextContent();let i=ft.tokenize(r,ft.languages[n?"diff":e]);return n&&(i=function(t,e){const n=e,r=ft.languages[n],i={tokens:t},o=ft.languages.diff.PREFIXES;for(const t of i.tokens){if("string"==typeof t||!(t.type in o)||!Array.isArray(t.content))continue;const e=t.type;let n=0;const i=()=>(n++,new ft.Token("prefix",o[e],e.replace(/^(\w+).*/,"$1"))),s=t.content.filter(t=>"string"==typeof t||"prefix"!==t.type),l=t.content.length-s.length,u=ft.tokenize(St(s),r);u.unshift(i());const c=/\r\n|\n/g,g=t=>{const e=[];c.lastIndex=0;let r,o=0;for(;n<l&&(r=c.exec(t));){const n=r.index+r[0].length;e.push(t.slice(o,n)),o=n,e.push(i())}if(0!==e.length)return o<t.length&&e.push(t.slice(o)),e},a=t=>{for(let e=0;e<t.length&&n<l;e++){const n=t[e];if("string"==typeof n){const r=g(n);r&&(t.splice(e,1,...r),e+=r.length-1)}else if("string"==typeof n.content){const t=g(n.content);t&&(n.content=t)}else Array.isArray(n.content)?a(n.content):a([n.content])}};a(u),n<l&&u.push(i()),t.content=u}return i.tokens}(i,n[1])),Tt(i)}function Tt(t,e){const n=[];for(const r of t)if("string"==typeof r){const t=r.split(/(\n|\t)/),i=t.length;for(let r=0;r<i;r++){const i=t[r];"\n"===i||"\r\n"===i?n.push(g()):"\t"===i?n.push(c()):i.length>0&&n.push(rt(i,e))}}else{const{content:t,alias:e}=r;"string"==typeof t?n.push(...Tt([t],"prefix"===r.type&&"string"==typeof e?e:r.type)):Array.isArray(t)&&n.push(...Tt(t,"unchanged"===r.type?void 0:r.type))}return n}const bt={$tokenize(t,e){return vt(t,e||this.defaultLanguage)},defaultLanguage:M,tokenize(t,e){return ft.tokenize(t,ft.languages[e||""]||ft.languages[this.defaultLanguage])}};function Ct(t,e,n){const r=t.getParent();X(r)?wt(r,e,n):it(t)&&t.replace(_(t.__text))}function Nt(t,e){const n=e.getElementByKey(t.getKey());if(null===n)return;const r=t.getChildren(),i=r.length;if(i===n.__cachedChildrenLength)return;n.__cachedChildrenLength=i;let o="1",s=1;for(let t=0;t<i;t++)y(r[t])&&(o+="\n"+ ++s);n.setAttribute("data-gutter",o)}const jt=new Set;function wt(t,e,n){const r=t.getKey();void 0===t.getLanguage()&&t.setLanguage(n.defaultLanguage);const i=t.getLanguage()||n.defaultLanguage;if(!function(t){const e=function(t){const e=/^diff-([\w-]+)/i.exec(t);return e?e[1]:null}(t),n=e||t;try{return!!n&&ft.languages.hasOwnProperty(n)}catch(t){return!1}}(i))return t.getIsSyntaxHighlightSupported()&&t.setIsSyntaxHighlightSupported(!1),void async function(){}();t.getIsSyntaxHighlightSupported()||t.setIsSyntaxHighlightSupported(!0),jt.has(r)||(jt.add(r),e.update(()=>{!function(t,e){const n=S(t);if(!X(n)||!n.isAttached())return;const r=v();if(!T(r))return void e();const i=r.anchor,o=i.offset,s="element"===i.type&&y(n.getChildAtIndex(i.offset-1));let u=0;if(!s){const t=i.getNode();u=o+t.getPreviousSiblings().reduce((t,e)=>t+e.getTextContentSize(),0)}if(!e())return;if(s)return void i.getNode().select(o,o);n.getChildren().some(t=>{const e=l(t);if(e||y(t)){const n=t.getTextContentSize();if(e&&n>=u)return t.select(u,u),!0;u-=n}return!1})}(r,()=>{const e=S(r);if(!X(e)||!e.isAttached())return!1;const i=e.getLanguage()||n.defaultLanguage,o=n.$tokenize(e,i),s=function(t,e){let n=0;for(;n<t.length&&kt(t[n],e[n]);)n++;const r=t.length,i=e.length,o=Math.min(r,i)-n;let s=0;for(;s<o;)if(s++,!kt(t[r-s],e[i-s])){s--;break}const l=n,u=r-s,c=e.slice(n,i-s);return{from:l,nodesForReplacement:c,to:u}}(e.getChildren(),o),{from:l,to:u,nodesForReplacement:c}=s;return!(l===u&&!c.length)&&(t.splice(l,u-l,c),!0)})},{onUpdate:()=>{jt.delete(r)},skipTransforms:!0}))}function kt(t,e){return it(t)&&it(e)&&t.__text===e.__text&&t.__highlightType===e.__highlightType||u(t)&&u(e)||y(t)&&y(e)}function At(t){if(!T(t))return!1;const e=t.anchor.getNode(),n=X(e)?e:e.getParent(),r=t.focus.getNode(),i=X(r)?r:r.getParent();return X(n)&&n.is(i)}function Pt(t){const e=t.getNodes(),n=[];if(1===e.length&&X(e[0]))return n;let r=[];for(let t=0;t<e.length;t++){const i=e[t];it(i)||u(i)||y(i)||I(169),y(i)?r.length>0&&(n.push(r),r=[]):r.push(i)}if(r.length>0){const e=t.isBackward()?t.anchor:t.focus,i=b(r[0].getKey(),0,"text");e.is(i)||n.push(r)}return n}function Lt(t){const e=v();if(!T(e)||!At(e))return!1;const n=Pt(e),r=n.length;if(0===r&&e.isCollapsed())return t===C&&e.insertNodes([c()]),!0;if(0===r&&t===C&&"\n"===e.getTextContent()){const t=c(),n=g(),r=e.isBackward()?"previous":"next";return e.insertNodes([t,n]),w(k(A(P(t,"next",0),L(h(n,"next"))),r)),!0}for(let i=0;i<r;i++){const r=n[i];if(r.length>0){let n=r[0];if(0===i&&(n=st(n)),t===C){const t=c();if(n.insertBefore(t),0===i){const r=e.isBackward()?"focus":"anchor",i=b(n.getKey(),0,"text");e[r].is(i)&&e[r].set(t.getKey(),0,"text")}}else u(n)&&n.remove()}}return!0}function Ot(t,e){const n=v();if(!T(n))return!1;const{anchor:r,focus:i}=n,o=r.offset,s=i.offset,l=r.getNode(),c=i.getNode(),g=t===O;if(!At(n)||!it(l)&&!u(l)||!it(c)&&!u(c))return!1;if(!e.altKey){if(n.isCollapsed()){const t=l.getParentOrThrow();if(g&&0===o&&null===l.getPreviousSibling()){if(null===t.getPreviousSibling())return t.selectPrevious(),e.preventDefault(),!0}else if(!g&&o===l.getTextContentSize()&&null===l.getNextSibling()){if(null===t.getNextSibling())return t.selectNext(),e.preventDefault(),!0}}return!1}let a,f;if(l.isBefore(c)?(a=st(l),f=lt(c)):(a=st(c),f=lt(l)),null==a||null==f)return!1;const p=a.getNodesBetween(f);for(let t=0;t<p.length;t++){const e=p[t];if(!it(e)&&!u(e)&&!y(e))return!1}e.preventDefault(),e.stopPropagation();const h=g?a.getPreviousSibling():f.getNextSibling();if(!y(h))return!0;const d=g?h.getPreviousSibling():h.getNextSibling();if(null==d)return!0;const m=it(d)||u(d)||y(d)?g?st(d):lt(d):null;let x=null!=m?m:d;return h.remove(),p.forEach(t=>t.remove()),t===O?(p.forEach(t=>x.insertBefore(t)),x.insertBefore(h)):(x.insertAfter(h),x=h,p.forEach(t=>{x.insertAfter(t),x=t})),n.setTextNodeRange(l,o,c,s),!0}function Ht(t,e){const n=v();if(!T(n))return!1;const{anchor:r,focus:i}=n,o=r.getNode(),s=i.getNode(),l=t===H;if(!At(n)||!it(o)&&!u(o)||!it(s)&&!u(s))return!1;const c=s;if("rtl"===ut(c)?!l:l){const t=ct(c,i.offset);if(null!==t){const{node:e,offset:r}=t;y(e)?e.selectNext(0,0):n.setTextNodeRange(e,r,e,r)}else c.getParentOrThrow().selectStart()}else{gt(c).select()}return e.preventDefault(),e.stopPropagation(),!0}function Et(t,e){if(!t.hasNodes([q,et]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");null==e&&(e=bt);const n=[];return!0!==t._headless&&n.push(t.registerMutationListener(q,e=>{t.getEditorState().read(()=>{for(const[n,r]of e)if("destroyed"!==r){const e=S(n);null!==e&&Nt(e,t)}})},{skipInitialization:!1})),n.push(t.registerNodeTransform(q,n=>wt(n,t,e)),t.registerNodeTransform(f,n=>Ct(n,t,e)),t.registerNodeTransform(et,n=>Ct(n,t,e)),t.registerCommand(E,e=>{const n=function(t){const e=v();if(!T(e)||!At(e))return null;const n=t?N:C,r=t?N:j,i=e.anchor,o=e.focus;if(i.is(o))return r;const s=Pt(e);if(1!==s.length)return n;const l=s[0];let u,c;0===l.length&&I(285),e.isBackward()?(u=o,c=i):(u=i,c=o);const g=st(l[0]),a=lt(l[0]),f=b(g.getKey(),0,"text"),p=b(a.getKey(),a.getTextContentSize(),"text");return u.isBefore(f)||p.isBefore(c)?n:f.isBefore(u)||c.isBefore(p)?r:n}(e.shiftKey);return null!==n&&(e.preventDefault(),t.dispatchCommand(n,void 0),!0)},z),t.registerCommand(j,()=>!!At(v())&&(B([c()]),!0),z),t.registerCommand(C,t=>Lt(C),z),t.registerCommand(N,t=>Lt(N),z),t.registerCommand(O,t=>{const e=v();if(!T(e))return!1;const{anchor:n}=e,r=n.getNode();return!!At(e)&&(e.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&X(r.getParentOrThrow())?(t.preventDefault(),!0):Ot(O,t))},z),t.registerCommand(D,t=>{const e=v();if(!T(e))return!1;const{anchor:n}=e,r=n.getNode();return!!At(e)&&(e.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&X(r.getParentOrThrow())?(t.preventDefault(),!0):Ot(D,t))},z),t.registerCommand(H,t=>Ht(H,t),z),t.registerCommand(F,t=>Ht(F,t),z)),i(...n)}const zt=st,Bt=lt,Dt=gt,Ft=ct;export{rt as $createCodeHighlightNode,U as $createCodeNode,ut as $getCodeLineDirection,gt as $getEndOfCodeInLine,st as $getFirstCodeNodeOfLine,lt as $getLastCodeNodeOfLine,ct as $getStartOfCodeInLine,it as $isCodeHighlightNode,X as $isCodeNode,pt as CODE_LANGUAGE_FRIENDLY_NAME_MAP,ht as CODE_LANGUAGE_MAP,at as CodeExtension,et as CodeHighlightNode,q as CodeNode,M as DEFAULT_CODE_LANGUAGE,bt as PrismTokenizer,xt as getCodeLanguageOptions,yt as getCodeLanguages,_t as getCodeThemeOptions,J as getDefaultCodeLanguage,Dt as getEndOfCodeInLine,zt as getFirstCodeNodeOfLine,mt as getLanguageFriendlyName,Bt as getLastCodeNodeOfLine,Ft as getStartOfCodeInLine,dt as normalizeCodeLang,dt as normalizeCodeLanguage,Et as registerCodeHighlighting};