parameters: (self, tree_iter, only_selection=False)
docstring: Export a Node To HTML
docstring_summary: Export a Node To HTML
docstring_tokens: Export a Node To HTML
function: def node_export_to_html(self, tree_iter, only_selection=False):
          """Export a Node To HTML"""
          if only_selection:
              iter_start, iter_end = self.dad.curr_buffer.get_selection_bounds()
              sel_range = [iter_start.get_offset(), iter_end.get_offset()]
          else: sel_range = None
          html_text = cons.HTML_HEADER % clean_text_to_utf8(self.dad.treestore[tree_iter][1])
          # add redirect from some html to index.html, to have a link tree
          if self.tree_links_text and self.dad.last_index_in_page:
              script = '''
      <script type="text/javascript">
          function in_frame () { try { return window.self !== window.top; } catch (e) { return true; } }
          if (!in_frame()) {
              var page = location.pathname.substring(location.pathname.lastIndexOf("/") + 1);
              window.location = 'index.html#' + page;
          }
      </script>'''
              html_text = html_text.replace("<script></script>", script)
  
          html_text += r'<div class="page">'
          if self.dad.last_include_node_name:
              html_text += '<h1 class="title">%s</h1><br/>' % clean_text_to_utf8(self.dad.treestore[tree_iter][1])
          self.dad.get_textbuffer_from_tree_iter(tree_iter)
          if self.dad.treestore[tree_iter][4] == cons.RICH_TEXT_ID:
              text_n_objects = self.html_get_from_treestore_node(tree_iter, sel_range)
              self.images_count = 0
              for i, html_slot in enumerate(text_n_objects[0]):
                  html_text += html_slot
                  if i < len(text_n_objects[1]):
                      curr_object = text_n_objects[1][i]
                      if curr_object[0] == "pixbuf":
                          pix_dir = dir(curr_object[1][1])
                          if "embfile" in pix_dir:
                              html_text += self.get_embfile_html(curr_object[1], tree_iter)
                          else:
                              html_text += self.get_image_html(curr_object[1], tree_iter)
                      elif curr_object[0] == "table": html_text += self.get_table_html(curr_object[1])
                      elif curr_object[0] == "codebox": html_text += self.get_codebox_html(curr_object[1])
          else: html_text += self.html_get_from_code_buffer(self.dad.treestore[tree_iter][2], sel_range)
          if self.tree_links_text and not self.dad.last_index_in_page:
              html_text += '<p align="center">' + '<img src="%s" height="22" width="22">' % os.path.join("images", "home.png") + 2*cons.CHAR_SPACE + '<a href="index.html">' + _("Index") + '</a></p>'
          html_text += '</div>' # div class="page"
          html_text += cons.HTML_FOOTER
          node_html_filepath = os.path.join(self.new_path, self.get_html_filename(tree_iter))
          #print "full=%s(prefix=%s)" % (len(node_html_filepath), len(self.new_path))
          file_descriptor = open(node_html_filepath, 'w')
          file_descriptor.write(html_text)
          file_descriptor.close()
function_tokens: def node_export_to_html ( self , tree_iter , only_selection = False ) : if only_selection : iter_start , iter_end = self . dad . curr_buffer . get_selection_bounds ( ) sel_range = [ iter_start . get_offset ( ) , iter_end . get_offset ( ) ] else : sel_range = None html_text = cons . HTML_HEADER % clean_text_to_utf8 ( self . dad . treestore [ tree_iter ] [ 1 ] ) # add redirect from some html to index.html, to have a link tree if self . tree_links_text and self . dad . last_index_in_page : script = '''
      <script type="text/javascript">
          function in_frame () { try { return window.self !== window.top; } catch (e) { return true; } }
          if (!in_frame()) {
              var page = location.pathname.substring(location.pathname.lastIndexOf("/") + 1);
              window.location = 'index.html#' + page;
          }
      </script>''' html_text = html_text . replace ( "<script></script>" , script ) html_text += r'<div class="page">' if self . dad . last_include_node_name : html_text += '<h1 class="title">%s</h1><br/>' % clean_text_to_utf8 ( self . dad . treestore [ tree_iter ] [ 1 ] ) self . dad . get_textbuffer_from_tree_iter ( tree_iter ) if self . dad . treestore [ tree_iter ] [ 4 ] == cons . RICH_TEXT_ID : text_n_objects = self . html_get_from_treestore_node ( tree_iter , sel_range ) self . images_count = 0 for i , html_slot in enumerate ( text_n_objects [ 0 ] ) : html_text += html_slot if i < len ( text_n_objects [ 1 ] ) : curr_object = text_n_objects [ 1 ] [ i ] if curr_object [ 0 ] == "pixbuf" : pix_dir = dir ( curr_object [ 1 ] [ 1 ] ) if "embfile" in pix_dir : html_text += self . get_embfile_html ( curr_object [ 1 ] , tree_iter ) else : html_text += self . get_image_html ( curr_object [ 1 ] , tree_iter ) elif curr_object [ 0 ] == "table" : html_text += self . get_table_html ( curr_object [ 1 ] ) elif curr_object [ 0 ] == "codebox" : html_text += self . get_codebox_html ( curr_object [ 1 ] ) else : html_text += self . html_get_from_code_buffer ( self . dad . treestore [ tree_iter ] [ 2 ] , sel_range ) if self . tree_links_text and not self . dad . last_index_in_page : html_text += '<p align="center">' + '<img src="%s" height="22" width="22">' % os . path . join ( "images" , "home.png" ) + 2 * cons . CHAR_SPACE + '<a href="index.html">' + _ ( "Index" ) + '</a></p>' html_text += '</div>' # div class="page" html_text += cons . HTML_FOOTER node_html_filepath = os . path . join ( self . new_path , self . get_html_filename ( tree_iter ) ) #print "full=%s(prefix=%s)" % (len(node_html_filepath), len(self.new_path)) file_descriptor = open ( node_html_filepath , 'w' ) file_descriptor . write ( html_text ) file_descriptor . close ( )