Copyright ©2001-2007 by OCSoftware. All Rights Reserved.

URL Links in RTF(D) Texts

Overview

The RTF and RTFD formats of Mac OS X, used e.g., in TextEdit and in a number of other places, support a number of luxurious services. Some of them are not available through the current graphical user interface. One of them – at least for Panther – is the URL Link support: the formatted text can contain URL links, just like a HTML document: here's an example, a link to the OCSoftware site. The standard text system used in most Cocoa applications would understand them and resolve the URL properly if the link is clicked; it is though not possible to enter the link (save for the possibility to copy&paste it from a Web browser).

OCSmart Hacks add the possibility to mark a text as a URL link into any application, which uses the standard text object with a formatted text and allows the user to edit it.

User Interface

Find the command "Set Link..." in the menu: in TextEdit or similar application it would be at the very bottom of the "Format" menu; in other applications it may be moved into the "Edit" or "Font" menu, or even placed in an "OCSmart Hacks" menu by itself–it depends on what formatting commands and menu the application has:

Select the command; a link sheet is displayed for the current selection:

If the sheet does not display and the command just beeps, the text object in the active window is not suitable for making links (e.g., not editable, or containing plain ASCII text only).

The sheet contains a copy of the selected text, or a text "Link", in case there is no selection. If the latter, the text "Link" is editable, and whatever you enter instead of it will be inserted at the cursor position. Into the main text field you can enter any URL, which will become the link's target.

It seems the Mac OS X text system tries to be clever, and adds the "http://" prefix to any URL which does not contain a colon; that though makes entering relative links somewhat problematic. OCSmart Hacks therefore check for a "local:" prefix (no slashes), and if it is in the URL, it is removed. To enter link to a Whatever.html in the same folder as the current document therefore use "local:Whatever.html": the link will not work in TextEdit or other Cocoa application, but it will work properly in the generated HTML.

To remove an URL from link (turning it so into a normal text) just move the cursor into it (preferrably using arrows, for clicking on the link would open the URL), and select the "Set Link..." command. In the sheet delete the URL and click OK.

The standard text system does not well support the URL attribute at the edge of the text: normally, it is pretty difficult to enter a plain text before a link at the very beginning, or after a link at the very end. Since that, OCSmart Hacks support two special tricks: you can enter the "<" or ">" characters into the Link Sheet textfield to move the insertion point before or after the link.

So, to add a plain text before a link on which you happen to have the insertion point, just open the Link Sheet, enter "<" into the textfield, and press the "OK" button. The link will not change, but the insertion point will be moved before it. Similarly, to add a plain text after a link do the same with ">".

Customization

It is possible to customize the keyboard alternative for the "Set Link..." command. Open the OCSmart Hacks window selecting the "OCSmart Hacks..." item from the application menu, and choose its "HTML" tab. The appropriate widgets are placed in the top:

You can disable both the HTML extensions ("Set Link...", described here, and "Save As HTML...", described in a separate Help page), using the checkboxes at the very top. Like it is with tear-off menus, the first checkbox disables HTML extensions in all applications, the second one in the current application only. To see the change you again need to quit and re-launch the application.

The widgets below the checkboxes allow to set up the "Set Link..." keyboard alternative: enter the letter into the text field, and switch on the radio buttons for the desired modifiers. Note that the

modifier is mandatory, and also that the modifier is linked into the letter case: uppercase always means , whilst lowercase always means no . Again, the change will apply after the application is terminated and launched again.