Skip to content
This repository was archived by the owner on Oct 17, 2021. It is now read-only.
mattt edited this page Apr 10, 2020 · 14 revisions

List

An ordered list.

public final class List: Node

From the CommonMark Spec:

A list is a sequence of one or more list items of the same type. The list items may be separated by any number of blank lines.

A list marker is a bullet list marker or an ordered list marker.

An ordered list marker is a sequence of 1–9 arabic digits (0-9), followed by either a . character or a ) character. (The reason for the length limit is that with 10 digits we start seeing integer overflows in some browsers.)

Inheritance

Node

Initializers

init(delimiter:children:)

public convenience init(delimiter: Delimiter = .none, children: [List.Item] = [])

init(delimiter:tight:_:)

public convenience init(delimiter: Delimiter = .none, tight: Bool = true, _ builder: () -> ListItemConvertible)

init(of:delimiter:tight:_:)

public convenience init<Values>(of values: Values, delimiter: Delimiter = .none, tight: Bool = true, _ builder: (Values.Element) -> ListItemConvertible) where Values: Sequence

init(of:delimiter:tight:_:)

public convenience init<Values>(of values: Values, delimiter: Delimiter = .none, tight: Bool = true, _ closure: (Values.Element) -> String) where Values: Sequence

Properties

kind

var kind: Kind

delimiter

var delimiter: Delimiter

loose

Whether the list is loose.

var loose: Bool

From the CommonMark Spec:

A list is loose if any of its constituent list items are separated by blank lines, or if any of its constituent list items directly contain two block-level elements with a blank line between them. Otherwise a list is tight.

tight

Whether the list is tight.

var tight: Bool

Seealso: loose

children

The block's children.

var children: [Item]

Methods

prepend(child:)

Adds a block to the beginning of the block's children.

@discardableResult public func prepend(child: Item) -> Bool

Parameters

  • child: The block to add.

Returns

true if successful, otherwise false.

append(child:)

Adds a block to the end of the block's children.

@discardableResult public func append(child: Item) -> Bool

Parameters

  • child: The block to add.

Returns

true if successful, otherwise false.

insert(child:before:)

Inserts a block to the block's children before a specified sibling.

@discardableResult public func insert(child: Item, before sibling: Item) -> Bool

Parameters

  • child: The block to add.
  • sibling: The child before which the block is added

Returns

true if successful, otherwise false.

insert(child:after:)

Inserts a block to the block's children after a specified sibling.

@discardableResult public func insert(child: Item, after sibling: Item) -> Bool

Parameters

  • child: The block to add.
  • sibling: The child after which the block is added

Returns

true if successful, otherwise false.

remove(child:)

Removes a block from the block's children.

@discardableResult public func remove(child: Item) -> Bool

Parameters

  • child: The block to remove.

Returns

true if successful, otherwise false.

Clone this wiki locally