#!/bin/bash set -e echo "Building BoxJax with tcolorbox support" # Test if LaTeX packages are available echo "Testing if required packages are available..." mkdir -p build cd build cat > tcolorbox_test.tex << EOF \\documentclass{article} \\usepackage{tikz} \\usepackage[most]{tcolorbox} \\tcbuselibrary{skins,breakable,theorems} \\begin{document} \\begin{tcolorbox}[title=Test Box] This is a test of tcolorbox \\end{tcolorbox} \\end{document} EOF pdflatex -interaction=nonstopmode tcolorbox_test.tex if [ $? -eq 0 ]; then echo "LaTeX packages successfully loaded" else echo "Error: Missing LaTeX packages. Please install tcolorbox package." exit 1 fi cd .. # Build WebAssembly files from web2js echo "Building WebAssembly files from web2js..." cd web2js # Install dependencies npm install || echo "⚠️ Some npm install errors occurred, but continuing..." # Check if required build tools are available if ! command -v node &> /dev/null; then echo "Error: Node.js is required but not found" exit 1 fi # Build the WebAssembly file echo "Building tex-async.wasm..." node ./compile.js texk/web2c/tex.web tex.ch > tex-async.js npx webpack-cli tex-async.js -o tex-async.js mv tex-async.js tex-async.wasm # Create the core dump echo "Creating core.dump..." node initex.js # Compress the core dump echo "Compressing core.dump to core.dump.gz..." gzip -c core.dump > core.dump.gz # Copy the WebAssembly files to the public directories echo "Copying WebAssembly files to the public directory..." cd .. mkdir -p ../../static/js/boxjax cp web2js/tex-async.wasm ../../static/js/boxjax/tex.wasm cp web2js/core.dump.gz ../../static/js/boxjax/ # Build the BoxJax JavaScript echo "Building BoxJax JavaScript..." npm run build # Copy the JavaScript and CSS files echo "Copying files to the static/js/boxjax directory..." cp public/boxjax.js ../../static/js/boxjax/ cp fonts.css ../../static/js/boxjax/ echo "Done! Files have been deployed to /static/js/boxjax/" echo "Update your BoxJax.js to use local files instead of TikZJax CDN"