Sha256: 3bf77f2b99a81d9dd6b2897ba0fbb88a3cbd97fa74b7d06f1525b017eb167041

Contents?: true

Size: 636 Bytes

Versions: 1

Compression:

Stored size: 636 Bytes

Contents

module List_nonumber
  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<ul>\n<li>#$1</li>\n"}

    end_ul_rex = %r! 
      ^\*\s(\w*)\n # * list_end => <li>list_end</li>\n
      ^\s*$\n      # 空行 => </ul>\n\n
    !x
    parse_text = parse_text.gsub(end_ul_rex){|s| "<li>#$1</li>\n</ul>\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_nonumber.rb