diff --git a/app/helpers/excerpt_helper.rb b/app/helpers/excerpt_helper.rb index b48986c26..03af24bd6 100644 --- a/app/helpers/excerpt_helper.rb +++ b/app/helpers/excerpt_helper.rb @@ -3,9 +3,10 @@ module ExcerptHelper return "" if content.blank? text = content.respond_to?(:to_plain_text) ? content.to_plain_text : content.to_s + text = text.first(length * 2) text = text.gsub(/^>\s*(.*)$/m, '> \1') text = text.gsub(/^\s*[-+]\s*(.*)$/m, '• \1') - text = text.gsub(/^\d+\.\s*(.*)$/m) { |m| m } + text = text.gsub(/^\s*(\d+\.)\s*(.*)$/m, '\1 \2') text = text.gsub(/\s+/, " ").strip text.truncate(length) end diff --git a/test/helpers/excerpt_helper_test.rb b/test/helpers/excerpt_helper_test.rb index ef685680b..1933177a9 100644 --- a/test/helpers/excerpt_helper_test.rb +++ b/test/helpers/excerpt_helper_test.rb @@ -11,7 +11,8 @@ class ExcerptHelperTest < ActionView::TestCase end test "ol" do - assert_excerpt("99. Hello world", "99. Hello world") + assert_excerpt("99. Hello world", "99. Hello world") + assert_excerpt("99. Hello world", " 99. Hello world") end test "large spaces" do