public TextRendererBak (HTMLNode root, List<HTMLNode> contents, int type, boolean constain) {
List<HTMLNode> tokens = new ArrayList<HTMLNode>();
// root.buildTokens(tokens);
for(int i = 0; i < tokens.size(); i++) {
NodeImpl node = (NodeImpl)tokens.get(i);
switch (node.getName()) {
case CONTENT:
char [] chars = node.getValue();
if(!isEmpty(chars)) {
if(isValid(contents, node, constain)) {
int start = builder.length();
for(int k = 0; k < chars.length; k++) {
builder.append(chars[k] == '\n' ? ' ' : chars[k]);
}
int end = builder.length();
positions.add(new NodePosition(node, start, end));
}
}
break;
case IMG:
positions.add(new NodePosition(node, -1, -1));
break;
case H1:
case H2:
case H3:
case H4:
case H5:
case H6:
case TR:
case TABLE:
case TD:
case P:
case DIV:
case BR:
if(!isEndWithNewLine(builder)) {
builder.append('\n');
if(type == RENDERER) builder.append('\n');
}
break;
case SCRIPT:
case STYLE:
if(node.getType() == TypeToken.TAG) i++;
break;
default:
if(builder.length() > 0) {
char c = builder.charAt(builder.length()-1);
if(!(Character.isWhitespace(c)