// Path: src/uk/ac/open/lts/webmaths/MapUtil.java
// public abstract class MapUtil
// {
// 
// 	public static Map<String, String> makeMap(String[] data)
// 	{
// 		Map<String, String> result = new HashMap<String, String>();
// 		for(int i=0; i<data.length; i+=2)
// 		{
// 			String previous = result.put(data[i], data[i+1]);
// 			if(previous != null)
// 			{
// 				Error e = new Error("Duplicate map entry: " + data[i] + "=" + data[i+1]
// 					+ " (previously " + previous + ")");
// 				System.err.println(e.getMessage());
// 				throw e;
// 			}
// 		}
// 		return result;
// 	}
// 
// }
// 
// Path: src/uk/ac/open/lts/webmaths/WebMathsService.java
// public final static String NS = "http://www.w3.org/1998/Math/MathML";


import java.util.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import static uk.ac.open.lts.webmaths.MapUtil.*;
import static uk.ac.open.lts.webmaths.WebMathsService.NS;
		"mstyle",
		"merror",
		"mpadded",
		"mphantom",
		"menclose",
		"mtd",
		"math"
	}));

	private static void addRequiredWhitespace(Element parent)
	{
		Document doc = parent.getOwnerDocument();
		for(Node n = parent.getFirstChild(); n != null; n = n.getNextSibling())
		{
			if(n.getNodeType() != Node.ELEMENT_NODE)
			{
				continue;
			}
			Element e = (Element)n;
			// Is this an mtext?
			if(e.getLocalName().equals("mtext"))
			{
				String thisText = ((Text)e.getFirstChild()).getNodeValue();
				// Only deal with mtext that has space at start/end
				if(thisText.startsWith(" ") || thisText.endsWith(" "))
				{
					// See if parent is an mrow, if not then we are going to need one
					if(!MROW_EQUIVALENTS.contains(parent.getLocalName()))
					{
						// Create row and stick this text in it
// Path: src/uk/ac/open/lts/webmaths/MapUtil.java
// public abstract class MapUtil
// {
// 
// 	public static Map<String, String> makeMap(String[] data)
// 	{
// 		Map<String, String> result = new HashMap<String, String>();
// 		for(int i=0; i<data.length; i+=2)
// 		{
// 			String previous = result.put(data[i], data[i+1]);
// 			if(previous != null)
// 			{
// 				Error e = new Error("Duplicate map entry: " + data[i] + "=" + data[i+1]
// 					+ " (previously " + previous + ")");
// 				System.err.println(e.getMessage());
// 				throw e;
// 			}
// 		}
// 		return result;
// 	}
// 
// }
// 
// Path: src/uk/ac/open/lts/webmaths/WebMathsService.java
// public final static String NS = "http://www.w3.org/1998/Math/MathML";


// Path: src/uk/ac/open/lts/webmaths/tex/LatexToMathml.java
import java.util.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import static uk.ac.open.lts.webmaths.MapUtil.*;
import static uk.ac.open.lts.webmaths.WebMathsService.NS;

		"mstyle",
		"merror",
		"mpadded",
		"mphantom",
		"menclose",
		"mtd",
		"math"
	}));

	private static void addRequiredWhitespace(Element parent)
	{
		Document doc = parent.getOwnerDocument();
		for(Node n = parent.getFirstChild(); n != null; n = n.getNextSibling())
		{
			if(n.getNodeType() != Node.ELEMENT_NODE)
			{
				continue;
			}
			Element e = (Element)n;
			// Is this an mtext?
			if(e.getLocalName().equals("mtext"))
			{
				String thisText = ((Text)e.getFirstChild()).getNodeValue();
				// Only deal with mtext that has space at start/end
				if(thisText.startsWith(" ") || thisText.endsWith(" "))
				{
					// See if parent is an mrow, if not then we are going to need one
					if(!MROW_EQUIVALENTS.contains(parent.getLocalName()))
					{
						// Create row and stick this text in it
						Element newRow = doc.createElementNS(NS, "mrow");