[hmath-commits] org.hmath.server/WEB-INF/src/org/hartmath/server/filter WikipediaFilter.java,1.3,1.4
Status: Pre-Alpha
Brought to you by:
jsurfer
|
From: Klaus H. <js...@us...> - 2004-03-21 17:28:22
|
Update of /cvsroot/hmath/org.hmath.server/WEB-INF/src/org/hartmath/server/filter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9101/WEB-INF/src/org/hartmath/server/filter Modified Files: WikipediaFilter.java Log Message: misc changes Index: WikipediaFilter.java =================================================================== RCS file: /cvsroot/hmath/org.hmath.server/WEB-INF/src/org/hartmath/server/filter/WikipediaFilter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WikipediaFilter.java 20 Mar 2004 14:32:20 -0000 1.3 --- WikipediaFilter.java 21 Mar 2004 17:18:08 -0000 1.4 *************** *** 33,37 **** import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; ! import org.hartmath.server.taglib.BrowserSniffer; import org.hartmath.tex2mml.TeXParser; import org.radeox.api.engine.ImageRenderEngine; --- 33,37 ---- import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; ! import org.hartmath.server.taglib.MathSniffer; import org.hartmath.tex2mml.TeXParser; import org.radeox.api.engine.ImageRenderEngine; *************** *** 418,421 **** --- 418,422 ---- protected int getNextToken() throws InvalidInputException { + boolean startOfIndent = false; fWhiteStartPosition = 0; fWhiteStart = false; *************** *** 439,442 **** --- 440,459 ---- } break; + case ':' : + + if (fCurrentPosition >= 2) { + char beforeChar = fSource[fCurrentPosition - 2]; + if (beforeChar == '\n' || beforeChar == '\r') { + startOfIndent = true; + } + } else { + startOfIndent = true; + } + if (startOfIndent) { + copyWhite(fWhiteStart, fWhiteStartPosition, 1); + fWhiteStart = false; + continue; + } + break; case '\\' : // special characters follow copyWhite(fWhiteStart, fWhiteStartPosition, 1); *************** *** 462,472 **** copyWhite(fWhiteStart, fWhiteStartPosition, 1); fWhiteStart = false; int startMathPosition = fCurrentPosition; ! ! if (readUntilChar('$')) { ! String mathContent = new String(fSource, startMathPosition, fCurrentPosition - startMathPosition - 1); ! if (mathContent != null) { ! handleTeXMath(mathContent); ! continue; } } --- 479,502 ---- copyWhite(fWhiteStart, fWhiteStartPosition, 1); fWhiteStart = false; + startOfIndent = false; int startMathPosition = fCurrentPosition; ! if (getNextChar('$')) { ! startMathPosition = fCurrentPosition; ! copyWhite(fWhiteStart, fWhiteStartPosition, 2); ! fWhiteStart = false; ! if (readUntilString("$$")) { ! String mathContent = new String(fSource, startMathPosition, fCurrentPosition - startMathPosition - 2); ! if (mathContent != null) { ! handleTeXMath(mathContent, false); ! continue; ! } ! } ! } else { ! if (readUntilChar('$')) { ! String mathContent = new String(fSource, startMathPosition, fCurrentPosition - startMathPosition - 1); ! if (mathContent != null) { ! handleTeXMath(mathContent, true); ! continue; ! } } } *************** *** 878,882 **** copyWhite(fWhiteStart, fWhiteStartPosition, fCurrentPosition - htmlStartPosition + 1); fWhiteStart = false; ! handleTeXMath(mathContent); continue; } --- 908,917 ---- copyWhite(fWhiteStart, fWhiteStartPosition, fCurrentPosition - htmlStartPosition + 1); fWhiteStart = false; ! if (startOfIndent) { ! startOfIndent = false; ! handleTeXMath(mathContent, false); ! } else { ! handleTeXMath(mathContent, true); ! } continue; } *************** *** 886,889 **** --- 921,925 ---- } + startOfIndent = false; fCurrentPosition = htmlStartPosition; // detect special html tags *************** *** 924,927 **** --- 960,964 ---- fWhiteStartPosition = fCurrentPosition - 1; } + startOfIndent = false; } // -----------------end switch while try-------------------- *************** *** 933,959 **** } ! private void handleTeXMath(String mathContent) { // TODO clean this up Map map = Application.get().getParameters(); HttpServletRequest request = (HttpServletRequest) map.get("request"); ! BrowserSniffer sniffy = BrowserSniffer.getBrowserDetection(request); switch (sniffy.getBrowserId()) { ! case BrowserSniffer.GECKOID : ! case BrowserSniffer.MSIEID : ! case BrowserSniffer.MATHPLAYERID : ! fResult.append("<m:math><m:mstyle mathcolor=\"Black\" displaystyle=\"true\">"); ! fTeXParser.initialize(mathContent); ! fTeXParser.parse2MML(fResult); ! fResult.append("</m:mstyle></m:math>"); break; ! case BrowserSniffer.NETSCAPEID ://older netscape newer are detected as Gecko ! fResult.append(fResult); break; default : ! fResult.append("<m>"); ! fTeXParser.initialize(mathContent); ! fTeXParser.parse2CSS(fResult); ! fResult.append("</m>"); } } --- 970,1009 ---- } ! private void handleTeXMath(String mathContent, boolean inlineExpression) { // TODO clean this up Map map = Application.get().getParameters(); HttpServletRequest request = (HttpServletRequest) map.get("request"); ! MathSniffer sniffy = MathSniffer.getBrowserDetection(request); switch (sniffy.getBrowserId()) { ! case MathSniffer.XMLID : ! case MathSniffer.MATHPLAYERID : ! if (inlineExpression) { ! fResult.append("<m:math><m:mstyle mathcolor=\"Black\" displaystyle=\"true\">"); ! fTeXParser.initialize(mathContent); ! fTeXParser.parse2MML(fResult); ! fResult.append("</m:mstyle></m:math>"); ! } else { ! fResult.append("<dl><dd><m:math><m:mstyle mathcolor=\"Black\" displaystyle=\"true\">"); ! fTeXParser.initialize(mathContent); ! fTeXParser.parse2MML(fResult); ! fResult.append("</m:mstyle></m:math></dd></dl>"); ! } break; ! case MathSniffer.CSSID : ! if (inlineExpression) { ! fResult.append("<m>"); ! fTeXParser.initialize(mathContent); ! fTeXParser.parse2CSS(fResult, true); ! fResult.append("</m>"); ! } else { ! fResult.append("<e>"); ! fTeXParser.initialize(mathContent); ! fTeXParser.parse2CSS(fResult, true); ! fResult.append("</e>"); ! } break; default : ! fResult.append(fResult); } } |