Toddy.Iced.Widget.Markdown (Toddy v0.3.0)

Copy Markdown View Source

Markdown display -- renders parsed markdown content.

The renderer manages an internal markdown::Items cache keyed by node ID.

Props

  • content (string) -- raw markdown text (used to seed the parser cache).
  • width (length) -- container width. See Toddy.Iced.Length.
  • text_size (number) -- base text size in pixels.
  • h1_size (number) -- heading 1 size in pixels.
  • h2_size (number) -- heading 2 size in pixels.
  • h3_size (number) -- heading 3 size in pixels.
  • code_size (number) -- code block text size in pixels.
  • spacing (number) -- spacing between markdown elements in pixels.
  • link_color (hex color) -- color to override the default link color.
  • code_theme -- syntax highlighting theme for code blocks: "solarized_dark", "base16_mocha", "base16_ocean" (default), "base16_eighties", "inspired_github".
  • a11y (map) -- accessibility overrides. See Toddy.Iced.A11y.

Events

  • Link clicks are forwarded as MarkdownUrl messages by the renderer.

Summary

Functions

Sets accessibility annotations.

Converts this markdown struct to a ui_node() map via the Toddy.Iced.Widget protocol.

Sets the code block text size.

Sets the syntax highlighting theme for code blocks.

Sets the heading 1 size.

Sets the heading 2 size.

Sets the heading 3 size.

Sets the link text color.

Creates a new markdown struct with the given content and optional keyword opts.

Sets the spacing between markdown elements.

Sets the base text size.

Sets the container width.

Applies keyword options to an existing markdown struct.

Types

option()

@type option() ::
  {:width, Toddy.Iced.Length.t()}
  | {:text_size, number()}
  | {:h1_size, number()}
  | {:h2_size, number()}
  | {:h3_size, number()}
  | {:code_size, number()}
  | {:spacing, number()}
  | {:link_color, Toddy.Iced.Color.input()}
  | {:code_theme, String.t()}
  | {:a11y, Toddy.Iced.A11y.t()}

t()

@type t() :: %Toddy.Iced.Widget.Markdown{
  a11y: Toddy.Iced.A11y.t() | nil,
  code_size: number() | nil,
  code_theme: String.t() | nil,
  content: String.t(),
  h1_size: number() | nil,
  h2_size: number() | nil,
  h3_size: number() | nil,
  id: String.t(),
  link_color: Toddy.Iced.Color.t() | nil,
  spacing: number() | nil,
  text_size: number() | nil,
  width: Toddy.Iced.Length.t() | nil
}

Functions

a11y(md, a11y)

@spec a11y(markdown :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()

Sets accessibility annotations.

build(md)

@spec build(markdown :: t()) :: Toddy.Iced.ui_node()

Converts this markdown struct to a ui_node() map via the Toddy.Iced.Widget protocol.

code_size(md, code_size)

@spec code_size(markdown :: t(), code_size :: number()) :: t()

Sets the code block text size.

code_theme(md, code_theme)

@spec code_theme(markdown :: t(), code_theme :: String.t()) :: t()

Sets the syntax highlighting theme for code blocks.

h1_size(md, h1_size)

@spec h1_size(markdown :: t(), h1_size :: number()) :: t()

Sets the heading 1 size.

h2_size(md, h2_size)

@spec h2_size(markdown :: t(), h2_size :: number()) :: t()

Sets the heading 2 size.

h3_size(md, h3_size)

@spec h3_size(markdown :: t(), h3_size :: number()) :: t()

Sets the heading 3 size.

new(id, content, opts \\ [])

@spec new(id :: String.t(), content :: String.t(), opts :: [option()]) :: t()

Creates a new markdown struct with the given content and optional keyword opts.

spacing(md, spacing)

@spec spacing(markdown :: t(), spacing :: number()) :: t()

Sets the spacing between markdown elements.

text_size(md, text_size)

@spec text_size(markdown :: t(), text_size :: number()) :: t()

Sets the base text size.

width(md, width)

@spec width(markdown :: t(), width :: Toddy.Iced.Length.t()) :: t()

Sets the container width.

with_options(md, opts)

@spec with_options(markdown :: t(), opts :: [option()]) :: t()

Applies keyword options to an existing markdown struct.