Refine search
public boolean isTightListItem(ListItem node) { if (node.isLoose()) { return false; } boolean autoLoose = isAutoLoose(); if (autoLoose && isAutoLooseOneLevelLists()) { boolean singleLevel = node.getAncestorOfType(ListItem.class) == null && node.getChildOfType(ListBlock.class) == null; return node.getFirstChild() == null || !singleLevel && node.isTight() || singleLevel && node.isInTightList(); } else { return node.getFirstChild() == null || !autoLoose && node.isTight() || autoLoose && node.isInTightList(); } }
@Override public void preProcess(ParserState state, Block block) { if (block instanceof BulletListItem || block instanceof OrderedListItem) { // we chop up the previous paragraph into definition terms and add the definition item to the last one // we add all these to the previous DefinitionList or add a new one if there isn't one final ListItem listItem = (ListItem) block; final BasedSequence markerSuffix = listItem.getMarkerSuffix(); if (markerSuffix.matches("[ ]") || markerSuffix.matches("[x]") || markerSuffix.matches("[X]")) { TaskListItem taskListItem = new TaskListItem(listItem); taskListItem.setTight(listItem.isOwnTight()); listItem.insertBefore(taskListItem); listItem.unlink(); state.blockAdded(taskListItem); state.blockRemoved(listItem); } } }
private static boolean hasNonItemChildren(ListItem item) { if (item.hasChildren()) { int count = 0; for (Node child : item.getChildren()) { if (child instanceof ListBlock) continue; count++; if (count >= 2) return true; } } return false; }
if (state.isBlank()) { Node firstChild = myBlock.getFirstChild(); myIsEmpty = firstChild == null; if (myIsEmpty || firstChild.getNext() == null) { myBlock.setHadBlankAfterItemParagraph(true); assert myBlock.getParent() instanceof ListBlock; ListBlockParser listBlockParser = (ListBlockParser) state.getActiveBlockParser(myBlock.getParent()); ParserEmulationProfile emulationProfile = myOptions.getParserEmulationProfile(); ParserEmulationProfile emulationFamily = emulationProfile.family; final int contentIndent = getContentIndent(); int newColumn = state.getColumn() + contentIndent; if (currentIndent >= contentIndent + myOptions.getCodeIndent()) { ListBlockParser.ListData listData = ListBlockParser.parseListMarker(myOptions, myOptions.getCodeIndent(), state); if (myHadBlankLine) { if (myBlock.isHadBlankAfterItemParagraph()) myBlock.setLoose(true); listBlockParser.setItemHandledLineSkipActive(state.getLine()); return BlockContinue.none();
final FormatterOptions options = context.getFormatterOptions(); if (options.listRemoveEmptyItems && !(node.hasChildren() && node.getFirstChildAnyNot(BlankLine.class) != null)) { return; CharSequence openingMarker = node.getOpeningMarker(); if (node instanceof OrderedListItem) { char delimiter = openingMarker.charAt(openingMarker.length() - 1); markdown.pushPrefix().addPrefix(options.itemContentIndent ? RepeatedCharSequence.of(' ', openingMarker.length() + (listOptions.isItemContentAfterSuffix() ? markerSuffix.length() : 0) + 1) : RepeatedCharSequence.of(" ", listOptions.getItemIndent()).toString()); if (node.hasChildren() && node.getFirstChildAnyNot(BlankLine.class) != null) { context.renderChildren(node); if (addBlankLineLooseItems && (node.isLoose() || node.getDocument().get(LIST_ITEM_SPACING) == ListSpacing.LOOSE)) { markdown.blankLine(); if (node.isLoose()) { markdown.blankLine(); } else {
private void renderListItem(ListItem node, NodeRendererContext context, HtmlWriter html) { renderListItemPrefix(node, context, html); if (listOptions.isTightListItem(node)) { context.renderChildren(node); } else { context.renderChildren(node); if (node.getFirstChild().getNext() != null) { html.blankLine(); } } }
private void renderListItem(final ListItem node, final DocxRendererContext docx) { final int nesting = node.countDirectAncestorsOfType(ListItem.class, BulletList.class, OrderedList.class); final DocxRendererOptions options = docx.getDocxRendererOptions(); final String listTextStyle = listOptions.isTightListItem(node) ? options.TIGHT_PARAGRAPH_STYLE : options.LOOSE_PARAGRAPH_STYLE; final NumberingDefinitionsPart ndp = docx.getDocxDocument().getNumberingDefinitionsPart(); if (node.getParent() instanceof OrderedList) { if (node == node.getParent().getFirstChild()) { newNum = listOptions.isOrderedListManualStart() ? ((OrderedList) node.getParent()).getStartNumber() : 1; numId = ndp.restart(numId, listLevel, newNum); ensureNumberedListLength(listLevel); numId = numberedLists[listLevel]; } else if (node.getParent() instanceof BulletList) { if (node == node.getParent().getFirstChild()) { newNum = 1; numId = ndp.restart(numId, listLevel, newNum);
@Override public boolean isPropagatingLastBlankLine(BlockParser lastMatchedBlockParser) { return !(myBlock.getFirstChild() == null && this != lastMatchedBlockParser); }
@Override public void run() { html.text(node.getMarkerSuffix().unescape()); context.renderChildren(node); } });
for (Node item : itemList) { if (item instanceof ListItem) { if (((ListItem) item).isOwnTight() && item.getNext() != null) { itemSpacing = ListSpacing.TIGHT; break;
@Override public void getAstExtra(StringBuilder out) { super.getAstExtra(out); if (isOrderedItem) out.append(" isOrderedItem"); out.append(isItemDoneMarker() ? " isDone" : " isNotDone"); }
if (state.isBlank()) { Node firstChild = myBlock.getFirstChild(); myIsEmpty = firstChild == null; if (myIsEmpty || firstChild.getNext() == null) { myBlock.setHadBlankAfterItemParagraph(true); assert myBlock.getParent() instanceof ListBlock; ListBlockParser listBlockParser = (ListBlockParser) state.getActiveBlockParser(myBlock.getParent()); ParserEmulationProfile emulationProfile = myOptions.getParserEmulationProfile(); ParserEmulationProfile emulationFamily = emulationProfile.family; final int contentIndent = getContentIndent(); int newColumn = state.getColumn() + contentIndent; if (currentIndent >= contentIndent + myOptions.getCodeIndent()) { ListBlockParser.ListData listData = ListBlockParser.parseListMarker(myOptions, myOptions.getCodeIndent(), state); if (myHadBlankLine) { if (myBlock.isHadBlankAfterItemParagraph()) myBlock.setLoose(true); listBlockParser.setItemHandledLineSkipActive(state.getLine()); return BlockContinue.none();
final FormatterOptions options = context.getFormatterOptions(); if (options.listRemoveEmptyItems && !(node.hasChildren() && node.getFirstChildAnyNot(BlankLine.class) != null)) { return; CharSequence openingMarker = node.getOpeningMarker(); if (node instanceof OrderedListItem) { char delimiter = openingMarker.charAt(openingMarker.length() - 1); markdown.pushPrefix().addPrefix(options.itemContentIndent ? RepeatedCharSequence.of(' ', openingMarker.length() + (listOptions.isItemContentAfterSuffix() ? markerSuffix.length() : 0) + 1) : RepeatedCharSequence.of(" ", listOptions.getItemIndent()).toString()); if (node.hasChildren() && node.getFirstChildAnyNot(BlankLine.class) != null) { context.renderChildren(node); if (addBlankLineLooseItems && (node.isLoose() || node.getDocument().get(LIST_ITEM_SPACING) == ListSpacing.LOOSE)) { markdown.blankLine(); if (node.isLoose()) { markdown.blankLine(); } else {
private void renderListItem(ListItem node, NodeRendererContext context, HtmlWriter html) { renderListItemPrefix(node, context, html); if (listOptions.isTightListItem(node)) { context.renderChildren(node); } else { context.renderChildren(node); if (node.getFirstChild().getNext() != null) { html.blankLine(); } } }
public boolean isItemParagraph(Paragraph node) { // see if this is the first paragraph child item Node child = getFirstChild(); while (child != null && !(child instanceof Paragraph)) child = child.getNext(); return child == node; }
private static boolean hasNonItemChildren(ListItem item) { if (item.hasChildren()) { int count = 0; for (Node child : item.getChildren()) { if (child instanceof ListBlock) continue; count++; if (count >= 2) return true; } } return false; }
@Override public void run() { html.text(node.getMarkerSuffix().unescape()); context.renderChildren(node); } });
for (Node item : itemList) { if (item instanceof ListItem) { if (((ListItem) item).isOwnTight() && item.getNext() != null) { itemSpacing = ListSpacing.TIGHT; break;
@Override public void getAstExtra(StringBuilder out) { super.getAstExtra(out); if (isOrderedItem) out.append(" isOrderedItem"); out.append(isItemDoneMarker() ? " isDone" : " isNotDone"); }