/** * This method checks if current parent is a strong parent based on param `chars`. If so, it checks if the * latest inline node to be added as child does not end with a closing character of the parent. When this * is true, a next test should check if the closing character(s) of the child should become (part of) the * closing character(s) of the parent. */ protected boolean isStrongCloseCharStolen( String chars ){ if(chars.length() < 2 ) return false; Object childClass = peek().getClass(); //checks if last `inline` to be added as child is not a StrongEmphSuperNode //that eats up a closing character for the parent StrongEmphSuperNode if( StrongEmphSuperNode.class.equals( childClass ) ){ StrongEmphSuperNode child = (StrongEmphSuperNode) peek(); if (!child.isClosed()) return false; if( child.getChars().endsWith( chars.substring(0, 1) ) ){ //The nested child ends with closing char for the parent, allow stealing it back return true; } } return false; }
public void visit(StrongEmphSuperNode node) { if (node.isClosed()) { if (node.isStrong()) printTag(node, "strong"); else printTag(node, "em"); } else { //sequence was not closed, treat open chars as ordinary chars printer.print(node.getChars()); visitChildren(node); } }
@Override public void visit(StrongEmphSuperNode sesn) { char sym = '*'; if( !sesn.isStrong() ) { final String chars = sesn.getChars(); if( chars.equals("_")) sym = '_'; } _buffer.append( sym); visitChildren(sesn); _buffer.append( sym ); }
@Override public void visit(StrongEmphSuperNode sesn) { char sym = '*'; if( !sesn.isStrong() ) { final String chars = sesn.getChars(); if( chars.equals("_")) sym = '_'; } _buffer.append( sym); visitChildren(sesn); _buffer.append( sym ); }
@Override public void visit(StrongEmphSuperNode sesn) { char sym = '*'; if( !sesn.isStrong() ) { final String chars = sesn.getChars(); if( chars.equals("_")) sym = '_'; } _buffer.append( sym); visitChildren(sesn); _buffer.append( sym ); }
public void visit(StrongEmphSuperNode node) { if (node.isClosed()) { if (node.isStrong()) { printNodeSurroundedBy(node, "*"); } else { printNodeSurroundedBy(node, "_"); } } else { //sequence was not closed, treat open chars as ordinary chars printer.print(node.getChars()); visitChildren(node); } }
public void visit(StrongEmphSuperNode node) { if (node.isClosed()) { if (node.isStrong()) { printNodeSurroundedBy(node, "*"); } else { printNodeSurroundedBy(node, "_"); } } else { //sequence was not closed, treat open chars as ordinary chars printer.print(node.getChars()); visitChildren(node); } }