redcarpet icon indicating copy to clipboard operation
redcarpet copied to clipboard

Add `step` parameter to `#list_item`

Open dchacke opened this issue 2 years ago • 1 comments

Would be useful to add a step parameter to the list_item method for ordered lists. That would allow users to do the following:

def list_item text, list_type, step = nil
  case list_type
  when :ordered
    %{<li data-step="#{step}">#{text}</li>}
  when :unordered
    %{<li>#{text}</li>}
  end
end

Then one could parse the first data-step in the contents passed to the list method to ensure that lists start at the given index. Or better yet, the gem could pass a new start parameter to the list method.

Either way, ordered lists continuing from an arbitrary index would then be possible, if they aren't already:

def list contents, list_type, start = 1
  case list_type
  when :ordered
    %{<ol start="#{start}">#{contents}</ol>}
  when :unordered
    # ...
  end
end

dchacke avatar Aug 25 '23 14:08 dchacke

I've proposed PR #741 to support broken-up ordered lists without resetting the numbering.

dchacke avatar Aug 25 '23 23:08 dchacke