class

Glimmer::Renderer::TermRenderer

Inherits Markd::Renderer < Reference < Object

TermRenderer transforms Markdown AST into styled terminal output.

This renderer extends Markd::Renderer to produce ANSI-styled output

that matches Glow/Glamour's rendering behavior.

Constants

MARGIN = " "

Constructors

new(theme : Style::Theme = Style::Theme.dark, width : Int32 = 78, profile : Style::ColorProfile = Style::ColorProfile.detect, expand_emojis : Bool = true)
Source

Instance methods

alert(node : Markd::Node, entering : Bool) : Nil

Alert rendering (GitHub-style alerts: > [!NOTE], > [!WARNING], etc.)

Source
block_quote(node : Markd::Node, entering : Bool) : Nil

Block quote rendering — with styled prefix and content.

Source
code(node : Markd::Node, entering : Bool) : Nil

Code span rendering — styled with fg+bg color inline.

Source
code_block(node : Markd::Node, entering : Bool, formatter = nil) : Nil

Code block rendering — with syntax highlighting and code block style.

Source
emphasis(node : Markd::Node, entering : Bool) : Nil

Emphasis (italic) — pushes italic style onto the stack.

Source
expand_emojis=(expand_emojis : Bool)
Source
expand_emojis?
Source
heading(node : Markd::Node, entering : Bool) : Nil

Heading rendering — applies heading style (color, bold, bg) to content.

Source
html_block(node : Markd::Node, entering : Bool) : Nil

HTML block rendering — preserve literal HTML for terminal output.

Source
html_inline(node : Markd::Node, entering : Bool) : Nil

HTML inline rendering — preserve literal HTML inline.

Source
image(node : Markd::Node, entering : Bool) : Nil

Image rendering — styled with image colors.

Source
item(node : Markd::Node, entering : Bool) : Nil

List item rendering — with styled bullet/number prefix.

Source
line_break(node : Markd::Node, entering : Bool) : Nil

Line break (hard)

Source
list(node : Markd::Node, entering : Bool) : Nil

List rendering

Source
paragraph(node : Markd::Node, entering : Bool) : Nil

Paragraph rendering — wraps text and applies document styling.

Source
profile
Source
profile=(profile : Style::ColorProfile)
Source
render(markdown : String) : String

Renders a markdown string directly.

This is a convenience method that parses the markdown string and renders it.

renderer = Glimmer::Renderer::TermRenderer.new(theme: Glimmer::Style::Theme.dark)
puts renderer.render("# Hello\n\nThis is **bold**")
Source
render(document : Markd::Node)

Walks the Markd AST and dispatches to element handlers.

We override Markd::Renderer#render entirely to:

- Skip Document nodes (which otherwise emit spurious margin via text())

- Avoid Markd's sub("\n", "") which strips the first newline

ameba:disable Metrics/CyclomaticComplexity

Source
soft_break(node : Markd::Node, entering : Bool) : Nil

Soft break (line wrap)

Source
strikethrough(node : Markd::Node, entering : Bool) : Nil

Strikethrough rendering

Source
strong(node : Markd::Node, entering : Bool) : Nil

Strong (bold) — pushes bold style onto the stack.

Source
table(node : Markd::Node, entering : Bool) : Nil

Table rendering — collects rows and cells, then renders with borders.

Source
table_cell(node : Markd::Node, entering : Bool) : Nil

Table cell rendering — collects cell content.

Source
table_row(node : Markd::Node, entering : Bool) : Nil

Table row rendering — collects cells into a row.

Source
text(node : Markd::Node, entering : Bool) : Nil

Text rendering — applies inline styles from the stack.

Source
thematic_break(node : Markd::Node, entering : Bool) : Nil

Thematic break (horizontal rule) — styled dashes.

Source
theme
Source
theme=(theme : Style::Theme)
Source
width
Source
width=(width : Int32)
Source
wrapper
Source
wrapper=(wrapper : WordWrapper)
Source