lib/maruku/input/parse_block.rb
# This is the only ugly function in the code base.
# It is used to read list items, descriptions, footnote text
This is the only ugly function in the code base.
It is used to read list items, descriptions, footnote text
This is the only ugly function in the code base . It is used to read list items descriptions footnote text
def read_indented_content(src, indentation, break_list, item_type, ial_offset=0)
    lines = []
    saw_empty = false
    saw_anything_after = false
    break_list = Array(break_list)
    len = indentation - ial_offset
    while src.cur_line
      num_leading_spaces = src.cur_line.number_of_leading_spaces
      break if num_leading_spaces < len && ![:text, :empty, :code].include?(src.cur_line.md_type)
      line = strip_indent(src.cur_line, indentation)
      md_type = line.md_type
      if md_type == :empty
        saw_empty = true
        lines << line
        src.shift_line
        next
      end
      if md_type != :code && num_leading_spaces > len
        lines << line
        src.shift_line
        next
      end
      if saw_empty
        break if num_leading_spaces < len
        saw_anything_after = true
      else
        break if break_list.include?(md_type)
      end
      if md_type == :code && num_leading_spaces > len+6
        lines << strip_indent(src.cur_line, num_leading_spaces-4)
        src.shift_line
        next
      end
      lines << line
      src.shift_line
      if md_type == :text
        while src.cur_line && src.cur_line.md_type == :text
          lines << strip_indent(src.shift_line, indentation)
        end
      end
    end
    want_my_paragraph = saw_anything_after ||
      (saw_empty && src.cur_line && src.cur_line.md_type == item_type)
    while lines.last && lines.last.md_type == :empty
      lines.pop
    end
    return lines, want_my_paragraph
  end
def read_indented_content ( src , indentation , break_list , item_type , ial_offset = 0 ) lines = [ ] saw_empty = false saw_anything_after = false break_list = Array ( break_list ) len = indentation - ial_offset while src . cur_line num_leading_spaces = src . cur_line . number_of_leading_spaces break if num_leading_spaces < len && ! [ :text , :empty , :code ] . include? ( src . cur_line . md_type ) line = strip_indent ( src . cur_line , indentation ) md_type = line . md_type if md_type == :empty saw_empty = true lines << line src . shift_line next end if md_type != :code && num_leading_spaces > len lines << line src . shift_line next end if saw_empty break if num_leading_spaces < len saw_anything_after = true else break if break_list . include? ( md_type ) end if md_type == :code && num_leading_spaces > len + 6 lines << strip_indent ( src . cur_line , num_leading_spaces - 4 ) src . shift_line next end lines << line src . shift_line if md_type == :text while src . cur_line && src . cur_line . md_type == :text lines << strip_indent ( src . shift_line , indentation ) end end end want_my_paragraph = saw_anything_after || ( saw_empty && src . cur_line && src . cur_line . md_type == item_type ) while lines . last && lines . last . md_type == :empty lines . pop end return lines , want_my_paragraph end
This is the only ugly function in the code base.
This is the only ugly function in the code base .
# collect all indented lines # Unquestioningly grab anything that's deeper-indented # after a white line # we expect things to be properly aligned # You are only required to indent the first line of # a child paragraph. # TODO fix this # create a new context
src
indentation
break_list
item_type
ial_offset