Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-05-05 09:01:32

Ian Goldby
Archived Plugin Author
Registered: 2007-09-16
Posts: 6

img_rebase_headings

This plugin is useful if you want to ensure that the headings marked up with Textile inside an article body are all subheadings of the article title.

For example, your template might define the article title as an <h3> heading. If the author of the article used Textile h1. or h2. headings, these would then break the hierarchy of heading levels. Presumably you would want the first subheading in the article body to be h4. so that it is a proper subheading of the article title <h3>.

img_rebase_headings looks to see what is the top-level heading used in the article and adjusts all of the headings and subheadings found so that the top-level heading used matches the desired base level.

Download

img_rebase_headings

Example

<txp:img_rebase_headings base="4"><txp:body /></txp:img_rebase_headings>

Attributes

Required

  • base: the highest-level heading (i.e. lowest numbered) that you want inside the wrapped text.

Comments

  1. XHTML supports heading levels 1 to 6. img_rebase_headings will not renumber any heading to be above 6. One consequence of this is that more than one level might be converted to <h6>.
  2. img_rebase_headings assumes valid XHTML and does not replace heading tags if they are in uppercase.

——
I’ve been using it for a while now and I don’t have plans to develop it any further, except to fix any problems that might be found. However all comments are very welcome.

Offline

#2 2008-05-05 10:41:29

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: img_rebase_headings

Nice!
I like little neat things.

Thank you!


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#3 2008-05-05 10:43:31

lee
Member
From: Normandy, France
Registered: 2004-06-17
Posts: 831

Re: img_rebase_headings

Very cute.

Offline

#4 2008-06-04 04:37:36

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: img_rebase_headings

Nice little one! Thanks!

Particularly useful when someone forgot to write the proper excerpt (and when you are obsesed with every heading being the right level…)
An example:

<txp:if_article_list>
    <txp:if_excerpt>
        <txp:excerpt />
        <p class="read-more"><txp:permlink>Read more →</txp:permlink></p>
    <txp:else />
        <txp:img_rebase_headings base="4"><txp:body /></txp:img_rebase_headings>
    </txp:if_excerpt>
<txp:else />
    <txp:body />
</txp:if_article_list>

La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB