ListItemParser(ListOptions options, Parsing parsing, ListBlockParser.ListData listData) { myOptions = options; myListData = listData; myParsing = parsing; myBlock = myListData.isNumberedList ? new OrderedListItem() : new BulletListItem(); myBlock.setOpeningMarker(myListData.listMarker); myBlock.setMarkerSuffix(myListData.markerSuffix); }
static Node C(int key, Node left, Node right) { return new Node(key, left, right); } static Node X(int key) { return C(key, null, null); } static Node L(int key, Node left) { return C(key, left, null); } static Node R(int key, Node right) { return C(key, null, right); } public static void main(String[] args) { Node n = C(8, C(3, X(1), C(6, X(4), X(7) ) ), R(10, L(14, X(13) ) ) ); Node current = n.getLeftMost(); while (current != null) { System.out.print(current.key + " "); current = current.getNext(); } }
@Override public void getAstExtra(StringBuilder out) { astExtraChars(out); if (getChars() instanceof PrefixedSubSequence) { astChars(out, getChars(), "text"); } }
@Override protected String toStringAttributes() { return "text=" + getChars(); } }
public boolean isInTightListItem(Paragraph node) { Block parent = node.getParent(); if (!(parent instanceof ListItem)) return false; ListItem listItem = (ListItem) parent; if (!listItem.isItemParagraph(node)) return false; boolean autoLoose = isAutoLoose(); if (autoLoose && isAutoLooseOneLevelLists()) { return isTightListItem(listItem); } return !autoLoose && listItem.isParagraphInTightListItem(node) || autoLoose && listItem.isInTightList(); }
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 closeBlock(ParserState state) { block.setContent(content); content = null; }
public boolean isParagraphInTightListItem(Paragraph node) { if (!isTight()) return false; // see if this is the first paragraph child item return isItemParagraph(node); }
public ListItem(ListItem other) { this.openingMarker = other.openingMarker; this.markerSuffix = other.markerSuffix; this.tight = other.tight; this.hadBlankAfterItemParagraph = other.hadBlankAfterItemParagraph; takeChildren(other); setCharsFromContent(); }
@Override public void getAstExtra(StringBuilder out) { if (isReferenceTextCombined()) { delimitedSegmentSpanChars(out, referenceOpeningMarker, reference, referenceClosingMarker, "reference"); delimitedSegmentSpanChars(out, textOpeningMarker, text, textClosingMarker, "text"); } else { delimitedSegmentSpanChars(out, textOpeningMarker, text, textClosingMarker, "text"); delimitedSegmentSpanChars(out, referenceOpeningMarker, reference, referenceClosingMarker, "reference"); } }
@Override protected String toStringAttributes() { return "text=" + getChars(); } }
public AutoLink(BasedSequence openingMarker, BasedSequence text, BasedSequence closingMarker) { super(openingMarker, text, closingMarker); setUrlChars(text); } }
public void setUrl(BasedSequence linkOpeningMarker, BasedSequence url, BasedSequence linkClosingMarker) { this.linkOpeningMarker = linkOpeningMarker; this.setUrlChars(url); this.linkClosingMarker = linkClosingMarker; }
@Override public void getAstExtra(StringBuilder out) { delimitedSegmentSpan(out, openingMarker, text, closingMarker, "text"); } }
@Override protected String toStringAttributes() { return "text=" + getChars(); } }
public ListBlockParser(ListOptions options, ListData listData, ListItemParser listItemParser) { myOptions = options; myListData = listData; myBlock = listData.listBlock; myBlock.setTight(true); myLastChild = listItemParser; myItemHandledNewListLine = false; myItemHandledNewItemLine = false; myItemHandledSkipActiveLine = false; }
@Override public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, reference, closingMarker, "ref"); delimitedSegmentSpanChars(out, urlOpeningMarker, url, urlClosingMarker, "url"); delimitedSegmentSpanChars(out, titleOpeningMarker, title, titleClosingMarker, "title"); }
public Text getPreviousNonDelimiterTextNode() { Node previousNode = node.getPrevious(); if (previousNode instanceof Text && (this.previous == null || this.previous.node != previousNode)) { return (Text) previousNode; } else { return null; } }
public Text getNextNonDelimiterTextNode() { Node nextNode = node.getNext(); if (nextNode instanceof Text && (this.next == null || this.next.node != nextNode)) { return (Text) nextNode; } else { return null; } }