Class: TipTap::Nodes::OrderedList
- Inherits:
-
TipTap::Node
- Object
- TipTap::Node
- TipTap::Nodes::OrderedList
- Defined in:
- lib/tip_tap/nodes/ordered_list.rb
Instance Attribute Summary
Attributes included from HtmlRenderable
Attributes included from HasContent
Instance Method Summary collapse
Methods included from PlainTextRenderable
Methods included from JsonRenderable
#include_empty_content_in_json?, #to_h
Methods included from HtmlRenderable
#html_attributes, #html_class_name, #html_tag, included, #inline_styles, #to_html
Methods included from HasContent
#add_content, #blank?, #each, #find_node, included, #initialize, #size
Methods included from Registerable
Instance Method Details
#list_item(&block) ⇒ Object
12 13 14 15 16 |
# File 'lib/tip_tap/nodes/ordered_list.rb', line 12 def list_item(&block) raise ArgumentError, "Block required" if block.nil? add_content(ListItem.new(&block)) end |
#start ⇒ Object
18 19 20 |
# File 'lib/tip_tap/nodes/ordered_list.rb', line 18 def start attrs["start"] end |
#to_markdown(context = Markdown::Context.root) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/tip_tap/nodes/ordered_list.rb', line 22 def to_markdown(context = Markdown::Context.root) starting_index = start.to_i starting_index = 1 if starting_index <= 0 content.each_with_index.map do |node, index| marker = "#{starting_index + index}. " node.to_markdown(context, marker: marker) end.join("\n") end |