Incrementing/Decrementing HTML Headers

We're in the process of migrating sites between Drupal 6 and D7 and that's also involved some theming work. One of the changes in our theme is the main site title has been changed from H1 to a div, the page title from H2 to H1, and content headings from H3 to H2. This means any H3's in the old site now need to be H2's, H4 -> H3, and so on.

Luckily, we have regex to the rescue. All I need to do is find:

<h3 ([^<>]+)>([^<>]+)<\/h3>

and replace with

<h2 \1>\2</h2>

either in the import process or using the handy Search and Replace Scanner module, then rinse and repeat with and further headings. 

Add new comment

Sign in with your CNETID and password to post a comment, or submit your comment using the form below.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.