outfile.write(' <div id="main_panel">\n')
for topic_root in all_topic_roots:
outfile.write(' <div class="alt-content" id="topic-'+str(topic_root.index)+'">\n')
- top_post_blocks = list(filter(lambda x: x.start_pos_child < 0, topic_root.blocks.ranges))
- thread_post_blocks = list(filter(lambda x: x.start_pos_child >= 0, topic_root.blocks.ranges))
- if len(top_post_blocks) != 0:
- outfile.write(' <h1>Top-posted messages (sorry this looks like a mess)</h1>\n')
- for block in top_post_blocks:
- outfile.write(' <div class="message-block-container" style="margin-left:'+str(block.message.depth*4)+'em">\n')
- outfile.write(' <div class="message-block-meta">'+html.escape(block.message.from_hdr, quote=False)+'</div>\n')
- outfile.write(' <div class="message-block-content">'+html.escape(block.get_text(), quote=False)+'</div>\n')
- outfile.write(' </div>\n')
- outfile.write(' <h1>Actual thread</h1>\n')
- for block in thread_post_blocks:
+ printed_top_header = False
+ printed_threads_header = False
+ for block in topic_root.blocks.ranges:
+ if block.start_pos_child < 0 and not printed_top_header:
+ outfile.write(' <h1>Top-posted messages (sorry this section looks like a mess)</h1>\n')
+ printed_top_header = True
+ if block.start_pos_child >= 0 and not printed_threads_header:
+ outfile.write(' <h1>Actual thread</h1>\n')
+ printed_threads_header = True
outfile.write(' <div class="message-block-container" style="margin-left:'+str(block.message.depth*4)+'em">\n')
outfile.write(' <div class="message-block-meta">'+html.escape(block.message.from_hdr, quote=False)+'</div>\n')
outfile.write(' <div class="message-block-content">'+html.escape(block.get_text(), quote=False)+'</div>\n')