Latex formula expressions into usable data in the server
Language and extensions
- node.js
- Mathjax ( document links )
- MathJax solutions at NodeJS GitHub ) (
- SVG into a picture or extended
Ready to work
- Installation nodejs
- Installation Mathjax-node extension ( GitHub )
- The pictures SVG extensions ( PKRA / MathJax-the Node-svg2png )
Paste the code
var mjAPI = require('mathjax-node-svg2png'); mjAPI.config({ displayMessages: false, // determines whether Message.Set() calls are logged displayErrors: true, // determines whether error messages are shown on the console undefinedCharError: false, // determines whether "unknown characters" (i.e., no glyph in the configured fonts) are saved in the error array extensions: '', // a convenience option to add MathJax extensions fontURL: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/fonts/HTML-CSS', // for webfont urls in the CSS for HTML output paths: {}, // configures custom path variables (e.g., for third party extensions, cf. test/config-third-party-extensions.js) MathJax: { showProcessingMessages: false, messageStyle: "none", extensions: ["tex2jax.js"], jax: ["input/TeX", "output/HTML-CSS"], tex2jax: { //inlineMath: [ ['$','$'], ["\\(","\\)"] ], displayMath: [ ['$$','$$'], ["\\[","\\]"] ], processEscapes: true }, "HTML-CSS": { fonts: ["TeX"], showMathMenu: false } } // standard MathJax configuration options, see https://docs.mathjax.org for more detail. }); mjAPI.start(); var math = ' \\triangle ABC , AC\\bot BC , AC=8\\rm cm , BC=4\\rm cm , AP\\bot AC , A , D , E '; mjAPI.typeset({ math: math, format: 'inline-TeX', svg: false, //关闭SVG转换 png: true// open images converted into other reference GitHUb If set Scale: . 1 , @ HTML: to true, }, function (Data) { the console.log ( 'Data:' ) the console.log (Data); } )
When other language development, program changes can be invoked through the command line program
var Math = '\\ Triangle the ABC, the BC BOT \\ the AC, the AC. 8 cm & lt RM = \\, the BC = \\. 4 cm & lt RM, the AC BOT \\ the AP, A, D, E' ; // modify var Math process.argv = [2 ]; // the CLI command node xxx.js "formula word" exemplary: the test.js Node " \ Triangle the ABC, the AC \ BOT the BC, the AC =. 8 \ cm & lt RM, the BC =. 4 \ cm & lt RM , the AP \ BOT AC, A, D, E "
You can also modify into other communication agreement
Record it