From 8729ffcb6b2e83b82bbcee5e457eac4d7e22e9fd Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Sun, 14 Jul 2019 15:03:15 +0530 Subject: [PATCH] Stash array of numbers in a private constant --- lib/kramdown/converter/html.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/kramdown/converter/html.rb b/lib/kramdown/converter/html.rb index e97422a9..60b98943 100644 --- a/lib/kramdown/converter/html.rb +++ b/lib/kramdown/converter/html.rb @@ -152,12 +152,15 @@ def convert_hr(el, indent) "#{' ' * indent}\n" end + ZERO_TO_ONETWENTYEIGHT = (0..128).to_a.freeze + private_constant :ZERO_TO_ONETWENTYEIGHT + def convert_ul(el, indent) if !@toc_code && (el.options[:ial][:refs].include?('toc') rescue nil) - @toc_code = [el.type, el.attr, (0..128).to_a.map { rand(36).to_s(36) }.join] + @toc_code = [el.type, el.attr, ZERO_TO_ONETWENTYEIGHT.map { rand(36).to_s(36) }.join] @toc_code.last elsif !@footnote_location && el.options[:ial] && (el.options[:ial][:refs] || []).include?('footnotes') - @footnote_location = (0..128).to_a.map { rand(36).to_s(36) }.join + @footnote_location = ZERO_TO_ONETWENTYEIGHT.map { rand(36).to_s(36) }.join else format_as_indented_block_html(el.type, el.attr, inner(el, indent), indent) end