For a general introduction to hooks, see their respective markup description. Named hooks are a less common type of hook that offer unique benefits. To produce one, instead of attaching a macro, attach a “nametag” to the front or back:
[This hook is named 'opener']<opener| |s2>[This hook is named 's2']
(Hook nametags are supposed to resemble triangular gift box nametags.)
A macro can refer to and alter the text content of a named hook by referring to the hook as if it were a variable.
To do this, write the hook's name as if it were a variable, but use the
? symbol in place of the
[Fie and fuggaboo!]<shout| (click: ?shout)[ (replace: ?shout)["Blast and damnation!"] ]
The above (click:) and (replace:) macros can remotely refer to and alter the hook using its name. This lets you, for instance, write a section of text full of tiny hooks, and then attach behaviour to them further in the passage:
Your [ballroom gown]<c1| is [bright red]<c2| with [silver streaks]<c3|, and covered in [moonstones]<c4|. (click: ?c1)[A hand-me-down from your great aunt.] (click: ?c2)[A garish shade, to your reckoning.] (click: ?c3)[Only their faint shine keeps them from being seen as grey.] (click: ?c4)[Dreadfully heavy, they weigh you down and make dancing arduous.]
As you can see, the top sentence remains mostly readable despite the fact that several words have (click:) behaviours assigned to them.
There are four special built-in hook names, ?Page, ?Passage, ?Sidebar and ?Link, which, in addition to selecting named hooks, also affect parts of the page that you can't normally style with macros. They can be styled using the (enchant:) macro.
?Pageselects the page element (to be precise, the
<tw-story>element) and using it with the (background:) macro lets you
change the background of the entire page.
?Passageaffects just the element that contains the current passage's text (to be precise, the
<tw-passage>element) and lets you,
?Sidebarselects the passage's sidebar containing undo/redo icons (
<tw-sidebar>). You can style it with styling macros, or use
?Linkselects all of the links (passage links, and those created by (link:) and other macros) in the passage.
(Note that, as mentioned above, if you use these names for your own hooks, such as by creating a named hook like
then they will, of course, be included in the selections of these names.)