News from MathTran

Just another weblog

Archive for June 2008

JavaScript split problems

with 2 comments

During the development of some string manipulation methods we ran into some problems with the JavaScript implementation of the split method in different browsers when using regular expressions as delimiters. Other people have had this problem before and Steven Levithan has a nice article about the topic including a script which fixes the inconsistencies between the different browsers, and a test page.

We decided not to use his implementation of the split method, because we do not want to rely on third party code which we have to supply with our distribution and which might break with new browser versions coming out. Instead, we will use a work-around only containing JavaScript code which is consistent among different browsers.

Written by mystar22

June 19, 2008 at 6:31 pm

Posted in Uncategorized

Writing testable string manipulation code

leave a comment »

For our project we need a lot of string manipulation code. For example, given a textarea and a selection range, we want to extract the paragraph containing the selection and, later, extract the TeX code parts in that paragraph.

We decided to use test driven development for writing cross-browser code for these tasks. A set of tests is designed, which consist of input parameters and the expected output a function should return when called with the given input parameters. Whenever our function does not give the expected output an error message is printed and we know that the code is not correct.

The test framework then consists of the function X that we want to test, the tests, and a test runner function which runs the tests on X and compares the actual output with the expected output. To do this in an automated fashion, we call the js file with a JavaScript interpreter. For Windows we use SpiderMonkey (Mozilla’s implementation of JavaScript) and the build-in Windows Script Host.

After installing SpiderMonkey, we can call our script with “js X.js”, to use the Windows Script Host run “cscript X.js”

This setup allows us to test our code on Mozilla’s and Windows’ JavaScript implementation using the same test data on the command line.

Written by mystar22

June 19, 2008 at 2:07 pm

Posted in Uncategorized

Demonstration of autocomplete

leave a comment »

While I’ve been away on holiday Christoph has completed a demonstration version of TeX-command autocompletion.  You can play with it here.

I’m very please with what he’s done, and am interested in producing an online version of Scott Pakin’s Comprehensive LaTeX symbol list (view as PDF), which has several thousand symbols.

In most situations, there will be a subset of relevant symbols, which will depend on what is being authored.  Many symbols are required only in special areas.

Written by Jonathan Fine

June 15, 2008 at 1:36 pm

Posted in Uncategorized