Index: modules/book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book.module,v
retrieving revision 1.319
diff -u -r1.319 book.module
--- modules/book.module	6 Oct 2005 09:17:17 -0000	1.319
+++ modules/book.module	6 Oct 2005 15:10:31 -0000
@@ -422,7 +422,16 @@
           foreach ($book as $key => $value) {
             $node->$key = $value;
           }
-          $node = theme('book_navigation', $node);
+
+          $path = book_location($node);
+          // Construct the breadcrumb:
+          $node->breadcrumb = array(); // Overwrite the trail with a book trail.
+          foreach ($path as $level) {
+            $node->breadcrumb[] = array('path' => 'node/'. $level->nid, 'title' =>  $level->title);
+          }
+          $node->breadcrumb[] = array('path' => 'node/'. $node->nid);
+          
+          $node->body .= theme('book_navigation', $node);
           if ($page) {
             menu_set_location($node->breadcrumb);
           }
@@ -439,16 +448,6 @@
  * @ingroup themeable
  */
 function theme_book_navigation($node) {
-  $path = book_location($node);
-
-  // Construct the breadcrumb:
-
-  $node->breadcrumb = array(); // Overwrite the trail with a book trail.
-  foreach ($path as $level) {
-    $node->breadcrumb[] = array('path' => 'node/'. $level->nid, 'title' =>  $level->title);
-  }
-  $node->breadcrumb[] = array('path' => 'node/'. $node->nid);
-
   if ($node->nid) {
     $output .= '<div class="book">';
 
@@ -487,9 +486,7 @@
     $output .= '</div>';
   }
 
-  $node->body = $node->body.$output;
-
-  return $node;
+  return $output;
 }
 
 /**
@@ -635,7 +632,6 @@
  *
  */
 function book_export($type = 'html', $nid = FALSE) {
-  global $base_url;
   $type = drupal_strtolower($type);
   $node = node_load($nid);
   if ($node) {
@@ -656,14 +652,7 @@
         for ($i = 1; $i < $depth; $i++) {
           $output .= "</div>\n";
         }
-        $html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
-        $html .= '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">';
-        $html .= "<head>\n<title>". check_plain($node->title) ."</title>\n";
-        $html .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
-        $html .= '<base href="'. $base_url .'/" />' . "\n";
-        $html .= "<style type=\"text/css\">\n@import url(misc/print.css);\n</style>\n";
-        $html .= "</head>\n<body>\n". $output . "\n</body>\n</html>\n";
-        print $html;
+        print theme('book_export_html', check_plain($node->title), $output);
         break;
       case 'opml':
         $output .= book_recurse($nid, $depth, 'book_node_visitor_opml_pre', 'book_node_visitor_opml_post');
@@ -682,6 +671,22 @@
     drupal_not_found();
   }
 }
+/**
+ * How the book's HTML export should be themed
+ *
+ * @ingroup themeable
+ */
+function theme_book_export_html($title, $content) {
+  global $base_url;
+  $html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
+  $html .= '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">';
+  $html .= "<head>\n<title>". $title ."</title>\n";
+  $html .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
+  $html .= '<base href="'. $base_url .'/" />' . "\n";
+  $html .= "<style type=\"text/css\">\n@import url(misc/print.css);\n</style>\n";
+  $html .= "</head>\n<body>\n". $content . "\n</body>\n</html>\n";
+  return $html;
+}
 
 /**
  * Given a node, this function returns the depth of the node in its hierarchy.
