Class: JayFixIndentDepth

Inherits:
HTML::Pipeline::TextFilter
  • Object
show all
Defined in:
lib/jay_flavored_markdown/markdown_converter.rb

Overview

Fix the depth of the indent to multiple of 4(INDENT_DEPTH)

Constant Summary collapse

INDENT_DEPTH =
4

Instance Method Summary collapse

Instance Method Details

#callObject



674
675
676
677
678
679
680
681
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 674

def call
  lines = @text.split("\n")
  items = MarkdownEnumerator.new(lines)

  @text = items.filter do |header, count|
    header.sub(/^(\s*)([*+-])(\s+)/){|x| "#{valid_indent(count)}#{$2}#{$3}"}
  end.join("\n")
end