Sha256: e1910ed2667f65ec68fe86b1ce407dde9df37ea6ecefeb71804be0ef799dae5a

Contents?: true

Size: 638 Bytes

Versions: 1

Compression:

Stored size: 638 Bytes

Contents

module List_number
  def parse text
    start_ul_rex = %r! 
      ^\s*$\n         # 空行 => \n<ul>\n
      ^\#\s(\w*)\n    # # list_start => <li>list_start</li>\n
    !x
    parse_text = text.gsub(start_ul_rex){|s| "\n<ol>\n<li>#$1</li>\n"}

    end_ul_rex = %r! 
      ^\#\s(\w*)\n  # # list_end => <li>list_end</li>\n
      ^\s*$\n       # 空行 => </ol>\n\n
    !x
    parse_text = parse_text.gsub(end_ul_rex){|s| "<li>#$1</li>\n</ol>\n\n"}

    # * list => <li>list</li>
    parse_text = parse_text.gsub(/^\#\s(\w*)\n/){|s| "<li>#$1</li>\n"}
    return text if parse_text == nil
    parse_text
  end 

  module_function :parse
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wparser-0.0.2 lib/wparser/block/list_number.rb