Closed (fixed)
Project:
Drupal core
Version:
6.12
Component:
book.module
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
25 May 2004 at 16:34 UTC
Updated:
18 May 2009 at 17:05 UTC
Jump to comment: Most recent file
When I ask for a "printer-friendly version" of a book, all the titles come out looking the same, they are marked:
h1 id="3" name="3" class="book-h1"
When I look at the code for function "book_print" in the book.module, it looks as if there is a variable which is supposed to change depending on the depth in the book - the variable is called $depth. But as far as I can see it is defined as "1" and never changes.
I can't find this marked as a bug, but it seems to me to be one. Excuse me if I have missed something.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | book_16.patch | 1.67 KB | killes@www.drop.org |
Comments
Comment #1
joel_guesclin commentedHere is a solution for this which seems to work:
In functions book_print and book_print_recurse change the line:
so that it looks like this:
This gets rid of the class book-h1 which is not referenced in the print.css
Then, in book_print make sure that the call to book_print_recurse shows:
Correct the definition of book_print_recurse to read:
Then you might want to play with the misc/print.css but I'm still having trouble understanding that.
Comment #2
moshe weitzman commentedI can confirm that book.module is still outputting this non-ideal markup in HEAD. See book_print()
Comment #3
killes@www.drop.org commentedHere is a patch that also takes care to no increase the depth over 6. The patch is untested but run through php -l.
Comment #4
killes@www.drop.org commentedAnd here'S the patch...
Comment #5
dries commentedNot sure. A lot of book pages use h2 and h3 headers.
Comment #6
killes@www.drop.org commentedIMNSHO they shouldn't. If you need substructures that qualify for h2 or h3 you should create subpages. Long pages aren't good to read on a screen.
Comment #7
Steven commentedThe book has to do a trade-off between the amount of clicks required to reach a topic and the amount of information on a page. There are many cases where h2 and h3 usage is valid.
Comment #8
Steven commentedThe book has to do a trade-off between the amount of clicks required to reach a topic and the amount of information on a page. There are many cases where h2 and h3 usage is valid.
Comment #9
Steven commentedIt should be possible to check which h's are used in a book page, and renumber them.
Eg. if we are at level 3 in the book (<h3>), and the body uses <h2> and <h4>, we renumber those to <h4> and <h5>.
Comment #10
dries commentedNot going to commit this patch as is. It needs more thought.
Comment #11
clairem commentedI'm glad to see that this patch is still marked as active, beacuse I want to suggest an alternative way of developing the same idea -- which at its core is about differentiating the difft levels of a book.
First I should say that I agree with Steven's point that use of h2 and h3 can sometimes be valid in book pages, and I would add that possibly h4 h5 and h6 may be valid as well. We may all have our preferences, but site maintainers juggling their options may make their choices in circumstances which developers have not envisaged. Renumbering hn tags could break pages: a h3 tag in a book page at depth4 would be renumbered as h7. Not good.
So, instead of renumbering the headings, why not use the depth to wrap each book page in a div with an appropriate class, like this:
Then print.css could set the indentation for depth, as follows:
Site managers could modify print.css to suit their needs, without ever having to tweak the Drupal code ... and without their hn tags being modified
Comment #12
puregin commentedPlease see also the related discussion on
http://drupal.org/node/1898
I'm completely in support of clairem's idea to wrap sections in
<div>tags.However, at the risk of repeating myself to excess - any use of H1, H2, ... H6 inside of a book page is a sign of something not right. These should never appear. Having them present implies:
If you feel the urge to include them in your book page, one or more of the following is probably true:
<dl>, <dt>, <dd>insteadComment #13
puregin commentedPlease see also the related discussion on
http://drupal.org/node/1898
I'm completely in support of clairem's idea to wrap sections in
<div>tags.However, at the risk of repeating myself to excess - any use of H1, H2, ... H6 inside of a book page is a sign of something not right. These should never appear. Having them present implies:
If you feel the urge to include them in your book page, one or more of the following is probably true:
<dl>, <dt>, <dd>insteadComment #14
puregin commentedThis issue is fixed with the patch for http://drupal.org/node/1482, together with the print.css stylesheet patch provided in http://drupal.org/node/1898.
Comment #15
puregin commentedMarking this as fixed now that the patch for http://drupal.org/node/1482 has been committed.
Comment #16
(not verified) commentedComment #17
RockyRoad commentedHi,
The book module has probably changed significantly since last comment here.
But the problem is still there IMHO.
I use a simple way to write css (for drupal 6x book), which conciliates both approaches (use book outline vs. use node contents headings).
For me, book writers would rather concentrate on their subject than on the undocumented prefered practices of modules maintainers.
Here's a simplified part of it:
I hope these "two cents" can help.
But one thing I don't understand is why the html exported book takes his stylesheet in the
misc/directory.I would like to see a default stylesheet provided by the book module, and a user setting to override it.
But I didn't had a look in book.module sources yet.
Best regards,