Class: Marvi::ASTWalker
- Inherits:
-
Object
- Object
- Marvi::ASTWalker
- Defined in:
- lib/marvi/ast_walker.rb
Constant Summary collapse
- HEADER_COLORS =
%i[cyan green yellow magenta white white].freeze
- DEFAULT_MAX_WIDTH =
80- MIN_COL_WIDTH =
4
Instance Method Summary collapse
Instance Method Details
#walk(markdown, max_width: nil) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/marvi/ast_walker.rb', line 14 def walk(markdown, max_width: nil) @max_width = max_width || Integer(ENV["COLUMNS"] || DEFAULT_MAX_WIDTH) doc = Kramdown::Document.new(markdown, input: "GFM") lines = render_block(doc.root) lines.pop while lines.last&.plain_text&.empty? lines end |