Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stash array of numbers in a private constant #621

Merged
merged 1 commit into from Jul 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/kramdown/converter/html.rb
Expand Up @@ -152,12 +152,15 @@ def convert_hr(el, indent)
"#{' ' * indent}<hr#{html_attributes(el.attr)} />\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
Expand Down