Markdown class
A component that renders markdown to ANSI-styled terminal output.
Automatically adapts syntax highlighting and styles based on terminal background (dark vs light) using RenderConfig.
// Basic usage
final md = Markdown('# Hello\n\nThis is **bold** text.');
print(md.render());
// With RenderConfig for theme adaptation
final config = RenderConfig(
terminalWidth: 100,
hasDarkBackground: false, // Light terminal
);
final md = Markdown(
'```dart\nvoid main() {}\n```',
renderConfig: config,
);
print(md.render());
// With custom options
final md = Markdown(
markdown,
options: MarkdownOptions(
syntaxTheme: AdaptiveChromaTheme.draculaGithub,
tableBorder: Border.rounded,
),
);
- Inheritance
- Available extensions
Constructors
- Markdown(String content, {RenderConfig renderConfig = const RenderConfig(), MarkdownOptions options = const MarkdownOptions()})
-
Creates a markdown component with the given content.
const
Properties
- content → String
-
The markdown content to render.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- lineCount → int
-
Number of lines in the rendered output.
no setterinherited
- options → MarkdownOptions
-
Additional markdown rendering options.
final
- renderConfig → RenderConfig
-
Render configuration (terminal width, color profile, background theme).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
init(
) → Cmd? -
Returns an optional command to execute on program startup.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
render(
) → String -
Renders the component as a styled string.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
Msg msg) → (ViewComponent, Cmd?) -
Updates the component state in response to a message.
inherited
-
view(
) → String -
Renders the current model state for display.
inherited
-
writelnTo(
Console io) → void -
Available on DisplayComponent, provided by the DisplayComponentExtension extension
Renders the component and writes it to the console.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited