0

I would like to use John Gruber's titlecase script (converts strings to titlecase with small-word exceptions).

My specific task is to search through multiple files and replace text strings within specific elements only (for example only h1's of a certain class name) with the titlecase.

For example, running titlecase on the following, everywhere it appears across files within multiple directories.

<div class="page-header"><h1>Replace me with appropriate title case, everywhere I appear</h1></div>

I can't figure out how to do this specifically. I was able to successfully use the javascript version of this script, and make the change onload in the browser, but I'd like to do it server-side so I can make the change permanently by actually writing the files.

Mojo::DOM looks useful, but I'm not sure exactly how to use it in this case.

user2387823
  • 141
  • 1
  • 5
  • 2
    I suggest you take a stab at it, and maybe show a diff of what you've tried. Will be much easier that way. But who knows, maybe you'll get lucky and someone will write this for you.. – chrsblck May 15 '13 at 23:20

1 Answers1

0

You have a good plan.

Get started on it.

  1. Write some code which parses out the H1s or whatever using Mojo::DOM.
  2. Write a title-izer which takes a file and a string to title-ize that outputs the title-ized content using something like the script you refer to (optionally overwrite the file...)
  3. Write something that puts this all together
OneSolitaryNoob
  • 5,423
  • 3
  • 25
  • 43