-# Here's the javascript that makes this possible. A key feature is the use
-# of css to hide toggleables, to avoid any flashing on page load. The css
-# is only emitted after the javascript tests that it's going to be able to
-# show the toggleables.
-my $javascript=<<'EOF';
-<script type="text/javascript">
-<!--
-if (document.getElementById && document.getElementsByTagName && document.createTextNode) {
- document.write('<style type="text/css">div.toggleable { display: none; }</style>');
- window.onload = inittoggle;
+sub import {
+ add_underlay("javascript");
+ hook(type => "getsetup", id => "toggle", call => \&getsetup);
+ hook(type => "preprocess", id => "toggle",
+ call => \&preprocess_toggle);
+ hook(type => "preprocess", id => "toggleable",
+ call => \&preprocess_toggleable);
+ hook(type => "format", id => "toggle", call => \&format);