Overview

I had the opportunity to highlight LaTeX in Monaco Editor, so here are my notes.

This is a follow-up to the following article that targeted Ace Editor.

I hope this serves as a useful reference.

Screenshot

Demo Site

https://nakamura196.github.io/ace_latex/monaco/

Repository

https://github.com/nakamura196/ace_latex/

Source Code

<<%!h\\\\\/Dt<<uuubehOmhbsss\en/tCle<<<<ho<<<<eeeg{{dbmTammtledhdsspppi{/olYldeeiihray2iis/ccr}r}faaand}sd>Pa>tttnred>>vdtdrre)e)uccc{ocyEnaalkel>M=yiiiqp};qmm}m}m};nrkkkdcr>gef=o"lvppua,uoo)o)o)ceaaaouih=cn>="nce>ttitvinnt};nbir]c;nvltw;ttgggcmpt"haM"sao=>rhsrRaRao,Daanu,oaaahoiueeeu}}etmeamohtcn"ses:eececkr]ecshl{{{{{{lclneror{[{mn>lnrentyotwr.:(gogoeo,foeeeoougmdnnhdfet>"s=atlaicc"[i.i.no[[[[[[[[i.:rsttttttr.eueWivon}>e"cpeEid=o{h"slslit////////nei:oooooose:a:rg`rint`tvossdnt"ntvtataz:((((((((ed"tkkkkkk:dgae\apt};=i:hiehhftsenene\\\\d%iv:[eeeeeeige"pt\gs}"eE/etr:tip/rgrgr[\{}[].atsnnnnnn{te:m:Cdi]Uwd/eo"tgseuu:[[))))c*o"t::::::}otyoon{Tpictr1p(:daaaaa///u)nr,r,rC"TtdcogFotd"0s{/igg{-w,,,,m/e.u"""""".olhreu,r-ronL0:/tnetez\e,wdecnbbkccdaeu(mca8tr.a%/coesosAu""""ne,oorreoretme)eip""jT;/drw.k.-3bbbbt"tfmtaayme(ee,ndhDsecn/resZ0rrrr|chimeccwma)x"{t}icedXhd.elene]0aaaadoena"ekoet,",ccome<enjdagst+0ccccvmmen,"erne,lsnol/i.siniM)-eekkimeTd,tdt(a}t<ihgjdtgspo""eepeh"f"""dse/v2hseoutrn,u]]ttsnte,of,,,osntr>tdlraeoa9,,"")thmroc{ti.:ei.grvr"F]]/"aeferfffut=tnlvme(iccF,,,]t(ogeooomb"le6ira{dhoF,"rrgrrreowet0v.ieTm]"cmeoreeenoi>/0rnnirom+koyguogggtkdnp.e"dka)enTrnurrr.}tpxnt]:fen/ythodnoooghm;e/,ond,wCaeu:duuue=/tn"rs"ooimn:nnntdmb/pflP]"rmned"dddEeoonmuatr,ndms":#":::lvnrp/ntho"e,2Feiadmmceevt]no"1F"""mcce/otxie,tn{#900##eeormni"ld"slF60049n--:oaoaeL]y4FFFCEtwencn}nra,43FFA9Bid1ao)g(Tr3""FFEydipc-;u"eLu3F59IttxoealXal6}}"0Edho-dgaTe",,""(,rsei{etcLes}"@odteoaX},}}ci0lioxmTt,,,on.itr"mekhni4do@,aXeaNBtt0r0nytorai.l@.{dcwtaBia0i04soomLecrKCnl/g.0mraaseaeoe-mh4.mdtTscymrsit00asceikwm"cng./nhXnieoe)a/r0mdntrn,lva/istcbsdtesymnholmss{=/"i/imuai1envsmegnii.d/saenn0iv"lnnc"ts,adtyggo/nsaarrrlgnea/ouieyeaannddgieertreo.drm.imna.ijns."m>i<n/\.s\ccsrsi{"pt>}

The following page was helpful for configuring custom languages.

https://microsoft.github.io/monaco-editor/playground.html?source=v0.40.0#example-extending-language-services-custom-languages

Also, using ChatGPT was convenient for creating the rules.

I hope this serves as a useful reference for others.