Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

Visitor

mattt edited this page Jan 14, 2021 · 1 revision

Visitor

Visitor for walking a visitable structure.

public protocol Visitor

Override the appropriate func visit(…:)'s return value to customize the behavior (e.g. skip a given element's children), with sub-types overriding their super-type's behavior.

The default implementation of func visit(…:)returns .inherit, resulting in a deep walk over the entire document.

Sub-type inheritance

Node
├── Block
│   ├── ContainerBlock
│   │   ├── BlockQuote
│   │   ├── List
│   │   └── List.Item
│   │
│   └── LeafBlock
│       ├── CodeBlock
│       ├── HTMLBlock
│       ├── Heading
│       ├── Paragraph
│       └── ThematicBreak
│
└── Inline
    ├── Code
    ├── Emphasis
    ├── HardLineBreak
    ├── Image
    ├── Link
    ├── RawHTML
    ├── SoftLineBreak
    ├── Strong
    └── Text

Order of Visitation

The order of object-wise visitations is: super-type before sub-type.

Order of Post-Visitation

The order of object-wise visitations is: sub-type before super-type.

Requirements

walk(_:​)

Walks a visitable structure.

func walk<T: Visitable>(_ visitable: T)

Parameters

  • visitable: The structure to walk.

visit(document:​)

func visit(document: Document) -> VisitorContinueKind

visitPost(document:​)

func visitPost(document: Document)

visit(node:​)

func visit(node: Node) -> VisitorContinueKind

visitPost(node:​)

func visitPost(node: Node)

visit(block:​)

func visit(block: Block) -> VisitorContinueKind

visitPost(block:​)

func visitPost(block: Block)

visit(containerBlock:​)

func visit(containerBlock: ContainerBlock) -> VisitorContinueKind

visitPost(containerBlock:​)

func visitPost(containerBlock: ContainerBlock)

visit(blockQuote:​)

func visit(blockQuote: BlockQuote) -> VisitorContinueKind

visitPost(blockQuote:​)

func visitPost(blockQuote: BlockQuote)

visit(list:​)

func visit(list: List) -> VisitorContinueKind

visitPost(list:​)

func visitPost(list: List)

visit(listItem:​)

func visit(listItem: List.Item) -> VisitorContinueKind

visitPost(listItem:​)

func visitPost(listItem: List.Item)

visit(leafBlock:​)

A block that can only contain inline elements.

func visit(leafBlock: LeafBlock) -> VisitorContinueKind

visitPost(leafBlock:​)

func visitPost(leafBlock: LeafBlock)

visit(heading:​)

func visit(heading: Heading) -> VisitorContinueKind

visitPost(heading:​)

func visitPost(heading: Heading)

visit(paragraph:​)

func visit(paragraph: Paragraph) -> VisitorContinueKind

visitPost(paragraph:​)

func visitPost(paragraph: Paragraph)

visit(htmlBlock:​)

func visit(htmlBlock: HTMLBlock) -> VisitorContinueKind

visitPost(htmlBlock:​)

func visitPost(htmlBlock: HTMLBlock)

visit(codeBlock:​)

func visit(codeBlock: CodeBlock) -> VisitorContinueKind

visitPost(codeBlock:​)

func visitPost(codeBlock: CodeBlock)

visit(thematicBreak:​)

func visit(thematicBreak: ThematicBreak) -> VisitorContinueKind

visitPost(thematicBreak:​)

func visitPost(thematicBreak: ThematicBreak)

visit(inline:​)

func visit(inline: Inline) -> VisitorContinueKind

visitPost(inline:​)

func visitPost(inline: Inline)

visit(text:​)

func visit(text: Text) -> VisitorContinueKind

visitPost(text:​)

func visitPost(text: Text)

visit(strong:​)

func visit(strong: Strong) -> VisitorContinueKind

visitPost(strong:​)

func visitPost(strong: Strong)

visit(emphasis:​)

func visit(emphasis: Emphasis) -> VisitorContinueKind

visitPost(emphasis:​)

func visitPost(emphasis: Emphasis)

visit(link:​)

func visit(link: Link) -> VisitorContinueKind

visitPost(link:​)

func visitPost(link: Link)

visit(image:​)

func visit(image: Image) -> VisitorContinueKind

visitPost(image:​)

func visitPost(image: Image)

visit(code:​)

func visit(code: Code) -> VisitorContinueKind

visitPost(code:​)

func visitPost(code: Code)

visit(rawHTML:​)

func visit(rawHTML: RawHTML) -> VisitorContinueKind

visitPost(rawHTML:​)

func visitPost(rawHTML: RawHTML)

visit(softLineBreak:​)

func visit(softLineBreak: SoftLineBreak) -> VisitorContinueKind

visitPost(softLineBreak:​)

func visitPost(softLineBreak: SoftLineBreak)

visit(hardLineBreak:​)

func visit(hardLineBreak: HardLineBreak) -> VisitorContinueKind

visitPost(hardLineBreak:​)

func visitPost(hardLineBreak: HardLineBreak)
Clone this wiki locally