class Muwu::RenderHtmlPartial::Contents
Attributes
destination[RW]
href_helper[RW]
html_attr_id[RW]
item_depth_max[RW]
project[RW]
sections[RW]
text_root_name[RW]
will_render_section_numbers[RW]
Public Instance Methods
render()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 28 def render @destination.margin_to_zero @destination.padding_vertical(1) do write_tag_div_open render_contents_heading render_contents_element(@sections) write_tag_div_close end @destination.margin_to_zero end
render_contents_element(sections)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 40 def render_contents_element(sections) @destination.margin_indent do case @will_render_section_numbers when false render_ol(sections) when true render_table(sections) end end end
render_contents_heading()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 52 def render_contents_heading write_tag_h1_contents_heading end
render_ol(text_item)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 57 def render_ol(text_item) write_tag_ol_open @destination.margin_indent do text_item.each do |section| render_ol_li(section) end end write_tag_ol_close end
render_ol_li(text_item)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 68 def render_ol_li(text_item) if task_depth_is_within_range(text_item) if text_item.is_parent_heading write_tag_li_open @destination.margin_indent do render_ol_li_heading_and_subsections(text_item) end write_tag_li_close_outline elsif text_item.is_not_parent_heading write_tag_li_open render_ol_li_heading(text_item) write_tag_li_close_inline end end end
render_ol_li_heading(text_item)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 85 def render_ol_li_heading(text_item) render_tag_a_section_heading(text_item) end
render_ol_li_heading_and_subsections(text_item)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 90 def render_ol_li_heading_and_subsections(text_item) render_tag_a_section_heading(text_item, trailing_line_feed: true) render_ol(text_item.sections) end
render_table(text_item)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 96 def render_table(text_item) write_tag_table_open @destination.margin_indent do text_item.each do |section| render_table_tr(section) end end write_tag_table_close end
render_table_tr(section)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 107 def render_table_tr(section) if task_depth_is_within_range(section) html_id = ['contents', @text_root_name, section.numbering.join('_')].join('_') write_tag_tr_open(html_id) @destination.margin_indent do if section.is_parent_heading render_table_tr_td_number(section) render_table_tr_td_heading_and_subsections(section) elsif section.is_not_parent_heading render_table_tr_td_number(section) render_table_tr_td_heading(section) end end write_tag_tr_close end end
render_table_tr_td_heading(text_item)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 125 def render_table_tr_td_heading(text_item) write_tag_td_open(attr_list: "class='heading'") render_tag_a_section_heading(text_item) write_tag_td_close_inline end
render_table_tr_td_heading_and_subsections(text_item)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 132 def render_table_tr_td_heading_and_subsections(text_item) write_tag_td_open(attr_list: "class='heading'") render_tag_a_section_heading(text_item, trailing_line_feed: true) @destination.margin_indent do render_table(text_item.sections) end write_tag_td_close_outline end
render_table_tr_td_number(text_item)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 142 def render_table_tr_td_number(text_item) write_tag_td_open(attr_list: "class='number'") render_tag_a_section_number(text_item, attr_list: "tabindex='-1'") write_tag_td_close_inline end
render_tag_a_section_heading(text_item, trailing_line_feed: false)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 149 def render_tag_a_section_heading(text_item, trailing_line_feed: false) href = @href_helper.to_text_item(text_item) write_tag_a_open(href) write_text_section_heading(text_item) write_tag_a_close if trailing_line_feed write_lf end end
render_tag_a_section_number(text_item, attr_list: nil)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 160 def render_tag_a_section_number(text_item, attr_list: nil) href = @href_helper.to_text_item(text_item) write_tag_a_open(href, attr_list: attr_list) write_text_section_number(text_item) write_tag_a_close end
write_lf()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 168 def write_lf @destination.write_lf end
write_tag_a_close()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 173 def write_tag_a_close @destination.write_inline tag_a_close end
write_tag_a_open(href_id, attr_list: nil)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 178 def write_tag_a_open(href_id, attr_list: nil) @destination.write_inline tag_a_open(href_id, attr_list: attr_list) end
write_tag_div_close()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 183 def write_tag_div_close @destination.write_line tag_div_close end
write_tag_div_open()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 188 def write_tag_div_open @destination.write_line tag_div_open end
write_tag_h1_contents_heading()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 193 def write_tag_h1_contents_heading @destination.write_line tag_h1_contents_heading end
write_tag_li_close()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 198 def write_tag_li_close write_tag_li_close_outline end
write_tag_li_close_inline()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 203 def write_tag_li_close_inline @destination.write_inline_end tag_li_close end
write_tag_li_close_outline()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 208 def write_tag_li_close_outline @destination.write_line tag_li_close end
write_tag_li_open()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 213 def write_tag_li_open @destination.write_inline_indented tag_li_open end
write_tag_ol_close()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 218 def write_tag_ol_close @destination.write_line tag_ol_close end
write_tag_ol_open()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 223 def write_tag_ol_open @destination.write_line tag_ol_open end
write_tag_table_close()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 228 def write_tag_table_close @destination.write_line tag_table_close end
write_tag_table_open()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 233 def write_tag_table_open @destination.write_line tag_table_open end
write_tag_td_close()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 238 def write_tag_td_close write_tag_td_close_outline end
write_tag_td_close_inline()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 243 def write_tag_td_close_inline @destination.write_inline_end tag_td_close end
write_tag_td_close_outline()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 248 def write_tag_td_close_outline @destination.write_line tag_td_close end
write_tag_td_open(attr_list: nil)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 253 def write_tag_td_open(attr_list: nil) @destination.write_inline_indented tag_td_open(attr_list: attr_list) end
write_tag_tr_close()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 258 def write_tag_tr_close @destination.write_line tag_tr_close end
write_tag_tr_open(html_id)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 263 def write_tag_tr_open(html_id) @destination.write_line tag_tr_open(html_id) end
write_text_section_heading(textobject)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 268 def write_text_section_heading(textobject) @destination.write_inline CGI::escape_html(textobject.heading) end
write_text_section_number(textobject)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 273 def write_text_section_number(textobject) @destination.write_inline textobject.numbering.join('.') end
Private Instance Methods
tag_a_close()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 282 def tag_a_close "</a>" end
tag_a_open(href_id, attr_list: nil)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 287 def tag_a_open(href_id, attr_list: nil) ["<a", "class='document_link'", "href='#{href_id}'", attr_list].compact.join(' ').concat('>') end
tag_div_close()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 292 def tag_div_close "</div>" end
tag_div_open()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 297 def tag_div_open "<div class='contents' data-text_root_name='#{@text_root_name}' id='#{@html_attr_id}'>" end
tag_h1_contents_heading()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 302 def tag_h1_contents_heading "<h1>Contents</h1>" end
tag_li_close()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 307 def tag_li_close "</li>" end
tag_li_open()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 312 def tag_li_open "<li>" end
tag_ol_close()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 317 def tag_ol_close "</ol>" end
tag_ol_open()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 322 def tag_ol_open "<ol>" end
tag_table_close()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 327 def tag_table_close "</table>" end
tag_table_open()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 332 def tag_table_open "<table class='document_links'>" end
tag_td_close()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 337 def tag_td_close "</td>" end
tag_td_open(attr_list: nil)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 342 def tag_td_open(attr_list: nil) ["<td", attr_list].compact.join(' ').concat('>') end
tag_tr_close()
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 347 def tag_tr_close "</tr>" end
tag_tr_open(html_id)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 352 def tag_tr_open(html_id) "<tr id='#{html_id}'>" end
task_depth_is_within_range(textobject)
click to toggle source
# File lib/muwu/render_html_partial/render_contents.rb, line 357 def task_depth_is_within_range(textobject) result = nil if @item_depth_max == nil result = true elsif textobject.section_depth <= @item_depth_max result = true elsif textobject.section_depth > @item_depth_max result = false end result end