protected static <T extends Appendable & CharSequence> void ensureNewLine(@NonNull T output) { final int length = output.length(); if (length > 0 && '\n' != output.charAt(length - 1)) { appendQuietly(output, '\n'); } }
protected <T extends Appendable & CharSequence> void appendEmptyTagReplacement( @NonNull T output, @NonNull HtmlTagImpl tag) { final String replacement = emptyTagReplacement.replace(tag); if (replacement != null) { appendQuietly(output, replacement); } } }
if (outputLength > 0 && !Character.isWhitespace(output.charAt(outputLength - 1))) { appendQuietly(output, ' '); appendQuietly(output, c); appendQuietly(output, ' ');
protected <T extends Appendable & CharSequence> void processCharacter( @NonNull T output, @NonNull Token.Character character) { // there are tags: BUTTON, INPUT, SELECT, SCRIPT, TEXTAREA, STYLE // that might have character data that we do not want to display if (isInsidePreTag) { appendQuietly(output, character.getData()); } else { ensureNewLineIfPreviousWasBlock(output); trimmingAppender.append(output, character.getData()); } }
protected <T extends Appendable & CharSequence> void processInlineTagStart( @NonNull T output, @NonNull Token.StartTag startTag) { final String name = startTag.normalName; final HtmlTagImpl.InlineImpl inline = new HtmlTagImpl.InlineImpl(name, output.length(), extractAttributes(startTag)); ensureNewLineIfPreviousWasBlock(output); if (isVoidTag(name) || startTag.selfClosing) { final String replacement = emptyTagReplacement.replace(inline); if (replacement != null && replacement.length() > 0) { appendQuietly(output, replacement); } // the thing is: we will keep this inline tag in the list, // but in case of void-tag that has no replacement, there will be no // possibility to set a span (requires at least one char) inline.closeAt(output.length()); } inlineTags.add(inline); }
protected <T extends Appendable & CharSequence> void processBlockTagEnd( @NonNull T output, @NonNull Token.EndTag endTag) { final String name = endTag.normalName; final HtmlTagImpl.BlockImpl block = findOpenBlockTag(endTag.normalName); if (block != null) { if ("pre".equals(name)) { isInsidePreTag = false; } // okay, if this tag is empty -> call replacement if (isEmpty(output, block)) { appendEmptyTagReplacement(output, block); } block.closeAt(output.length()); // if it's empty -> we do no care about if it's block or not if (!block.isEmpty()) { previousIsBlock = isBlockTag(block.name); } if (TAG_PARAGRAPH.equals(name)) { appendQuietly(output, '\n'); } this.currentBlock = block.parent; } }
appendQuietly(output, '\n'); currentBlock = currentBlock.parent; } else if (TAG_LIST_ITEM.equals(name) if (replacement != null && replacement.length() > 0) { appendQuietly(output, replacement);