Golang HTTP LaTeX compiler server
- fasthttp serve a HTTP server with a POST
text/plain
route at/latex-to-svg
- saves a
.tex
file - pdflatex compiles
.tex
and output.pdf
- pdf2svg converts
.pdf
to.svg
- minify minifies
.svg
- finally, responds SVG content with
image/svg+xml
header
docker build -t=go-tex2svg .
docker run -d -p 4000:4000 tex2svg
curl -d "$\\frac{1}{2}$" http://localhost:4000/latex
fetch('http://localhost:4000/latex-to-svg', {method: 'POST', body: '$\\frac{1}{2}$'})
.then(res => res.text())
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="6.09pt" height="16.543pt" viewBox="0 0 6.09 16.543"><defs><g><symbol overflow="visible" id="glyph0-0"><path style="stroke:none;" d="M2.390625-1.265625v-.125c0-.8125 1.203125-1.390625 1.203125-2.5C3.59375-4.65625 2.9375-5 2.203125-5 1.453125-5 .9375-4.578125.9375-3.96875c0 .359375.140625.53125.390625.53125.171875.0.328125-.109375.328125-.328125C1.65625-4.0625 1.5-4.0625 1.5-4.3125c0-.234375.203125-.40625.640625-.40625.484375.0.78125.265625.78125.859375.0 1.140625-.828125 1.421875-.828125 2.390625v.203125zm.28125.90625c0-.234375-.15625-.4375-.421875-.4375s-.4375.203125-.4375.4375c0 .25.140625.421875.4375.421875.265625.0.421875-.1875.421875-.421875zm1.765625 1.625v-7.125H.078125v7.125zm-.375-.40625H.453125v-6.34375H4.0625zm0 0"/></symbol><symbol overflow="visible" id="glyph0-1"><path style="stroke:none;" d="M3.1875.0V-.203125c-.6875.0-.96875-.140625-.96875-.5v-4.0625H2l-1.453125.40625v.25c.234375-.078125.625-.125.765625-.125.1875.0.25.109375.25.359375V-.703125c0 .359375-.265625.5-.96875.5V0zm0 0"/></symbol><symbol overflow="visible" id="glyph0-2"><path style="stroke:none;" d="M3.46875-1.1875H3.25c-.171875.4375-.265625.59375-.671875.59375H1.546875l-.53125.03125V-.609375l1-.921875c.78125-.8125 1.203125-1.328125 1.203125-1.984375.0-.78125-.578125-1.296875-1.421875-1.296875-.734375.0-1.234375.421875-1.46875 1.140625l.1875.078125c.265625-.5625.59375-.734375 1.078125-.734375.578125.0.9375.359375.9375.921875.0.78125-.375 1.25-1.109375 2.015625L.28125-.25V0h2.9375zm0 0"/></symbol></g><clipPath id="clip1"><path d="M1 11H5v5.542969H1zm0 0"/></clipPath></defs><g id="surface1"><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph0-1" x="1.195" y="4.887"/></g><path style="fill:none;stroke-width:0.677;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M3125e-7-53125e-8H3.699531" transform="matrix(1,0,0,-1,1.195,8.144)"/><g clip-path="url(#clip1)" clip-rule="nonzero"><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph0-2" x="1.195" y="16.543"/></g></g></g></svg>
curl -d "$\\frac{\\hbar^2}{2m}\\nabla^2\\Psi+V(\\mathbf{r})\\Psi=-i\\hbar\\frac{\\partial\\Psi}{\\partial t}$" http://localhost:4000/latex-to-svg
fetch('http://localhost:4000/latex-to-svg', {method: 'POST', body: '$\\frac{\\hbar^2}{2m}\\nabla^2\\Psi+V(\\mathbf{r})\\Psi=-i\\hbar\\frac{\\partial\\Psi}{\\partial t}$'})
.then(res => res.text())
<svg xmlns="http://www.w3.org/2000/svg" style="zoom:2" xmlns:xlink="http://www.w3.org/1999/xlink" width="109.703pt" height="18.33pt" viewBox="0 0 109.703 18.33"><defs><g><symbol overflow="visible" id="glyph0-0"><path style="stroke:none;" d="M2.390625-1.265625v-.125c0-.8125 1.203125-1.390625 1.203125-2.5C3.59375-4.65625 2.9375-5 2.203125-5 1.453125-5 .9375-4.578125.9375-3.96875c0 .359375.140625.53125.390625.53125.171875.0.328125-.109375.328125-.328125C1.65625-4.0625 1.5-4.0625 1.5-4.3125c0-.234375.203125-.40625.640625-.40625.484375.0.78125.265625.78125.859375.0 1.140625-.828125 1.421875-.828125 2.390625v.203125zm.28125.90625c0-.234375-.15625-.4375-.421875-.4375s-.4375.203125-.4375.4375c0 .25.140625.421875.4375.421875.265625.0.421875-.1875.421875-.421875zm1.765625 1.625v-7.125H.078125v7.125zm-.375-.40625H.453125v-6.34375H4.0625zm0 0"/></symbol><symbol overflow="visible" id="glyph0-1"><path style="stroke:none;" d="M3.9375-.84375c-.109375.15625-.28125.390625-.546875.390625-.109375.0-.15625-.0625-.15625-.140625s.03125-.171875.03125-.171875L3.6875-2.5c.03125-.09375.0625-.359375.0625-.546875.0-.265625-.109375-.53125-.484375-.53125C2.375-3.578125 1.703125-2.5 1.375-1.9375H1.328125L1.78125-4H3.140625l.0625-.28125H1.859375l.21875-.984375H1.90625L.875-5.1875v.203125S1.015625-5 1.125-5c.171875.0.234375.078125.234375.1875s-.015625.25-.015625.25l-.0625.28125H.671875L.609375-4H1.21875l-.875 4h.625l.265625-1.1875c.234375-.515625 1.109375-1.859375 1.65625-1.859375.171875.0.21875.140625.21875.3125.0.140625-.046875.359375-.046875.359375L2.625-.65625c-.015625.03125-.046875.171875-.046875.296875.0.21875.125.4375.484375.4375.546875.0.84375-.53125 1.03125-.796875zm0 0"/></symbol><symbol overflow="visible" id="glyph0-2"><path style="stroke:none;" d="M3.46875-1.1875H3.25c-.171875.4375-.265625.59375-.671875.59375H1.546875l-.53125.03125V-.609375l1-.921875c.78125-.8125 1.203125-1.328125 1.203125-1.984375.0-.78125-.578125-1.296875-1.421875-1.296875-.734375.0-1.234375.421875-1.46875 1.140625l.1875.078125c.265625-.5625.59375-.734375 1.078125-.734375.578125.0.9375.359375.9375.921875.0.78125-.375 1.25-1.109375 2.015625L.28125-.25V0h2.9375zm0 0"/></symbol><symbol overflow="visible" id="glyph0-3"><path style="stroke:none;" d="M3.015625.0 3.25-1.03125c.28125-.671875 1.140625-2.015625 1.59375-2.015625.171875.0.234375.140625.234375.3125.0.15625-.078125.4375-.125.625l-.375 1.453125C4.5625-.625 4.53125-.484375 4.53125-.359375c0 .21875.109375.4375.5.4375.53125.0.828125-.53125 1.015625-.796875l-.140625-.125c-.125.15625-.3125.390625-.5625.390625-.09375.0-.140625-.0625-.140625-.140625s.015625-.171875.015625-.171875L5.625-2.5c.03125-.09375.078125-.359375.078125-.546875.0-.265625-.109375-.53125-.46875-.53125-.78125.0-1.390625 1-1.71875 1.5625h-.0625L3.578125-2.5c.015625-.03125.078125-.328125.078125-.546875.0-.265625-.09375-.53125-.46875-.53125-.859375.0-1.484375 1.046875-1.8125 1.640625H1.328125l.375-1.625H1.53125L.5-3.46875v.203125S.640625-3.28125.734375-3.28125c.171875.0.234375.0625.234375.203125.0.109375-.015625.234375-.015625.234375L.34375.0h.625L1.1875-1.015625c.375-.84375 1.125-2.03125 1.609375-2.03125.171875.0.234375.140625.234375.3125.0.109375-.046875.28125-.046875.3125-.1875.8125-.375 1.625-.59375 2.421875zm0 0"/></symbol><symbol overflow="visible" id="glyph0-4"><path style="stroke:none;" d="M2.1875-3.59375C.96875-3.59375.265625-2.4375.265625-1.125.265625-.234375.65625.109375 1.25.109375c1.734375.0 2.15625-2.0625 2.15625-3.921875.0-1.09375-.453125-1.5-1.03125-1.5-.4375.0-.84375.234375-1.1875.625l.125.125c.25-.15625.546875-.203125.75-.203125.65625.0 1.015625.46875 1.015625 1.15625.0.171875-.015625.296875-.03125.515625H2.96875c-.1875-.3125-.421875-.5-.78125-.5zm.625 1.5625c0 1.078125-.71875 1.5-1.421875 1.5-.390625.0-.75-.203125-.75-.84375.0-.828125.515625-1.578125 1.390625-1.578125.546875.0.78125.375.78125.921875zm0 0"/></symbol><symbol overflow="visible" id="glyph0-5"><path style="stroke:none;" d="M2.359375-1.875C1.40625-1.875 1.1875-2.546875 1.1875-3.140625c0-.25.015625-.609375.015625-.796875.0-.5625-.359375-.96875-1.046875-.96875h-.125v.21875H.109375c.375.0.40625.3125.40625.640625.0.3125-.015625.5625-.015625.984375.0.984375.953125 1.46875 1.859375 1.484375v.59375c0 .65625-.078125.765625-.75.765625V0h2.15625V-.21875c-.65625.0-.734375-.125-.734375-.765625v-.59375c.9375-.015625 1.859375-.546875 1.859375-1.53125.0-.328125-.015625-.6875-.015625-.953125.0-.3125.03125-.625.390625-.625H5.34375v-.21875H5.234375C4.5625-4.90625 4.1875-4.5 4.1875-3.9375c0 .15625.015625.546875.015625.796875.0.59375-.265625 1.25-1.171875 1.265625V-3.921875c0-.578125.015625-.765625.734375-.765625v-.21875H1.609375v.21875c.71875.0.75.1875.75.765625zm0 0"/></symbol><symbol overflow="visible" id="glyph0-6"><path style="stroke:none;" d="M2.359375-3.53125H1.625l.203125-.890625H1.59375c-.375.640625-.546875.78125-1.03125 1.03125l-.03125.15625h.4375L.453125-.75c-.015625.046875-.0625.296875-.0625.421875C.390625-.09375.53125.0625.84375.0625c.59375.0.90625-.546875 1.125-.84375L1.828125-.890625C1.5625-.546875 1.40625-.4375 1.1875-.4375c-.109375.0-.125-.078125-.125-.15625.0-.125.046875-.375.046875-.375L1.5625-3.234375h.734375zm0 0"/></symbol><symbol overflow="visible" id="glyph1-0"><path style="stroke:none;" d="M1.921875-1.015625v-.09375c0-.65625.953125-1.125.953125-2C2.875-3.734375 2.359375-4 1.765625-4S.75-3.65625.75-3.171875c0 .28125.125.40625.3125.40625.140625.0.265625-.078125.265625-.25.0-.234375-.125-.234375-.125-.4375.0-.1875.15625-.328125.515625-.328125.375.0.625.21875.625.6875.0.921875-.671875 1.140625-.671875 1.921875v.15625zm.21875.734375c0-.1875-.125-.359375-.328125-.359375-.234375.0-.359375.15625-.359375.359375.0.1875.109375.328125.34375.328125.21875.0.34375-.140625.34375-.328125zM3.5625 1.015625v-5.71875h-3.5v5.71875zM3.25.6875H.359375V-4.390625H3.25zm0 0"/></symbol><symbol overflow="visible" id="glyph1-1"><path style="stroke:none;" d="M2.78125-.953125H2.609375c-.140625.359375-.21875.484375-.53125.484375h-.84375L.8125-.453125v-.03125l.796875-.75C2.25-1.875 2.578125-2.28125 2.578125-2.8125c0-.640625-.46875-1.046875-1.140625-1.046875-.578125.0-.984375.34375-1.171875.921875L.40625-2.875c.21875-.453125.484375-.59375.875-.59375.453125.0.75.296875.75.734375.0.640625-.296875 1.015625-.890625 1.625l-.90625.90625V0h2.34375zm0 0"/></symbol><symbol overflow="visible" id="glyph2-0"><path style="stroke:none;" d="M3.1875-1.6875v-.171875C3.1875-2.9375 4.796875-3.71875 4.796875-5.1875c0-1.03125-.875-1.484375-1.84375-1.484375-1.015625.0-1.703125.578125-1.703125 1.375.0.46875.203125.703125.515625.703125.234375.0.453125-.125.453125-.4375C2.21875-5.40625 2-5.421875 2-5.75c0-.3125.265625-.546875.859375-.546875.640625.0 1.03125.359375 1.03125 1.140625.0 1.53125-1.09375 1.90625-1.09375 3.203125V-1.6875zm.375 1.203125c0-.296875-.203125-.578125-.546875-.578125-.375.0-.59375.265625-.59375.578125.0.328125.1875.5625.578125.5625.359375.0.5625-.234375.5625-.5625zM5.9375 1.6875V-7.828125H.09375V1.6875zm-.53125-.53125H.609375V-7.3125H5.40625zm0 0"/></symbol><symbol overflow="visible" id="glyph2-1"><path style="stroke:none;" d="M6.8125-6.765625H.640625L3.65625.125H3.875zm-.65625.421875L4.015625-1.296875l-2.125-5.046875zm0 0"/></symbol><symbol overflow="visible" id="glyph2-2"><path style="stroke:none;" d="M3.140625-2.5c-1.25.0-1.5625-.90625-1.5625-1.6875.0-.34375.03125-.828125.03125-1.078125.0-.734375-.46875-1.28125-1.40625-1.28125H.046875V-6.25h.09375c.5.0.546875.421875.546875.84375.0.4375-.03125.765625-.03125 1.3125.0 1.3125 1.28125 1.96875 2.484375 1.984375V-1.3125c0 .890625-.09375 1.015625-1 1.015625V0H5.03125V-.296875c-.875.0-.984375-.171875-.984375-1.015625v-.796875c1.25-.015625 2.46875-.71875 2.46875-2.046875.0-.4375-.015625-.90625-.015625-1.25.0-.4375.046875-.84375.53125-.84375H7.125v-.296875H6.984375c-.90625.0-1.40625.546875-1.40625 1.296875.0.203125.03125.71875.03125 1.0625.0.78125-.34375 1.671875-1.5625 1.6875V-5.234375c0-.78125.015625-1.015625.984375-1.015625v-.296875h-2.875V-6.25c.9375.0.984375.234375.984375 1.015625zm0 0"/></symbol><symbol overflow="visible" id="glyph2-3"><path style="stroke:none;" d="M6.5625-2.25v-.671875H3.953125V-5.5625h-.71875v2.640625H.625V-2.25H3.234375V.40625h.71875V-2.25zm0 0"/></symbol><symbol overflow="visible" id="glyph2-4"><path style="stroke:none;" d="M2.53125-1.25H2.484375L2.40625-2.40625 2.109375-5.25c0-.078125-.03125-.296875-.03125-.359375C2.046875-6.0625 2.375-6.25 2.875-6.25l.03125-.296875H.46875L.453125-6.25c.53125.0.6875.234375.765625.90625L1.78125.046875h.328125L5.765625-5.1875C6.375-6.09375 6.578125-6.25 7.125-6.25l.015625-.296875H4.984375L4.96875-6.25c.4375.0.59375.0625.59375.265625.0.15625-.125.375-.3125.65625zm0 0"/></symbol><symbol overflow="visible" id="glyph2-5"><path style="stroke:none;" d="M.421875-2.734375c0 2.203125 1.046875 3.765625 2.65625 4.59375l.15625-.28125C1.78125.625 1.25-.734375 1.25-2.734375c0-1.984375.53125-3.3125 1.984375-4.28125l-.15625-.265625C1.46875-6.453125.421875-4.90625.421875-2.734375zm0 0"/></symbol><symbol overflow="visible" id="glyph2-6"><path style="stroke:none;" d="M2.265625-4.8125H1.75L.171875-4.5v.4375s.125-.03125.3125-.03125c.359375.0.421875.203125.421875.5625v2.4375c0 .5625-.09375.6875-.734375.6875V0h3.09375V-.40625c-.71875.0-.96875-.109375-.96875-.75V-3.203125c.21875-.265625.4375-.453125.65625-.453125.15625.0.390625.421875.828125.421875.296875.0.609375-.234375.609375-.8125.0-.515625-.25-.8125-.765625-.8125-.640625.0-.78125.390625-1.3125 1.09375H2.265625zm0 0"/></symbol><symbol overflow="visible" id="glyph2-7"><path style="stroke:none;" d="M3.125-2.734375c0-2.171875-1.046875-3.71875-2.65625-4.546875L.3125-7.015625c1.453125.96875 1.984375 2.296875 1.984375 4.28125.0 2-.53125 3.359375-1.984375 4.3125l.15625.28125C2.078125 1.03125 3.125-.53125 3.125-2.734375zm0 0"/></symbol><symbol overflow="visible" id="glyph2-8"><path style="stroke:none;" d="M6.5625-3.265625V-3.9375H.625v.671875zm0 2.046875v-.671875H.625v.671875zm0 0"/></symbol><symbol overflow="visible" id="glyph2-9"><path style="stroke:none;" d="M6.5625-2.25v-.671875H.625V-2.25zm0 0"/></symbol><symbol overflow="visible" id="glyph2-10"><path style="stroke:none;" d="M2.421875-6.078125c0-.328125-.203125-.546875-.53125-.546875s-.53125.203125-.53125.546875.203125.53125.53125.53125.53125-.1875.53125-.53125zM2.1875-4.75H1.96875L.5625-4.640625v.28125s.171875-.03125.34375-.03125c.265625.0.3125.15625.3125.296875.0.171875-.015625.3125-.015625.3125L.6875-1.421875c-.125.59375-.171875.8125-.171875.984375.0.34375.234375.53125.625.53125.65625.0 1.046875-.5625 1.40625-1.046875l-.203125-.15625c-.15625.1875-.4375.515625-.765625.515625-.125.0-.1875-.046875-.1875-.1875s.0625-.421875.0625-.421875zm0 0"/></symbol><symbol overflow="visible" id="glyph2-11"><path style="stroke:none;" d="M5.265625-1.109375c-.15625.1875-.390625.515625-.75.515625-.125.0-.1875-.078125-.1875-.1875.0-.125.03125-.25.03125-.25l.5625-2.296875c.03125-.140625.09375-.484375.09375-.734375.0-.359375-.15625-.71875-.65625-.71875-1.171875.0-2.09375 1.453125-2.515625 2.203125H1.765625L2.375-5.34375H4.1875l.078125-.375H2.46875l.296875-1.3125h-.21875l-1.375.109375v.265625s.1875-.015625.328125-.015625c.21875.0.3125.09375.3125.25s-.03125.34375-.03125.34375l-.078125.359375H.90625l-.09375.375H1.625L.46875.0h.8125l.359375-1.578125C1.96875-2.265625 3.125-4.0625 3.859375-4.0625c.234375.0.296875.171875.296875.40625.0.203125-.0625.46875-.0625.46875L3.5-.875c-.015625.046875-.046875.234375-.046875.390625.0.296875.140625.578125.640625.578125.71875.0 1.125-.6875 1.375-1.0625zm0 0"/></symbol></g><clipPath id="clip1"><path d="M1 13H5v5.328125H1zm0 0"/></clipPath><clipPath id="clip2"><path d="M5 14h6v4.328125H5zm0 0"/></clipPath><clipPath id="clip3"><path d="M1e2 12h4v6.328125h-4zm0 0"/></clipPath><clipPath id="clip4"><path d="M104 13h3v5.328125h-3zm0 0"/></clipPath></defs><g id="surface1"><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph0-1" x="2.366" y="6.599"/></g><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph1-1" x="6.618" y="3.909"/></g><path style="fill:none;stroke-width:0.677;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M3125e-7.00153125H10.051094" transform="matrix(1,0,0,-1,1.195,9.857)"/><g clip-path="url(#clip1)" clip-rule="nonzero"><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph0-2" x="1.195" y="18.255"/></g></g><g clip-path="url(#clip2)" clip-rule="nonzero"><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph0-3" x="4.894" y="18.255"/></g></g><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph2-1" x="12.441" y="12.427"/></g><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph0-2" x="19.893" y="8.841"/></g><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph2-2" x="24.09" y="12.427"/></g><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph2-3" x="33.474769" y="12.427"/></g><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph2-4" x="42.864" y="12.427"/></g><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph2-5" x="50.246" y="12.427"/></g><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph2-6" x="53.793" y="12.427"/></g><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph2-7" x="58.624" y="12.427"/><use xlink:href="#glyph2-2" x="62.170686" y="12.427"/></g><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph2-8" x="72.11336" y="12.427"/></g><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph2-9" x="82.056035" y="12.427"/></g><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph2-10" x="89.225" y="12.427"/></g><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph2-11" x="92.303443" y="12.427"/></g><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph0-4" x="99.168" y="6.599"/></g><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph0-5" x="103.128" y="6.599"/></g><path style="fill:none;stroke-width:0.677;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M-3125e-8.00153125H9.339813" transform="matrix(1,0,0,-1,99.168,9.857)"/><g clip-path="url(#clip3)" clip-rule="nonzero"><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph0-4" x="100.483" y="18.255"/></g></g><g clip-path="url(#clip4)" clip-rule="nonzero"><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"><use xlink:href="#glyph0-6" x="104.44316" y="18.255"/></g></g></g></svg>