TermUI.Markdown (TermUI v1.0.0)
View SourceMarkdown processor for rendering styled text in TermUI.
Converts markdown content to styled segments that can be rendered by TermUI components. MDEx parses CommonMark input; this renderer handles headings, paragraphs, emphasis, code, lists, blockquotes, thematic breaks, links, and image alt text. Unsupported nodes degrade to their text/children where possible.
Usage
iex> lines = TermUI.Markdown.render("**bold** and *italic*", 80)
iex> result = TermUI.Markdown.render_with_elements("```elixir\ndef hello, do: :world\n```", 80)
Summary
Functions
Renders markdown content as a list of styled lines.
Converts a styled line to a TermUI render node.
Renders markdown content with interactive element tracking.
Types
@type interactive_element() :: %{ id: String.t(), type: :code_block, content: String.t(), language: String.t() | nil, start_line: non_neg_integer(), end_line: non_neg_integer() }
@type render_result() :: %{ lines: [styled_line()], elements: [interactive_element()], content_height: non_neg_integer() }
@type styled_line() :: [styled_segment()]
@type styled_segment() :: {String.t(), TermUI.Renderer.Style.t() | nil}
Functions
@spec render(String.t(), pos_integer()) :: [styled_line()]
Renders markdown content as a list of styled lines.
@spec render_line_to_node(styled_line()) :: TermUI.Component.RenderNode.t()
Converts a styled line to a TermUI render node.
@spec render_with_elements(String.t(), pos_integer(), keyword()) :: render_result()
Renders markdown content with interactive element tracking.
@spec wrap_styled_lines([styled_line()], pos_integer()) :: [styled_line()]