Add looots of comments

Summary:
Add comments everywhere! Also fix some small bugs like using Style.id
instead of Style.size, and rename some variables to be more descriptive.

Fixes #22

Test Plan:
 - Make sure the huxley screenshots didn't change
 - Make sure the tests still pass

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D13158
This commit is contained in:
Emily Eisenberg
2014-09-14 19:23:39 -07:00
parent 79a5687057
commit f63af87f17
14 changed files with 955 additions and 297 deletions

View File

@@ -1,9 +1,21 @@
/**
* This is the main entry point for KaTeX. Here, we expose functions for
* rendering expressions either to DOM nodes or to markup strings.
*
* We also expose the ParseError class to check if errors thrown from KaTeX are
* errors in the expression, or errors in javascript handling.
*/
var ParseError = require("./ParseError");
var buildTree = require("./buildTree");
var parseTree = require("./parseTree");
var utils = require("./utils");
/**
* Parse and build an expression, and place that expression in the DOM node
* given.
*/
var process = function(toParse, baseNode) {
utils.clearNode(baseNode);
@@ -13,6 +25,9 @@ var process = function(toParse, baseNode) {
baseNode.appendChild(node);
};
/**
* Parse and build an expression, and return the markup for that.
*/
var renderToString = function(toParse) {
var tree = parseTree(toParse);
return buildTree(tree).toMarkup();