Skip to main content

Constructor

Returns

BaseFormatConverter

Methods

cardChildToFallbackText()

Convert card child element to fallback text.

Parameters

required

Returns

string | null

cardToFallbackText()

Generate fallback text from a card element. Override in subclasses for platform-specific formatting.

Parameters

required

Returns

string

defaultNodeToText()

Default fallback for converting an unknown mdast node to text. Recursively converts children if present, otherwise extracts the node value. Adapters should call this in their nodeToX() default case.

Parameters

RootContent
required
(node: RootContent) => string
required

Returns

string

extractPlainText()

Extract plain text from platform format. Convenience method - default implementation uses toAst + toPlainText.

Parameters

string
required

Returns

string

fromAst()

Render an AST to the platform’s native format. This is the primary method used when sending messages.

Parameters

required

Returns

string

fromAstWithNodeConverter()

Template method for implementing fromAst with a node converter. Iterates through AST children and converts each using the provided function. Joins results with double newlines (standard paragraph separation).

Parameters

required
The AST to convert
(node: RootContent) => string
required
Function to convert each Content node to string

Returns

string Platform-formatted string

fromMarkdown()

Parameters

string
required

Returns

string

renderList()

Parameters

required
number
required
(node: RootContent) => string
required
string

Returns

string

renderPostable()

Convert a PostableMessage to platform format (text only).
  • string: passed through as raw text (no conversion)
  • { raw: string }: passed through as raw text (no conversion)
  • { markdown: string }: converted from markdown to platform format
  • { ast: Root }: converted from AST to platform format
  • { card: CardElement }: returns fallback text (cards should be handled by adapter)
  • CardElement: returns fallback text (cards should be handled by adapter)
Note: For cards, adapters should check for card content first and render them using platform-specific card APIs, using this method only for fallback.

Parameters

Returns

string

toAst()

Parse platform’s native format into an AST. This is the primary method used when receiving messages.

Parameters

string
required

Returns

Root

toMarkdown()

Parameters

string
required

Returns

string

toPlainText()

Parameters

string
required

Returns

string