Skip to content

Commit

Permalink
Changed mode to imath and fixed the back search to not require a header.
Browse files Browse the repository at this point in the history
  • Loading branch information
raguay committed Jul 17, 2014
1 parent eb56238 commit fe7cb42
Showing 1 changed file with 13 additions and 23 deletions.
36 changes: 13 additions & 23 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ define(function(require, exports, module) {
var math = require("./mathjs.js");

//
// Add the 'math' mode extension to the system.
// Add the 'imath' mode extension to the system.
//
Extensions.addMode({
name: 'math'
name: 'imath'
});

//
Expand All @@ -31,7 +31,7 @@ define(function(require, exports, module) {
// a math area and is not empty.
//
function inMathArea(node) {
if((node.modeContext() == "math")&&(node.text().trim()) != "") {
if((node.modeContext() === 'imath')&&(node.text().trim() != "")) {
return(true);
} else {
return(false);
Expand Down Expand Up @@ -80,31 +80,21 @@ define(function(require, exports, module) {
// See if some of the previous lines had
// variable declarations.
//
var loop = false;
var pnode = node;
do {
var pnode = node,
text = "";
while(pnode && (!pnode.mode()) && (pnode.modeContext() === 'imath')) {
//
// Look for variable lines until reach the heading.
// Not a heading, see if it has an evaluate command.
//
pnode = pnode.previousBranch();
if(pnode.type() != "heading") {
//
// Not a heading, see if it has an evaluate command.
//
if(pnode.text().search("=>") < 0) {
//
// No evaluation, add it to the rest.
//
result = pnode.text() + "\n" + result;
}
loop = true;
} else {
text = pnode.text();
if(text.search("=>") < 0) {
//
// Hit a header. Quit looping.
// No evaluation, add it to the rest.
//
loop = false;
result = text + "\n" + result;
}
} while(loop);
pnode = pnode.previousBranch();
}

//
// Calculate the result. If Calculate returns an array, there were
Expand Down

0 comments on commit fe7cb42

Please sign in to comment.