Sha256: 1fd7938551e0e463b4046d04e1959e6144c52573773635776d1362bd36f844cc
Contents?: true
Size: 639 Bytes
Versions: 4
Compression:
Stored size: 639 Bytes
Contents
# frozen_string_literal: true require 'redcarpet' class MarkdownParserService class ListExtractor < Redcarpet::Render::Base attr_reader :files def list(_contents, _list_type) @next_is_hint = true '' end def list_item(text, _list_type) @files ||= [] if @next_is_hint @files.last.unshift text.strip @next_is_hint = false else @files << [text.strip] end '' end end def parse_markdown(markdown_text) renderer = ListExtractor.new markdown = Redcarpet::Markdown.new(renderer) markdown.render(markdown_text) renderer.files end end
Version data entries
4 entries across 4 versions & 1 rubygems