Git Product home page Git Product logo

svgtex's Introduction

svgtex

Using MathJax and PhantomJS to create SVGs on server side with minimum overhead.

This is just an idea, algorithm and it's proof of concept. If you want to use such system in production, take a look at this fork too: https://github.com/gwicke/mathoid !

MathJax is a great tool! Why not use it on a server side too? To avoid loading the whole phantomjs and MathJax into memory with every call, the service is exposed via HTTP.

Detailed usage instructions are on the GitHub wiki. For quick-start instructions, keep reading.

Then, start the server:

$ phantomjs main.js

Loading bench page index.html
Server started on port 16000
Point your brownser at http://localhost:16000 for a test form.

Try it out by pointing your browser at http://localhost:16000/, and using the test form to enter an equation in either TeX or MathML.

Or, from a different console, use curl:

$ curl localhost:16000/?q=x

<svg xmlns:xlink="http://www.w3.org/1999/xlink" style="width: 1.34ex; height: 1.099ex; ...

Or, try this MathML example: http://localhost:16000/?type=mml&q=%3Cmath%3E%3Cmfrac%3E%3Cmi%3Ey%3C%2Fmi%3E%3Cmn%3E2%3C%2Fmn%3E%3C%2Fmfrac%3E%3C%2Fmath%3E.

Loading MathJax from the CDN vs locally

By default, this loads MathJax from the MathJax CDN. That means that the server uses an internet connection, and it loads MathJax once, as the server is started.

To use a local version of MathJax instead, first download and extract MathJax into the mathjax subdirectory (or wherever else you would like):

wget https://github.com/mathjax/MathJax/zipball/v2.3-latest -O mathjax.zip
unzip mathjax.zip
mv mathjax-MathJax-* mathjax

Then uncomment the <script> element in index.html that refers to this local version, and comment out the one that loads from the CDN.

Stability

Experimental.

Read https://github.com/agrbin/svgtex/wiki for more details!

svgtex's People

Contributors

agrbin avatar klortho avatar mhartl avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.