UNPKG

on-codemerge

Version:

A WYSIWYG editor for on-codemerge is a user-friendly interface that allows users to edit and view their code in real time, exactly as it will appear in the final product

2 lines (1 loc) 990 B
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../../../_virtual/mathjax.cjs"),g=require("../../../../_virtual/tex.cjs"),l=require("../../../../_virtual/svg.cjs"),h=require("../../../../_virtual/liteAdaptor.cjs"),d=require("../../../../_virtual/html.cjs"),a=h.liteAdaptorExports.liteAdaptor();d.htmlExports.RegisterHTMLHandler(a);const u=new g.texExports.TeX({packages:["base","ams"]}),m=new l.svgExports.SVG({fontCache:"local"}),x=i.mathjaxExports.mathjax.document("",{InputJax:u,OutputJax:m});class p{async renderMath(n,r){const t=new Image;try{const e=x.convert(n,{display:!0}),s=a.outerHTML(e).match(/<svg[^>]*>[\s\S]*<\/svg>/);if(!s)throw new Error("Invalid SVG structure");const o=s[0],c=encodeURIComponent(o);t.className="svg-img",t.src=`data:image/svg+xml;charset=utf-8,${c}`,t.width=r.width,t.height=r.height}catch(e){console.error("MathJax rendering error:",e),t.alt="Invalid math expression"}return t}}exports.MathRenderer=p;