#### 28.2.4 Specifying link properties with macros

To include a macro in the href attribute of HTML links, assign the LinkSrc property to any paragraph formats that contain links you wish to modify:

    [HtmlStyles]
    ParaFmt = LinkSrc

To specify the macro code:

    [StyleLinkSrc]
    ParaFmt = code for the href attribute value

You can include macro variable <$$_linksrc> in the macro to insert the default content of the href attribute.

For example, suppose you want to use JavaScript for all links that occur in Body paragraphs, changing the links from the default format:

    <a href="destination">Some text</a>

to this format:

    <a href="javascript:LinkTo('destination');">Some text</a>

To make the links look like this in HTML output:

    [HtmlStyles]
    Body = LinkSrc

    [StyleLinkSrc]
    Body = javascript:LinkTo('<$$_linksrc>');

Macro variable <$$_linksrc> provides the original destination value for the href attribute. DITA2Go supplies the double quotes around the entire attribute value; do not include them in the macro definition. Any quote marks needed within the macro must be single quotes.

Macros are also helpful when you need more than one line of href attribute information, or when you want to use the same href attributes in many different configuration files. See §37. Working with macros.

Previous Topic: 28.2.3 Assigning link attributes with PI markers

Next Topic: 28.2.5 Replacing problem characters in links

Parent Topic: 28.2 Specifying link appearance

Sibling Topics:

28.2.1 Specifying link colors

28.2.2 Specifying link class

28.2.3 Assigning link attributes with PI markers

28.2.5 Replacing problem characters in links

28.2.6 Forcing link text to lowercase