package tex4ht; import org.w3c.dom.*; public class HtSpk { public static void fracLevel(Node dom) { setFracLevel(dom.getFirstChild(), 0); } private static int setFracLevel(Node node, int cont) { int level = 0; String clName = null; if (node.hasChildNodes()) { if (node.hasAttributes()) { Node cl = node.getAttributes().getNamedItem("class"); if (cl != null) { clName = cl.getNodeValue(); } } NodeList children = node.getChildNodes(); int max = 0; for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { int d = setFracLevel(child, (clName != null) && clName.equals("continuous-mfrac")? 2 : ((clName != null) && clName.equals("continuous-mfrac")? (cont-1) : cont) ); if (d > max) { max = d; } } } level += max; if( clName != null ){ if( clName.equals("msub") || clName.equals("msup") || clName.equals("msubsup") ) { return 0; } if( clName.equals("continuous-mfrac") ) { if( cont > 0 ){ Node child = node.getLastChild(); if (child.getNodeType() == Node.ELEMENT_NODE) { Node cls = child.getAttributes() .getNamedItem("class"); if (cls != null) { String clsName = cls.getNodeValue(); if ( clsName.equals("begin-end")) { node.removeChild( child ); } } } } else { for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { Node cls = child.getAttributes() .getNamedItem("class"); if (cls != null) { String clsName = cls.getNodeValue(); if ( clsName.equals("begin-end")) { child = child.getFirstChild(); String s = child.getNodeValue(); s = s.replaceFirst("begin", "begin continued"); s = s.replaceFirst("end", "end continued"); ((org.w3c.dom.Text) child).setData(s); } } } } } return 0; } if (clName.equals("mfrac")) { if( cont > 0 ){ Node child = node.getLastChild(); if (child.getNodeType() == Node.ELEMENT_NODE) { Node cls = child.getAttributes() .getNamedItem("class"); if (cls != null) { String clsName = cls.getNodeValue(); if ( clsName.equals("begin-end")) { node.removeChild( child ); } } } } else if( level > 0 ){ for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { Node cls = child.getAttributes() .getNamedItem("class"); if (cls != null) { String clsName = cls.getNodeValue(); if (clsName.equals("begin-end")) { child = child.getFirstChild(); String s = child.getNodeValue(); String bg = "", ov = "", en = ""; for(int j=0; j max ){ max = d; } } } level += max; if( clName != null ){ if( clName.equals("msub") || clName.equals("msup") || clName.equals("msubsup") ) { return 0; } if( clName.equals("msqrt") || clName.equals("root") ){ for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { Node cls = child.getAttributes() .getNamedItem("class"); if (cls != null) { String clsName = cls.getNodeValue(); if( clsName.equals("begin-root") || clsName.equals("mid-root") || clsName.equals("end-root") ){ child = child.getFirstChild(); String s = child.getNodeValue(); String nested = ""; for(int j=0; j