-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Thanks for making this mathb.in replacement! It's a shame the original wasn't converted to a client-side only application like this tool.
I have some suggestions and feature requests after using your tool:
1. Increase max length to 2000 characters.
Virtually all browsers support at least 2000 characters.
2. Compress before base64 encoding.
I did some experimentation with different Javascript compression libraries and found I could get about 33% space-savings with Brotli + base64 against my sample LaTex. Results are below:
[evan@blackbox mathbin] python compression.py
LZMA + base64url: 331
Zlib + base64url: 239
Brotli + base64url: 224
Base91 (no compression): 331
LZString URI encoded: 285
Source code
#!/usr/bin/env python3
import lzma
import zlib
import brotli
import base64
import base91
from lzstring import LZString
text = r"""
\frac{\partial V}{\partial t} + \frac{1}{2} \sigma^2 S^2 \frac{\partial^2 V}{\partial S^2} + r S \frac{\partial V}{\partial S} - rV = 0
\frac{d}{dx} (x^n) = n x^{n-1}
\nabla \cdot \mathbf{E} = \frac{\rho}{\varepsilon_0}
The quick brown fox jumped over the lazy dog."""
def base64url_encode(data: bytes) -> str:
return base64.urlsafe_b64encode(data).decode().rstrip("=")
# --- 1. LZMA ---
lzma_compressed = lzma.compress(text.encode())
print("LZMA + base64url:", len(base64url_encode(lzma_compressed)))
# --- 2. Zlib (like Pako) ---
zlib_compressed = zlib.compress(text.encode())
print("Zlib + base64url:", len(base64url_encode(zlib_compressed)))
# --- 3. Brotli ---
brotli_compressed = brotli.compress(text.encode())
print("Brotli + base64url:", len(base64url_encode(brotli_compressed)))
# --- 4. Base91 only (no compression) ---
base91_encoded = base91.encode(text.encode())
print("Base91 (no compression):", len(base91_encoded))
# --- 5. LZString (JS-compatible) ---
lz = LZString()
lzstring_encoded = lz.compressToEncodedURIComponent(text)
print("LZString URI encoded:", len(lzstring_encoded))3. Support Typst
Typst is a LaTeX alternative that is gaining some popularity and I've been using it exclusively lately. It's a bit simpler than LaTeX and it also has a Javascript library. Here is an example of it being used in the wild.
4. Shorten domain name
Maybe somethink like mathshare.github.io (taken) or mathshare.js.org would be easier to remember and type in manually but still be free?