View Single Post
Old 05-08-2015, 07:48 PM   #9
odamizu
just an egg
odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.
 
odamizu's Avatar
 
Posts: 1,838
Karma: 8006102
Join Date: Mar 2015
Device: Kindle, iOS
Ummm ... okay ... aside from the fact that the <br/> and <span> within an <h1> makes for some pretty ugly code I think we're talking about different kinds of subheads.

This is my HTML/CSS:

Spoiler:

Code:
<h1>Chapter 1</h1>

<h2 class="subch">Subhead AAA</h2>
<p>text text text</p>
<p>text text text</p>

<h2 class="subch1">Subhead BBB</h2>
<p>text text text</p>
<p>text text text</p>

<h2 class="subch1">Subhead CCC</h2>
<p>text text text</p>
<p>text text text</p>

<h1>Chapter 2</h1>

<h2 class="subch">Subhead DDD</h2>
<p>text text text</p>
<p>text text text</p>

<h2 class="subch1">Subhead EEE</h2>
<p>text text text</p>
<p>text text text</p>

<h2 class="subch1">Subhead FFF</h2>
<p>text text text</p>
<p>text text text</p>
Code:
h1 { font-size: 150%; margin-top: 20%; margin-bottom: 1em; text-align: center; }
h2.subch { font-size: 120%; margin-top: 0; margin-bottom: 1em; text-align: center; }
h2.subch1 { font-size: 120%; margin-top: 2em; margin-bottom: 1em; text-align: center; }


Then I run it through Calibre with the following settings:
  • Structure Detection > Insert page breaks before: //*[name()='h1']
  • Table of Contents > Level 1 TOC //h:h1 Level 2 TOC //h:h2

With the above, Calibre inserts a pagebreak before each chapter but not before subheads and it creates a TOC structured like so:

Chapter 1
  • Subhead AAA
  • Subhead BBB
  • Subhead CCC

Chapter 2
  • Subhead DDD
  • Subhead EEE
  • Subhead FFF

I think it will take a lot more (ugly ) code to make the eschwartz method accomplish the same
odamizu is offline   Reply With Quote