asterisk www.monkeyfood.com

/Software/Tagging Service

Tagging Service(v1.2)

Download Service:

About Services

Services are a very useful part of Mac OS X. You can find the Services Menu under the Application menu of any application (e.g. if you are using Safari, you can find the Services under the Safari Menu.)

Services act on the selected data of the active Application. Services can be part of another Application (e.g. OmniDictionary offers a service that will define the selected word) or they can be standalone Services (e.g. the Search Google service.)

There are two types of Services that a service provides: One takes data from the foremost application and works on that data (e.g. OmniDictionary's service described above.) - The other kind of service takes data from the foremost application, works on it, then replaces the data you selected with the result of the Service. The Tagging Service is an example of the latter.

About this service

TagService was designed to save time when coding HTML.

TagService will HTML tag the selected text. To determine what kind of tag to use the service searches for a colon - text before the colon is used as the Tag-Text.

Example: You select the phrase "em:Hello world" in TextEdit (or any other GUI-based text editor) then select the "Tag Text" Service from the Services Menu. The "Hello World" text would then become "<em>Hello World</em>".

The service has a keyboard short-cut of Command-Shift-\ (backslash) which is equivalent to Command-| (Pipe).
n.b. This shortcut will not work if other services have the same shortcut - or the application that you are trying to use it from uses the keyboard shortcut for itself.

Basically to tag some text - preceed it with the tag you wish and a colon - then select it all and press Command-Shift-/. So to tag an entire para of plain text, just add p: to the start and select it all then invoke the service.

Unusual Tags

img tags - if you choose img as the tag then the selected text will be used as the url for the src of the image.

e.g. img:foo becomes <img src="foo" alt="" />.

a tags - if you choose a as the tag then the selected text will be used as the text for a hyperlink.

e.g. a:foo becomes <a href="">foo</a>.

url tag - if you use url as the tag then the selected text will be used as the address for a hyperlink.

e.g. url:foo becomes <a href="foo"></a>.

Demo

If you'd like to see a practical example of what the service does: See a Demo Here.

Where to install the Service

The Service should be put in the following location: ~/Library/Services/

If you are the administrator of a multi-user machine and you wish every user to be able to access the Service, then you should put the service in the following location: /Library/Services/

A note about the Keyboard Shortcut

The Keyboard Shortcut is only available if the front application has not used that shortcut for itself. Panther's TextEdit and Safari are both examples of this. It has also come to my attention that certain keyboards lack the \ key.

If you wish to change the keyboard shortcut you can do the following:

  1. Locate the service bundle (TaggingService.service)
  2. Open the bundle (right-click the bundle and select "Show Package Contents" from the menu.)
  3. Open the folder named "Contents"
  4. Open the file named "info.plist" in a text editor (such as TextEdit)
  5. Search the following text: "<string>|</string>"
  6. Replace it the | character (between the string tags) with whatever you wish the new shortcut to be.
  7. Save the file and logout to see the changes.

n.b. you are only allowed one character for the shortcut - e.g. "2" is equivalent to Command-2 but "@" would be equivalent to Command-Shift-2


Changelog.

  • 1.2 - fixed bug where img tags would be closed with a \ instead of /.
  • 1.1 - removed console logging.
  • 1.0 - initial release.

This Service is freeware.

If the download is slow - use the mirror at my .mac page