How to use mathjax from command line? - javascript

I was hoping to use Mathjax to render some mathjax snippets into svg files.
At this point I believe that a command in the form
<javascript interpter> <Mathjax jax file> 'mathjax snippet here'
should work, I'm not sure what jax file I'm supposed to pick and how to set the output mode that I want, or how to configure mathjax in general when calling it from the command line.
I need this because I have to render this math expressions offline without a browser.

See this post on the MathJax forum for some code that does this using Phantom.js (there are some subtleties to be considered, so look at the code carefully if you need to modify it). Several others have taken this further. The svgtex project listed in that conversation apparently has been discontinued in favor of the Mathoid project that underlies Wikimedia's latest math support code.
EDIT: there is now the MathJax-node project that uses node.js to run MathJax via the command line or via your own node.js code.

I think you can use nodejs with some wrappers for MathJax - https://www.npmjs.org/search?q=Mathjax

Hey I am not expert in mathjax. but i read have read a article on it. I am passing some links to you. One of which is a documentation of it. Hope it helps you.
documentation pdf. and second one

Related

HTML5 Boilerplate build scripts doesn't replace script tags in index.html

I am just getting started with the HTML5 boilerplate build script and I am having some problems. Basically all my scripts are minified and compressed as I would hope, but all of the original <script> tags are left in the output index.html. What I need is for it to replace these tags with a reference to the minified js file. I thought this should happen by default. Maybe I am doing something wrong?
I ended up rolling my own build script with rake and the javascript closure compiler. It was pretty easy actually.
I guess the code responsible for replacing is in the build.xml file target -usemin especially this code.
If it is so then it searches for comment region marked with //-beg- concat_js and //-end- concat_js as is described as must-have in the quick start section.
Also make sure that you have set the file.root.script property in the project.properties file to the script you really use (default value expects main.js)
Running ant -debug >log.txt helps me a lot.
You can find helpful answer by searching through existing issues at GitHub, especially the article https://github.com/h5bp/ant-build-script/wiki/How-to-bypass-the-automatic-script-concatenation seems to be roblarsen's final answer to script concatenation problems.
I ended up with my custom Node.js build script that runs wintersmith and HTML5 Boilerplate build script, does some configuration of those tools and it works.

Generating Haxe externs for EaselJS

Being new to both JavaScript and Haxe, this may have a simple answer, but I've discovered that Haxe has externs port on GoogleCode for EaselJS, but they are out of date and correspond to an earlier version. I've been able to fix errors as they occur during compile time, but I'm still wary that I didn't catch al the new variables and function names.
My question is: is there a simple way to generate externs for a large JS library like EaselJS?
You might want to take a look at Joshua Granick's work with BuildJS:
http://www.joshuagranick.com/blog/2011/10/14/use-buildjs-to-make-externs-for-haxe-js-automatically/
Basically there's a tool called JSDuck which is supposed to compile documentation for JavaScript libraries, and it can output to JSON. He's used the output from JSON, combined with his "buildjs" library to build haxe externs.
He's used it for Sencha Touch, and I've used it for ExtJS, but both of those are Sencha products and their coding style is known to work with JSDuck. You can give it a go with EaselJS, if it works then BuildJS should generate pretty accurate externs.
Otherwise, you might try find the author of the original EaselJS externs and see if they can provide an update, or give you help creating an accurate update. Most of the haxe developers you can contact easily enough using the mailing list or google groups:
http://groups.google.com/group/haxelang?hl=en
I'm a bit late with the answer but you can find the latest (v0.5.0) externs for EaselJs here:
https://github.com/Fintan/easelhx
I generated them using BuildHx (https://github.com/jgranick/buildhx) which is now able to parse YUIDoc comments and then tested them by porting some of the code samples that accompany the EaselJs source.
Right, I did try and install Joshua's tool, but I'm running into an issue with JSDuck.
In the example you linked to, JSDuck is supposed to have a --json param, but the latest version seems to have deprecated that. I'm trying some others using the config file:
{
"--out": "out",
"--guides": "json",
"--warnings": ["all"],
"--": [
"src/easeljs/"
]}
But that doesn't work. The guides param seems to fail no matter what I try.
Creating the json file gives me this ouput:
C:/Users/mycmp/AppData/Local/Temp/ocr374A.tmp/lib/ruby/gems/1.8/gems/jsduck-3.3.0/lib/jsduck/json_duck.rb:36:in `read': Permission denied - K:/Vault/Haxe/myproj/json (Errno::EACCES)
So I'm not sure what to do next. It'd be great to get this working for lots of libraries.
By the way, I'm using the latest JSDuck and Windows 7.

compress js files like compass with css (SASS)

Is there something like Compass but for javascript? I'm interested in a tool where it will take the main js files and all the other files that are included and compress it to a new js file with all the code on 1 line as soon as you save your changes in whatever file you are working.
Compass includes that functionality. For instance, I use bootstrap.js for one of my projects. I watch the file with Compass and have it minify the file into bootstrap-ck.js, which is the file I refer to in my production code.
I've attached an image which should show you the details. Notice that you can do imports just as you would with Sass or Less.
You'll also be able to have it check the code through JSHint or JSLint. If you're having issues, you can check the Compass documentation or open your config.rb file to see the Compass details for that particular project.
Hope that helps.
You're looking for a Javascript minifier. There are a whole bunch of them to choose from. Try this one or this one, or google for "javascript minifier" for more.
Note that in addition to simply putting all the code on one line, these tools also rename your variables and functions to shorter names, and do a few other tricks to make the code as tiny as possible. The end result should be functionally identical to your original code, but it won't be exactly the same as the code you wrote.
You have a tool from yahoo
http://developer.yahoo.com/yui/compressor/
And you also have a .net tool (if you're working with .net) for this compressor
http://yuicompressor.codeplex.com/
Another recommendation would be UglifyJS

Which library does GitHub use to beautify JavaScript code?

Which library does GitHub use to beautify JavaScript code?
I am looking for a good code prettify library.
http://help.github.com/troubleshooting-common-issues/
We use the excellent pygments library for our syntax highlighting. Check their list of supported languages and learn how to specify a lexer for yours. If you contribute a lexer back to pygments, let us know and we’ll make sure it’s made available here on GitHub.
Github do not appear to use any client side library to render code. You can see, using something like Chrome's Net tab, that the HTML views of code arrive from the server prewrapped with vast numbers of span elements.

Combined JS File Using YUICompressor Causing Errors

I'm combining multiple js files using YUI Compressor. The command works successfully and outputs a combined file properly.
When I point my page to it, however, it doesn't seem to be read properly and I get this error in the Javascript error console.
YAHOO is not defined
I've tried using the --nomunge and --preserve-semi options but still get the same error.
Any ideas?
are you sure you're including the yahoo YUI js file before your script?
the variable YAHOO is defined within yui.js, so that script needs to exist and be loaded before you attempt to run any javascript that uses it.
Dave,
Hard to know what the problem is without a link to the compressed file.
You may also want to post those links to the dedicated YUI Compressor discussion forum on YUILibrary.com:
http://yuilibrary.com/forum/viewforum.php?f=94
Compressor's developers are there, as well as an interested community of fellow implementers.
-Eric
Did you try to jslint your code?
It may help you detect JS errors
It can usually be integrated in your IDE(I use Textmate), and warn you when you save your js file.
A poor man option is to use the online one at: http://www.jslint.com
Another option is to use a softer compression tool like jsmin to debug the problem. One is hosted here
You compress your files. Run your app, and usually your JS debugger will show you the problem.

Categories