Plushie.Widget.Markdown (Plushie v0.7.1)

Copy Markdown View Source

Markdown display, renders parsed markdown content.

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

Props

NameTypeDefaultDescription
contentString.t() | atom()requiredRaw markdown text (used to seed the parser cache).
width:fill | :shrink | {:fill_portion, pos_integer()} | number()nilContainer width.
text_sizenumber()nilBase text size in pixels.
h1_sizenumber()nilHeading 1 size in pixels.
h2_sizenumber()nilHeading 2 size in pixels.
h3_sizenumber()nilHeading 3 size in pixels.
code_sizenumber()nilCode block text size in pixels.
spacingnumber()nilSpacing between markdown elements in pixels.
link_colorString.t()nilColor to override the default link color.
code_themeString.t() | atom()nilSyntax highlighting theme for code blocks.
event_rateinteger()nilMax events per second for coalescable events.
a11y%Plushie.Type.A11y{} | map() | keyword()%{role: :document}Accessibility annotations.

Constructor

Markdown.new(id, content)
Markdown.new(id, content, opts)

Summary

Functions

Accessibility annotations.

Converts this widget struct to a ui_node() map.

Code block text size in pixels.

Syntax highlighting theme for code blocks.

Raw markdown text (used to seed the parser cache).

Max events per second for coalescable events.

Heading 1 size in pixels.

Heading 2 size in pixels.

Heading 3 size in pixels.

Color to override the default link color.

Creates a :markdown widget.

Creates a new widget struct with the given positional args and keyword options.

Spacing between markdown elements in pixels.

Base text size in pixels.

Container width.

Applies keyword options to an existing widget struct.

Types

option()

@type option() ::
  ((((((((({:width, :fill | :shrink | {:fill_portion, pos_integer()} | number()}
           | {:text_size, number()})
          | {:h1_size, number()})
         | {:h2_size, number()})
        | {:h3_size, number()})
       | {:code_size, number()})
      | {:spacing, number()})
     | {:link_color, atom() | String.t() | map()})
    | {:code_theme, String.t() | atom()})
   | {:event_rate, integer()})
  | {:a11y,
     %Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword()}

t()

@type t() :: %Plushie.Widget.Markdown{
  a11y:
    (%Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  code_size:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  code_theme:
    (String.t() | atom())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  content:
    (String.t() | atom())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  event_rate:
    integer()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  h1_size:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  h2_size:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  h3_size:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  id: String.t(),
  link_color:
    String.t()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  spacing:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  text_size:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  width:
    (:fill | :shrink | {:fill_portion, pos_integer()} | number())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil
}

Functions

a11y(widget, descriptor)

@spec a11y(
  widget :: t(),
  value ::
    (%Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword())
    | nil
) :: t()

Accessibility annotations.

Accepts %Plushie.Type.A11y{} | map() | keyword().

build(widget)

@spec build(widget :: t()) :: Plushie.Widget.ui_node()

Converts this widget struct to a ui_node() map.

code_size(widget, descriptor)

@spec code_size(widget :: t(), value :: number() | nil) :: t()

Code block text size in pixels.

Accepts number().

code_theme(widget, descriptor)

@spec code_theme(widget :: t(), value :: (String.t() | atom()) | nil) :: t()

Syntax highlighting theme for code blocks.

Accepts String.t() | atom().

content(widget, descriptor)

@spec content(widget :: t(), value :: (String.t() | atom()) | nil) :: t()

Raw markdown text (used to seed the parser cache).

Accepts String.t() | atom().

event_rate(widget, descriptor)

@spec event_rate(widget :: t(), value :: integer() | nil) :: t()

Max events per second for coalescable events.

Accepts integer().

h1_size(widget, descriptor)

@spec h1_size(widget :: t(), value :: number() | nil) :: t()

Heading 1 size in pixels.

Accepts number().

h2_size(widget, descriptor)

@spec h2_size(widget :: t(), value :: number() | nil) :: t()

Heading 2 size in pixels.

Accepts number().

h3_size(widget, descriptor)

@spec h3_size(widget :: t(), value :: number() | nil) :: t()

Heading 3 size in pixels.

Accepts number().

markdown(id, opts \\ [])

(macro)

Creates a :markdown widget.

Shorthand for new/2. Import this macro to use the widget name directly in view functions:

import Plushie.Widget.Markdown, only: [markdown: 2]

markdown("my-id", prop: value)

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

Creates a new widget struct with the given positional args and keyword options.

Arguments

  • id - unique widget identifier
  • content - Raw markdown text (used to seed the parser cache).
  • opts - keyword list of optional props

spacing(widget, descriptor)

@spec spacing(widget :: t(), value :: number() | nil) :: t()

Spacing between markdown elements in pixels.

Accepts number().

text_size(widget, descriptor)

@spec text_size(widget :: t(), value :: number() | nil) :: t()

Base text size in pixels.

Accepts number().

width(widget, descriptor)

@spec width(
  widget :: t(),
  value :: (:fill | :shrink | {:fill_portion, pos_integer()} | number()) | nil
) ::
  t()

Container width.

Accepts :fill | :shrink | {:fill_portion, pos_integer()} | number().

with_options(widget, opts)

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

Applies keyword options to an existing widget struct.