Class: Charming::Components::Markdown
- Inherits:
-
Charming::Component
- Object
- View
- Charming::Component
- Charming::Components::Markdown
- Defined in:
- lib/charming/presentation/components/markdown.rb
Overview
Markdown renders CommonMark/GFM source as ANSI-styled terminal text. hyperlinks (default false) emits OSC 8 escapes so links are clickable in modern terminals.
Instance Method Summary collapse
-
#initialize(content:, width: nil, theme: nil, syntax_highlighting: true, style: :dark, base_url: nil, hyperlinks: false) ⇒ Markdown
constructor
A new instance of Markdown.
-
#render ⇒ Object
Renders the Markdown body to a styled, terminal-safe string.
Methods inherited from Charming::Component
Methods inherited from View
Constructor Details
#initialize(content:, width: nil, theme: nil, syntax_highlighting: true, style: :dark, base_url: nil, hyperlinks: false) ⇒ Markdown
Returns a new instance of Markdown.
9 10 11 12 13 14 15 16 17 |
# File 'lib/charming/presentation/components/markdown.rb', line 9 def initialize(content:, width: nil, theme: nil, syntax_highlighting: true, style: :dark, base_url: nil, hyperlinks: false) super(theme: theme) @content = content @width = width @syntax_highlighting = syntax_highlighting @style = style @base_url = base_url @hyperlinks = hyperlinks end |
Instance Method Details
#render ⇒ Object
Renders the Markdown body to a styled, terminal-safe string.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/charming/presentation/components/markdown.rb', line 20 def render Charming::Markdown::Renderer.new( content: @content, width: @width, theme: theme, syntax_highlighting: @syntax_highlighting, style: @style, base_url: @base_url, hyperlinks: @hyperlinks ).render end |