fix(markdown): render ordered lists with custom values and handle multiline list items

This commit is contained in:
Paul Chavard 2023-07-26 18:55:02 +02:00
parent cf4048312e
commit 2daee794bc
3 changed files with 81 additions and 13 deletions

View file

@ -10,7 +10,14 @@ module Redcarpet
end
def list_item(content, list_type)
content_tag(:li, content.strip.gsub(/<\/?p>/, ''), {}, false)
item_number = content.match(/\[value:(\d+)\]/)
text = content.strip
.gsub(/<\/?p>/, '')
.gsub(/\[value:\d+\]/, '')
.gsub(/\n/, '<br>')
attributes = item_number.present? ? { value: item_number[1] } : {}
content_tag(:li, text, attributes, false)
end
def paragraph(text)