Skip to content

Commit a11e237

Browse files
committed
Add docs to ListItem and its appendChild about tight lists
1 parent e60be15 commit a11e237

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

commonmark/src/main/java/org/commonmark/node/ListItem.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
/**
44
* A child of a {@link ListBlock}, containing other blocks (e.g. {@link Paragraph}, other lists, etc).
5+
* <p>
6+
* Note that a list item can't directly contain {@link Text}, it needs to be:
7+
* {@link ListItem} > {@link Paragraph} > {@link Text}.
8+
* If you want a list that is rendered tightly, create a list with {@link ListBlock#setTight(boolean)}.
59
*
610
* @see <a href="https://spec.commonmark.org/0.31.2/#list-items">CommonMark Spec: List items</a>
711
*/
@@ -57,4 +61,18 @@ public Integer getContentIndent() {
5761
public void setContentIndent(Integer contentIndent) {
5862
this.contentIndent = contentIndent;
5963
}
64+
65+
/**
66+
* @deprecated list items should only contain block nodes; if you're trying to create a list that is rendered
67+
* without paragraphs, use {@link ListBlock#setTight(boolean)} instead.
68+
*/
69+
@Override
70+
@Deprecated
71+
public void appendChild(Node child) {
72+
super.appendChild(child);
73+
}
74+
75+
public void appendChild(Block child) {
76+
super.appendChild(child);
77+
}
6078
}

0 commit comments

Comments
 (0)