Class: Charming::Presentation::Components::Markdown
- Inherits:
-
Charming::Presentation::Component
- Object
- View
- Charming::Presentation::Component
- Charming::Presentation::Components::Markdown
- Defined in:
- lib/charming/presentation/components/markdown.rb
Overview
Markdown renders Markdown source as ANSI-styled terminal text. Parsing is delegated to ‘Presentation::Markdown::Renderer`; set syntax_highlighting to false to disable Rouge-backed code block highlighting.
Instance Method Summary collapse
-
#initialize(content:, width: nil, theme: nil, syntax_highlighting: true) ⇒ Markdown
constructor
content is the Markdown source string.
-
#render ⇒ Object
Renders the Markdown body to a styled, terminal-safe string.
Methods inherited from View
Constructor Details
#initialize(content:, width: nil, theme: nil, syntax_highlighting: true) ⇒ Markdown
content is the Markdown source string. width optionally sets the wrap width. syntax_highlighting enables Rouge for code blocks (defaults to true).
12 13 14 15 16 17 |
# File 'lib/charming/presentation/components/markdown.rb', line 12 def initialize(content:, width: nil, theme: nil, syntax_highlighting: true) super(theme: theme) @content = content @width = width @syntax_highlighting = syntax_highlighting end |
Instance Method Details
#render ⇒ Object
Renders the Markdown body to a styled, terminal-safe string.
20 21 22 23 24 25 26 27 |
# File 'lib/charming/presentation/components/markdown.rb', line 20 def render Charming::Presentation::Markdown::Renderer.new( content: @content, width: @width, theme: theme, syntax_highlighting: @syntax_highlighting ).render end |