Tinderbox Forum

Adjusting Hx Tagging in Template

Let’s say I have the following structure:

A Container
…It has a child
…/…the child has child

I want the container to be .title sytle, the first child to be H1 and the second child to be h2, and so on.

For HTML CSS tagging purposes, I would like the parent container to use a title style e.g. .ttile, the children to be H1 and the descendant to be H2, e.g.

Is this possible. What would I need to do to the template or the note attributes to make this happen?

Tinderbox compares the font size of a paragraph to the standard text font size.

If the difference is more than 6 points, we use H1.
If the difference is 4-5 points, we use H2.
If the difference is 1-3 points, we use H3.
Otherwise, we use paragraph markup.

I see, but how will this help me? Do I need to change the font size for all the titles of the notes? Is there not a way to do this through export or action code?

I tried this, but it is not working:

<h2>^title^</h2>
^text^^if($ChildCount>0)^<h3>^title^</h3>^text^^endif^
^children(/Templates/tPGIDTrial/tPGIDTrial item)^

I’m getting duplicates.

My issues is that the template is setting the root container to H1, where as I’d like the top container to be .title, the first layer of children h1 and, then h2, and h3. and so on.

Remember, we can’t always know exactly what you have in mind?

I’m getting duplicates.

<h2>^title^</h2>
^text^^if($ChildCount>0)^<h3>^title^</h3>^text^^endif^
^children(/Templates/tPGIDTrial/tPGIDTrial item)^

This exports the title, then the text. Then if you have children, it exports the title of this note as an h3, then exports each child.

1 Like

Yup, that’s what I figured out. :slight_smile: I’ll keep trying.

You want to include the child’s <h3>^title^</h3> in the child template.

What you might do in this case is test $OutlineDepth

^if($OutlineDepth==2)<h2>^endif
^if($OutlineDepth==3)<h3>^endif
^if($OutlineDepth> 3)<h4>^endif

OMG!!! For my own self-respect, you could have made the answer harder, no? :wink: Just kdding.

It is so obvious now that I see the solution. I LOVE TINDERBOX!!! Thank you. :pray: :pray: :pray: :pray: Very grateful!

Worked perfectly!!! Took about 30 seconds to implement and test.

For those that are interested, here are my two templates.

Template 1

<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8">
	<title>^title^</title>

     <style type="text/css">
	   h1 {font-family: open sans; color: #202020;}
       h2 {font-family: open sans; color: #0077c0;}
       h3 {font-family: open sans; color: #202020; text-decoration: underline;}
   </style>

</head>
<body>
<!--   ** Standard Tinderbox Template [section page] **  -->


<h1>^title^</h1>
^text^
^children(/Templates/tCSSPage/tCSSPage item)^
</body>
</html>

Template 2

^if($OutlineDepth==2)<h1>^title^</h1>^text^^endif^
^if($OutlineDepth==3)<h1>^title^</h1>^text^^endif^
^if($OutlineDepth==4)<h2>^title^</h2>^text^^endif^
^if($OutlineDepth==5)<h3>^title^</h3>^text^^endif^

^children(/Templates/tCSSPage/tCSSPage item)^

Sample file attached: TBX - L CSS Style Sheet and Outline Depth.tbx (145.6 KB)

Extra credit point: if your source containers differ in level you can always calculate the difference in relative $OutlineDepth to get to the same graduated heading result.