1 5 package org.exoplatform.services.grammar.wiki.impl; 6 7 12 public class StrikeTokenHandler extends TokenHandler { 13 14 private Token parent_ = new Token(0,0); 15 16 public Token handleToken(Token parent, Token token, ParsingContext context) { 17 StringBuffer b = context.getOutputBuffer() ; 18 parent_.clone(token) ; 19 parent_.parent = parent ; 20 token = context.nextToken(token) ; 21 if(token.type == Token.DEFAULT_TOKEN) { 22 b.append("<strike>") ; 23 while(token != null) { 24 if(token.type == Token.DEFAULT_TOKEN) { 25 token = context.getTokenHandlerManager().handleToken(parent_, token, context) ; 26 } else if(token.type == Token.STRIKE_TOKEN) { 27 token = context.nextToken(token) ; 28 break ; 29 } else if(token.group == Token.SINGLE_TOKEN_GROUP || token.group == Token.INLINE_TOKEN_GROUP) { 30 if(parent_.hasAncestor(token.type)) { 31 break ; 32 } 33 token = context.getTokenHandlerManager().handleToken(parent_, token, context) ; 34 } else { 35 break ; 36 } 37 } 38 b.append("</strike>") ; 39 return token ; 40 } 41 b.append(context.buf_, parent_.start, parent_.end - parent_.start + 1) ; 42 return token ; 43 } 44 45 public String [] getHandleableTokenType() { return new String []{Token.STRIKE_TOKEN} ;} 46 } | Popular Tags |