michael-brade / LaTeX.js

JavaScript LaTeX to HTML5 translator
https://latex.js.org
MIT License
770 stars 58 forks source link

How can we integrate Latex with React or any other UI framework? #147

Open RohitKuwar opened 9 months ago

RohitKuwar commented 9 months ago

I want to create Latex.js with existing React project. There I have to create runtime environment for latex just like playground. For which I am going through Latex documentation. In documentation I got code snippet which is not working for me. It is giving me an error can not find module 'fs' for svgdom package.

import { parse, HtmlGenerator } from 'latex.js'
import { createHTMLWindow } from 'svgdom'

global.window = createHTMLWindow()
global.document = window.document

let latex = "Hi, this is a line of text."

let generator = new HtmlGenerator({ hyphenate: false })

let doc = parse(latex, { generator: generator }).htmlDocument()

console.log(doc.documentElement.outerHTML)

Please provide detail information here or in docs. Thank you.