[hmath-commits] org.hmath.server/WEB-INF/src/org/hartmath/server/filter CachedWikipediaParser.java,1
Status: Pre-Alpha
Brought to you by:
jsurfer
|
From: Klaus H. <js...@us...> - 2004-06-11 19:24:16
|
Update of /cvsroot/hmath/org.hmath.server/WEB-INF/src/org/hartmath/server/filter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4865/WEB-INF/src/org/hartmath/server/filter Modified Files: CachedWikipediaParser.java CachedWikipediaFilter.java Log Message: misc changes Index: CachedWikipediaFilter.java =================================================================== RCS file: /cvsroot/hmath/org.hmath.server/WEB-INF/src/org/hartmath/server/filter/CachedWikipediaFilter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CachedWikipediaFilter.java 12 May 2004 21:20:14 -0000 1.3 --- CachedWikipediaFilter.java 11 Jun 2004 19:24:05 -0000 1.4 *************** *** 23,27 **** import java.util.HashMap; import java.util.HashSet; - import java.util.Map; import javax.servlet.http.HttpServletRequest; --- 23,26 ---- *************** *** 45,49 **** import org.radeox.util.Encoder; import org.radeox.util.StringBufferWriter; ! import org.snipsnap.app.Application; /** --- 44,48 ---- import org.radeox.util.Encoder; import org.radeox.util.StringBufferWriter; ! //import org.snipsnap.app.Application; /** *************** *** 929,936 **** } ! public static void handleTeXMath(StringBuffer result, String[] mathStrings) { ! Map map = Application.get().getParameters(); ! HttpServletRequest request = (HttpServletRequest) map.get("request"); ! MathSniffer sniffy = MathSniffer.getBrowserDetection(request); switch (sniffy.getBrowserId()) { --- 928,935 ---- } ! public static void handleTeXMath(MathSniffer sniffy, StringBuffer result, String[] mathStrings) { ! // Map map = Application.get().getParameters(); ! // HttpServletRequest request = (HttpServletRequest) map.get("request"); ! // MathSniffer sniffy = MathSniffer.getBrowserDetection(request); switch (sniffy.getBrowserId()) { Index: CachedWikipediaParser.java =================================================================== RCS file: /cvsroot/hmath/org.hmath.server/WEB-INF/src/org/hartmath/server/filter/CachedWikipediaParser.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CachedWikipediaParser.java 12 May 2004 21:20:14 -0000 1.5 --- CachedWikipediaParser.java 11 Jun 2004 19:24:05 -0000 1.6 *************** *** 42,45 **** --- 42,46 ---- import org.hartmath.server.filter.CachedWikipediaFilter.SpecialTagToken; import org.hartmath.server.filter.CachedWikipediaFilter.Token; + //import org.hartmath.server.macro.table.Table; import org.hartmath.server.taglib.MathSniffer; import org.hartmath.tex2mml.TeXParser; *************** *** 623,627 **** break; case ':' : - if (fCurrentPosition >= 2) { char beforeChar = fSource[fCurrentPosition - 2]; --- 624,627 ---- *************** *** 685,703 **** } break; ! case '{' : // detect macros copyWhite(fWhiteStart, fWhiteStartPosition, 1); fWhiteStart = false; // boolean scanBody = true; int startMacroPosition = fCurrentPosition; ! if (readUntilChar('}')) { ! String macroStartTag; ! ! macroStartTag = new String(fSource, startMacroPosition, fCurrentPosition - startMacroPosition - 1); ! if (macroStartTag != null) { ! createMacro(startMacroPosition, macroStartTag); ! continue; } ! } break; case '[' : --- 685,707 ---- } break; ! case '{' : ! // detect macros copyWhite(fWhiteStart, fWhiteStartPosition, 1); fWhiteStart = false; // boolean scanBody = true; int startMacroPosition = fCurrentPosition; + // if (getNextChar('|') && handleWikipediaTable()) { // Wikipedia table syntax + // continue; + // } else { + if (readUntilChar('}')) { + String macroStartTag; ! macroStartTag = new String(fSource, startMacroPosition, fCurrentPosition - startMacroPosition - 1); ! if (macroStartTag != null) { ! createMacro(startMacroPosition, macroStartTag); ! continue; ! } } ! // } break; case '[' : *************** *** 715,722 **** while (true) { fCurrentCharacter = fSource[fCurrentPosition++]; ! if (! Character.isLetterOrDigit(fCurrentCharacter)) { fCurrentPosition--; break; ! } suffixBuffer.append(fCurrentCharacter); } --- 719,726 ---- while (true) { fCurrentCharacter = fSource[fCurrentPosition++]; ! if (!Character.isLetterOrDigit(fCurrentCharacter)) { fCurrentPosition--; break; ! } suffixBuffer.append(fCurrentCharacter); } *************** *** 1096,1100 **** // insert html comment for visual checks only: /* ! * fResultBuffer.append(" <!--"); copyWhite(htmlCommentContent); fResultBuffer.append("-->"); */ continue; --- 1100,1104 ---- // insert html comment for visual checks only: /* ! * fResultBuffer.append(" <!--"); copyWhite(htmlCommentContent); fResultBuffer.append("--> "); */ continue; *************** *** 1374,1378 **** new Attachment(longImageName, "image/gif", imageFile.length(), new Date(), snipname + "/" + longImageName, true); // fSnip.getAttachments().addAttachment(longImageName, "image/gif", imageFile.length(), snipname + "/" + longImageName, ! // true); fSnip.getAttachments().addAttachment(attachment); StringWriter writer = new StringWriter(); --- 1378,1382 ---- new Attachment(longImageName, "image/gif", imageFile.length(), new Date(), snipname + "/" + longImageName, true); // fSnip.getAttachments().addAttachment(longImageName, "image/gif", imageFile.length(), snipname + "/" + longImageName, ! // true); fSnip.getAttachments().addAttachment(attachment); StringWriter writer = new StringWriter(); *************** *** 1518,1521 **** --- 1522,1641 ---- } + // private boolean handleWikipediaTable() { + // // example + // // {| border=1 + // // |Zelle 1 + // // | + // // {| border=2 + // // |Zelle A + // // |- + // // |Zelle B + // // |} + // // |Zelle 3 + // // |} + // + // int temp = fCurrentPosition; + // // StringBuffer suffixBuffer = new StringBuffer(); + // Table table = new Table(fContext.getRenderContext()); + // // char currentChar = ' '; + // char lastChar = ' '; + // // int startPosition = 0; + // // int currentPosition = 0; + // StringBuffer buffer = new StringBuffer(); + // int thStartPosition = 0; + // + // try { // read first line + // fCurrentCharacter = fSource[fCurrentPosition++]; + // // TODO improve this for different table attributes + // while (fCurrentCharacter != '\n' ) { + // fCurrentCharacter = fSource[fCurrentPosition++]; + // // System.out.println(fCurrentCharacter); + // } + // table.newRow(); + // lastChar = fCurrentCharacter; + // fCurrentCharacter = fSource[fCurrentPosition++]; + // while (true) { + // + // switch (fCurrentCharacter) { + // // case '{' : // start of nested table ? + // // if (getNextChar('|') && handleWikipediaTable()) { // Wikipedia table end reached + // // return true; + // // } + // // break; + // case '!' : + // if (lastChar == '\n') { + // table.addCell(buffer.toString()); + // // System.out.println(buffer.toString()); + // buffer.setLength(0); + // thStartPosition = fCurrentPosition; + // while (true) { + // lastChar = fCurrentCharacter; + // fCurrentCharacter = fSource[fCurrentPosition++]; + // if (fCurrentCharacter == '|') { + // break; + // } + // if (fCurrentCharacter == '\n') { + // lastChar = '\n'; + // fCurrentPosition = thStartPosition; + // break; + // } + // } + // } else { + // buffer.append(fCurrentCharacter); + // } + // break; + // case '|' : + // if (lastChar == '\n') { + // if (getNextChar('}')) { // Wikipedia table end reached + // table.addCell(buffer.toString()); + // StringWriter writer = new StringWriter(); + // try { + // table.appendTo(writer); + // fResultBuffer.append(writer.getBuffer()); + // } catch (IOException e1) { + // // TODO Auto-generated catch block + // e1.printStackTrace(); + // return false; + // } + // return true; + // } else if (getNextChar('-')) { + // table.addCell(buffer.toString()); + // buffer.setLength(0); + // table.newRow(); + // while (true) { + // lastChar = fCurrentCharacter; + // fCurrentCharacter = fSource[fCurrentPosition++]; + // if (fCurrentCharacter == '|' || fCurrentCharacter == '!') { + // break; + // } + // } + // // continue; + // } else { + // if (buffer.length()>0) { + // table.addCell(buffer.toString()); + // buffer.setLength(0); + // } + // } + // } else if (getNextChar('|')) { + // table.addCell(buffer.toString()); + // // System.out.println(buffer.toString()); + // buffer.setLength(0); + // } else { + // buffer.append(fCurrentCharacter); + // } + // break; + // default : + // buffer.append(fCurrentCharacter); + // } + // lastChar = fCurrentCharacter; + // fCurrentCharacter = fSource[fCurrentPosition++]; + // } + // + // } catch (IndexOutOfBoundsException e) { + // + // } + // fCurrentPosition = temp - 1; + // return false; + // } private void handleWikipediaLink(String linkText, String suffix) { String name = linkText; *************** *** 1563,1567 **** Writer writer = new StringBufferWriter(fResultBuffer); try { ! if (-1 != hashIndex) { interWiki.expand(writer, extSpace, name, hash); } else { --- 1683,1687 ---- Writer writer = new StringBufferWriter(fResultBuffer); try { ! if (-1 != hashIndex) { interWiki.expand(writer, extSpace, name, hash); } else { |