Version 4 (modified by Douglas Clifton, 9 years ago) (diff)

Linked to source code on GitHub

Top of page Macro

Notice: This plugin is unmaintained and available for adoption.


TopMacro is exceedingly simple, like all good software ;-). In a nutshell, it does exactly what you think it would, inserts a "top of page" link in your Wiki page. The only option is a string that is inserted into the content of the markup. This defaults to a single circumflex "^" character (more commonly known as a caret), surrounded by square brackets. The anchor element returned includes a "Top of Page" title attribute so the user knows its purpose, and a "topofpage" class so the Wiki author may style it in any way they please.

[[Top]] becomes:

[<span class="topofpage"><a href="#" title="Top of page">^</a></span>]

You could of course achieve the same effect by doing this:

[<a href="#" title="Top of page">^</a>]

Resulting in this:


But who wants to do all that typing?

That's what macros are for after all. Note that the brackets do not form part of the anchor itself. That is a personal preference. If you pass a string to the macro they are omitted.


If you like the caret, but prefer to omit the brackets and style the link yourself with CSS, try this:

.topofpage {
  background-color: #eaeaea;
  color: #eff5f16;
  padding: 2px 4px 0;
  border: 1px solid #c6c7db;

Note that if you're going to style the anchor like this you should really pass an argument to the macro or you'll end up with the default brackets in addition to the styling.


Download the zipped source from here or clone the repository (see below) from GitHub to a location on your local drive. Unzip the archive to a temporary location, visit the 0.11 directory and run:

python bdist_egg
cp dist/*.egg /trac/env/Project/plugins


Enable the macro in:


top.* = enabled

You may need to restart your Web server.


[[Top(Top of page)]]


  • Browse the source at: GitHub
  • Public clone URL:
    git clone git://

Bugs/Feature Requests

Existing bugs and feature requests for TopMacro are here.

If you have any issues, create a new ticket.

Recent Changes

5040 by dwclifton on 2008-12-21 20:51:41
New hack TopMacro, created by dwclifton


Author: dwclifton
Contributors: The Python/Trac development community.

Attachments (1)

Download all attachments as: .zip