Question

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.

No correct solution

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top