Sha256: c5a485e445b4adb83492ba2da52b0d03cf043b426b47bd6d730800f3ada4f409

Contents?: true

Size: 519 Bytes

Versions: 1

Compression:

Stored size: 519 Bytes

Contents

require "redcarpet"

module Methan


  class MdRenderer < ::Redcarpet::Render::HTML
    def list_item(text, list_type)
      tag = "<li"
      r = /^\[(\s|x)\]\s/
      m = r.match(text)
      if m
        input_tag = "<input type=\"checkbox\""
        input_tag << " checked=\"true\"" if m[1] and m[1] == 'x'
        input_tag << ">"
        text = text.gsub(r, '')
        text = "#{input_tag} #{text}"
        tag << " class=\"task-item\""
      end
      tag << ">#{text}</li>"
      return tag
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
methan-0.1.0 lib/methan/md_renderer.rb