Sha256: 46f3cabfc8de6d6ffcdd5db42401842c503aa78d076c17b3923c27c8a217b079
Contents?: true
Size: 1.31 KB
Versions: 4
Compression:
Stored size: 1.31 KB
Contents
# frozen_string_literal: true require 'html/pipeline' require 'html/pipeline/task_list/summary' module HTML class Pipeline # Generates task lists (e.g., checkboxes) from Github falvored # markdown. See ./filter.rb for more details class TaskList attr_reader :record # `record` is the resource with the Markdown source text with task list items # following this syntax: # # - [ ] a task list item # - [ ] another item # - [x] a completed item # def initialize(record) @record = record end # Public: return the TaskList::Summary for this task list. # # Returns a TaskList::Summary. def summary @summary ||= HTML::Pipeline::TaskList::Summary.new(record.task_list_items) end Item = Struct.new(:checkbox_text, :source) do COMPLETE = /\[[xX]\]/.freeze # see TaskList::Filter # Public: Check if a task list is complete. # # Examples # # Item.new(checkbox_text: "- [x]").complete? # # => true # # Item.new(checkbox_text: "- [ ]").complete? # # => false # # Returns true for checked list, false otherwise def complete? checkbox_text =~ COMPLETE end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems