Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
Replacing LaTeX expressions Between Dollar Signs by Divs in Electron Application with React

Overview

Hi guys,

I'm trying to create a WYSIWYG LaTeX editor using Electron with React, but I've come across a problem while attempting to replace math expressions between dollar signs by KaTeX components.

The Problem

My wish is to get something like Overleaf's rich text editor, which displays what's between $...$ as MathJax. In order to accomplish a simillar result, I've come up with the idea of using React states and Regex for, everytime the user inputs anything new, checking if there are any of those math expressions wrapped between the aforesaid signs. However, I couldn't create anything that can work around the fact that what is between expressions between dollar signs is also between them.

Part of My Code

export default function WYSIWYGEditor(){
  const [text, setText] = useState<string>('')
  const [latexInText, setLatexInText] = useState<String[]>([])
  const editorElement = document.getElementById('t')
  useEffect(()=>{
    setLatexInText((text.match(/(\${1,2})((?:\\.|[\s\S])*)\1/g)))
    console.log(latexInText ? String(latexInText[0]).split('$') : '0')
  }, [text])
  return (
    <div>
        <div contentEditable={true} id='t' onInput={()=>setText(document.getElementById('t').innerHTML)} style={{display: 'inline', maxWidth: '40%'}}>
            Math here
        </div>
    </div>
   )}

Don't know if this is any useful, but there the code goes. So far, I'm only trying to console log the math expressions, but I also want to replace them by divs where I can render a component from KaTeX library. Pretty much like what happens on Overleaf.

Sorry if I'm being too vague, this is my first question here and I'm kinda new to StackOverflow, stil learning. Please, let me know if I should specify anything.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda