%-
comment = if current.respond_to? :comment_location then
current.comment_location
else
current.comment
end
table = current.parse(comment).table_of_contents.dup
if table.length > 1 then %>
On this page
<%- display_link = proc do |heading| -%>
<%= heading.plain_html %>
<%- end -%>
<%- list_siblings = proc do -%>
<%- level = table.first&.level -%>
<%- while table.first && table.first.level >= level -%>
<%- heading = table.shift -%>
<%- if table.first.nil? || table.first.level <= heading.level -%>
<% display_link.call heading -%>
<%- else -%>
<%- display_link.call heading -%>
<%- end -%>
<%- end -%>
<%- end -%>
<%- end -%>