Skip to content

Commit

Permalink
Add tightness property to List node (#215)
Browse files Browse the repository at this point in the history
* Add tightness property to List node

* Fix comment

* Update test

Co-authored-by: rob phillips <[email protected]>
  • Loading branch information
johnxnguyen and iwasrobbed authored Jun 12, 2020
1 parent c389ca6 commit 6638a36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion Source/AST/Nodes/List.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ public class List: BaseNode {

/// The number of items in the list.
public lazy var numberOfItems: Int = children.count

/// Whether the list is "tight".
///
/// If any of the list items are separated by a blank line, then this property is `false`. This value is
/// a hint to render the list with more (loose) or less (tight) spacing between items.

public lazy var isTight: Bool = cmark_node_get_list_tight(cmarkNode) == 1
}

// MARK: - List Type
Expand Down Expand Up @@ -54,6 +61,6 @@ public extension List {
extension List: CustomDebugStringConvertible {

public var debugDescription: String {
return "List - type: \(listType)"
return "List - type: \(listType), isTight: \(isTight)"
}
}
4 changes: 2 additions & 2 deletions Tests/AST/__Snapshots__/VisitorTests/testList.2.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Document
↳ Paragraph
↳ Text - Text text.
↳ List - type: Ordered (start: 3)
↳ List - type: Ordered (start: 3), isTight: true
↳ Item
↳ Paragraph
↳ Text - One
↳ Item
↳ Paragraph
↳ Text - Two
↳ List - type: Bullet
↳ List - type: Bullet, isTight: true
↳ Item
↳ Paragraph
↳ Text - Three
Expand Down

0 comments on commit 6638a36

Please sign in to comment.