mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-07 12:18:39 +00:00
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
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
/**
|
|
* 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);
|
|
|
|
var tree = parseTree(toParse);
|
|
var node = buildTree(tree).toNode();
|
|
|
|
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();
|
|
};
|
|
|
|
module.exports = {
|
|
process: process,
|
|
renderToString: renderToString,
|
|
ParseError: ParseError
|
|
};
|