HTML2Book settings

Html2Book adds an option to automatically create a new book page for each html heading and subheading in the body text. This makes it possible to use a book created in a word processing program or other structured html to create a multipage Drupal book in a single step. To use this feature, enable the module, then click on the HTML2Book Splitter collapsible box below the book body in the edit form.

Each new book page will have the same author, categories, settings, and other characteristics of the original page. If Organic Groups is used and the original page has been assigned to one or more groups, all child book pages will belong to the same groups.

All text before the first heading will be retained as the body of the original page. Subsequent pages will be added as children of that page, using the heading as their title and all text from that point to the next heading as their body. Child pages will be nested based on the subheadding number, if the subheadings are logically organized.

The option to create books from html is permissioned, so you can restrict it to users who will understand how to use it. You may want to combine this with the HTML Corrector filter (included in core starting in Drupal 6) along with either the htmlTidy or the htmLawed filter. For best results when using source material from Microsoft Word documents, save the Word document as 'HTML, filtered' and paste that result into your page. You may also find it helps to turn rich text editing off and paste the raw html into the body.

There is a nice article Converting a Word Doc and PDF into a Drupal Book for web display about using the D5 version to get external data into a Drupal book. The D5 version is no longer supported, but the D6 version works the same way and the issues are the same. The biggest problem is finding a way to get clean html into the top page so HTML2Book can parse and create the pages correctly.

TODO: The current code creates the whole book in a single pass, which works fine for small books but not large ones. The code needs to be rewritten to create the child pages in batches. I would welcome a patch to do that.

EXAMPLE:

INPUT:

Node 1 Title: My Book

Node 1 Body:
<div>Here is my page.</div>
<h1>Page 1</h1>
  <p>Here is my text for page 1.</p>
  <h2>Page 1a</h2>
    <p>This is page 1a.</p>
  <h2>Page 1b</h2>
    <p>This is page 1b.</p>
<h1>Page 2</h1>
  <p>This is page 2.</p>

CREATES:

Node 1 Title: My Book
Node 1 Body: <div>Here is my page.</div>
Node 1 Parent: <top level>
Node 1 Weight: -15

    Node 2 Title: Page 1
    Node 2 Body: <p>Here is my text for page 1.</p>
    Node 2 Parent: Node 1
    Node 2 Weight: -15

       Node 3 Title: Page 1a
       Node 3 Body: <p>This is page 1a.</p>
       Node 3 Parent: Node 2
       Node 3 Weight: -15

       Node 4 Title: Page 1b
       Node 4 Body: <p>This is page 1b.</p>
       Node 4 Parent: Node 2
       Node 4 Weight: -14

    Node 5 Title: Page 2
    Node 5 Body: <p>This is page 2.</p>
    Node 5 Parent: Node 1
    Node 5 Weight: -14

Project Information

Downloads

Recommended releases

Version Downloads Date Links
6.x-1.0 tar.gz (9.59 KB) | zip (10.67 KB) 2010-Aug-28 Notes

Development releases

Version Downloads Date Links
6.x-1.x-dev tar.gz (9.58 KB) | zip (10.58 KB) 2011-Feb-25 Notes

Maintainers for HTML2Book

  • KarenS - 8 commits
    last: 1 year ago, first: 4 years ago

Issues for HTML2Book

To avoid duplicates, please search before submitting a new issue.
All issues
Bug reports
Oldest open issue: 7 Sep 10
nobody click here