@Override public void visit(StrongEmphasis strongEmphasis) { final int length = builder.length(); visitChildren(strongEmphasis); setSpan(length, factory.strongEmphasis()); }
@Override public void visit(Emphasis emphasis) { final int length = builder.length(); visitChildren(emphasis); setSpan(length, factory.emphasis()); }
private void visitList(Node node) { newLine(); visitChildren(node); if (hasNext(node)) { newLine(); forceNewLine(); } }
/** * @since 1.0.1 */ @Override public void visit(CustomBlock customBlock) { if (customBlock instanceof TaskListBlock) { blockIndent += 1; visitChildren(customBlock); blockIndent -= 1; if (hasNext(customBlock)) { newLine(); forceNewLine(); } } else { super.visit(customBlock); } }
@Override public void visit(Link link) { final int length = builder.length(); visitChildren(link); final String destination = configuration.urlProcessor().process(link.getDestination()); setSpan(length, factory.link(theme, destination, configuration.linkResolver())); }
@Override public void visit(BlockQuote blockQuote) { newLine(); final int length = builder.length(); blockIndent += 1; visitChildren(blockQuote); setSpan(length, factory.blockQuote(theme)); blockIndent -= 1; if (hasNext(blockQuote)) { newLine(); forceNewLine(); } }
@Override public void visit(ListItem listItem) { final int length = builder.length(); blockIndent += 1; listLevel += 1; final Node parent = listItem.getParent(); if (parent instanceof OrderedList) { final int start = ((OrderedList) parent).getStartNumber(); visitChildren(listItem); setSpan(length, factory.orderedListItem(theme, start)); // after we have visited the children increment start number final OrderedList orderedList = (OrderedList) parent; orderedList.setStartNumber(orderedList.getStartNumber() + 1); } else { visitChildren(listItem); setSpan(length, factory.bulletListItem(theme, listLevel - 1)); } blockIndent -= 1; listLevel -= 1; if (hasNext(listItem)) { newLine(); } }
@Override public void visit(Heading heading) { newLine(); final int length = builder.length(); visitChildren(heading); setSpan(length, factory.heading(theme, heading.getLevel())); if (hasNext(heading)) { newLine(); // after heading we add another line anyway (no additional checks) forceNewLine(); } }
@Override public void visit(CustomNode customNode) { if (customNode instanceof Strikethrough) { final int length = builder.length(); visitChildren(customNode); setSpan(length, factory.strikethrough()); } else if (customNode instanceof TaskListItem) { // new in 1.0.1 final TaskListItem listItem = (TaskListItem) customNode; final int length = builder.length(); blockIndent += listItem.indent(); visitChildren(customNode); setSpan(length, factory.taskListItem(theme, blockIndent, listItem.done())); if (hasNext(customNode)) { newLine(); } blockIndent -= listItem.indent(); } else if (!handleTableNodes(customNode)) { super.visit(customNode); } }
visitChildren(node); tableRows = 0; handled = true; visitChildren(node); visitChildren(cell); if (pendingTableRow == null) { pendingTableRow = new ArrayList<>(2);
@Override public void visit(Paragraph paragraph) { final boolean inTightList = isInTightList(paragraph); if (!inTightList) { newLine(); } final int length = builder.length(); visitChildren(paragraph); // @since 1.1.1 apply paragraph span setSpan(length, factory.paragraph(inTightList)); if (hasNext(paragraph) && !inTightList) { newLine(); forceNewLine(); } }
@Override public void visit(Image image) { final int length = builder.length(); visitChildren(image); // we must check if anything _was_ added, as we need at least one char to render if (length == builder.length()) { builder.append('\uFFFC'); } final Node parent = image.getParent(); final boolean link = parent != null && parent instanceof Link; final String destination = configuration.urlProcessor().process(image.getDestination()); setSpan( length, factory.image( theme, destination, configuration.asyncDrawableLoader(), configuration.imageSizeResolver(), null, link ) ); // todo, maybe, if image is not inside a link, we should make it clickable, so // user can open it in external viewer? }