First, apologies for multiple posts. I'm not seeing my own posts, despite mailman preferences.
The best answer is to type the title correctly, since Title Case is not just capitalizing every word. It is actually complex. Rules from Gregg include:
(360) Capitalize all words with four or more letters. Also, capitalize all words with fewer than four letters, except articles, short conjunctions and short prepositions.
(361) (a) Capitalize the first and last word of a title; (b) capitalize the first word following a dash or colon; (c) capitalize short words in titles that serve as adverbs rather than prepositions; (d) capitalize short prepositions when used with prepositions of four-or-more letters (such as "Sailing Up and Down the St. Lawrence"); (e) do not capitalize word-wraped words.
There are other rules and gobs of exceptions. Algorithms can get close, however. Textmate has Text -> Convert -> to title case which does fairly well. I had hoped to find a way to use that function, since a program to get close is 10-15 lines of code.
I also wanted to learn how to use transforms, since I found the write up in the manual kind of obscure.
Thanks for your patience. Lewy
On 12/3/06, Brian Landau brianjlandau@gmail.com wrote:
Hey Lewis,
On 12/3/06, Lewis Overton akakie@gmail.com wrote:
I'm trying to learn about writing useful snippets for things I do often.
It
looks like I need some conceptual help. For example, I use this snippet:
<tr> <td><cite>${1:title}</cite></td> <td>${2:composer}<br /> arr:${3:arranger}</td> </tr> </table>$0
with a tab trigger of </table>
That worked so well I got greedy. I'd like to cause the snippet to force
the
title be Title Case.
Can't you just type it out in title case? Or you could use a class attribute on the td or cite tag and use CSS to style it with the text-transform property like this:
HTML code:
<td class="title"><cite>song title</cite></td>
CSS code: td.title { text-transform: capitalize; }
that would display the text to the browser like this: Song Title
Otherwise if the text is getting pasted in or something you could do a transformation on it, see: http://macromates.com/textmate/manual/snippets#transformations
Hope that helps!
-Brian
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate