lukaiser / pressbooks-lists

0 stars 0 forks source link

all header tags added to TOC #9

Open bdolor opened 10 years ago

bdolor commented 10 years ago

The functionality of header tags (h1-h6) within the content body making up a new Table of Contents is not desirable functionality. Limiting the scope of which header tags get added to the Table of Contents would be helpful in reducing the size of a very large TOC.

Enforcing the prepending of a numeric identifier to header tags with the TOC may not be desirable in all use cases. The fact that this is not optional and not undo-able could be problematic for adding this feature to existing books.

screen shot 2014-09-09 at 3 54 36 pm

lukaiser commented 10 years ago

There is a difference between the TOC in the admin panel and the TOC in the outputs. In the admin panel all levels are shown. The reason for this is, that you can easily change h4, h5, h6 to h1, h2, h3 if you did not do it correctly while creating the chapters. In all the outputs only h1, h2 and h3 are shown. And you can change that in the template. Is it okay?

The numbers are added to all levels. And I see how that can be a problem. You can remove the number by removing the heading from the TOC. There is still the "Parse Sections" option. If you turn it of no headings are added to the TOC. I could use that to also disable numbering of the h1-h6. Would that be a solution?

lukaiser commented 10 years ago

What if I replace the "Parse Sections" (should now have an other name anyway). With a dropdown Fiction/Non-Fiction. (Fiction is the basic setting)

Fiction means that everything works as up to now. No headings added to the toc, no numbers added to heanding, images and tables. Basically how things where bevor sections where added.

The non-fiction would work the way I just enhanced it. All the heading represented in the toc get a number (Except if you turn numbers of), all selected images and tables get an number (either continuously if the chapters have no numbers or with the chapter prefix) and three layers are been added to the toc with the selected headings. (A dropdown for the number of layers would be possible too. I know, you guys what to keep it simple, but it would only show up in the Non-Fiction version and it gets a little more complicated there any way)

Everything between the two settings is possible for advanced user by the template and hooks.

lukaiser commented 10 years ago

Now that I have testet the Mastering Strategic Management book I see the problem with the Lists->TOC. Maybe I could add a filter for how many levels should been shown. I don't think that restricting it without possibility to change it is a solution. I just worked on a book with wrong heading types and the view was really handy! What do you guys think?

lukaiser commented 10 years ago

I just committed some changes with my proposals for the problems above:

Commit 0b6a614b839805ee7412f108bab7c4f57bacdc80: I replaced the "Parse Sections" option with a "Add headings to TOC" option. It is a dropdown where you can select if none, h1, h1 & h2, h1 & h2 & h3, etc. are added to the TOC. I chose a dropdown because I realized will playing around with a lot of books that it really depends on the structure of the book how much you want to add to the TOC. (default is none)

Commit 755e0ee25c2e36ded292bb15884b1250cd0ea9b4: I added two hooks allowing theme author to define if numbers are added to headings, images and tables. 1. add_filter("pb_lists_add_numbers_to_list_elements", function(){return true;}); This hook turns on the adding of numbers and acronyms to images, tables and heading. By default it is not on, so all the current themes look just like they looked like before. If not activated lists and references are still working and headings are added to the TOC if selected.

2. add_filter("pb_lists_add_numbers_to_heading_levels", function(){return 3;}); The hook defines to how may levels of headings a number is added. By default it is 6. So h1 through h6 get a number added. If you change it for example to 3 only h1 through h3 get a number added.

Commit da2e81c39ed745e5f9b0eb4aed4619cb61cacda5: I added a filter option to the TOC List. By default all the headings are displayed that have an output in the TOC.

bdolor commented 10 years ago

Nice. I will make some time this week to test it.