Stretchtext: a hidden gem in real hypertext

Most of us see hypertext, and hypermedia more generally, centred on nodes of content which are linked together. That is all you get with the watered-down standard implementations in HTML and electronic books, of course, and their links are limited unless someone has added scripts to extend them. Storyspace (and its sibling Tinderbox) go much further, with other forms of links such as text links, and the use of guards.

Go back to Ted Nelson’s original visionary ideas of 1967 (expressed formally in 1974) to discover that he proposed a device which would allow inline expansion of content without the disruption of being linked out of context to a separate area.

To take a simple example, I here need to reference my previous tutorial on text substitution and stretchtext. I have done that with an embedded link, in that case (as the linked page is on this same website) one which will completely replace this page when you click on the link. Alternatively, if you click this link, that page will open in a new tab (or window).

Either way, this is disruptive to your original reading. To return to that you would have to select the tab containing this article, or click on the Back button in your browser. It is even fiddly to arrange the windows so that you can see both the linked content and its original context.

A lot of expanded content needs a device which is less disruptive, which reveals the linked content in a way which does not obscure or replace the original. In the forty-plus years since Nelson proposed stretchtext (or Stretchtext, or even StretchText), many different solutions have appeared. Popular at the moment are small floating windowlets, which are implemented for ‘tooltips’, for instance, in context-dependent help systems. Some text editors, such as BBEdit, can fold away sections of marked up text or code (a technique first implemented in a remarkable folding editor for the Transputer language occam in around 1986).

Stretchtext can also be implemented in JavaScript, as in Brad Neuberg’s Stretchtext.js, and illustrated in an extensive system on Ted Goranson’s blog.

Most theorists agree that stretchtext is an important hypertext feature with many valuable applications, but somehow it has never enjoyed much support.

The good news for those using Eastgate’s Storyspace 3 is that, not only does it support stretchtext, but its current implementation is feature-rich and almost complete; I will explain later its one current limitation, and how to work around that.


When to use stretchtext

Use it often, as often as you want the reader to be able to expand content to explain, supplement, and enhance.


It is ideal for providing a reader definitions, explanations, translations, and other relatively brief content which benefits from being shown within the original context. In printed form, most of these might usefully go into a footnote. Systematic inclusions such as references may be better tackled using a separate scheme, which also collates those references in a single place, something that stretchtext would not do as easily.


How you can use stretchtext in Storyspace 3

If you have not used it before, my previous tutorial takes you through a simple, and artificial, example. The method used there for constructing the code to elicit stretchtext is pedagogic: you first insert the anchor text and make it into a text link to the content which will be inserted, then surround that anchor text with the code to transform it into stretchtext. It has the disadvantage that it can, occasionally, capture a bit more in the text anchor than you intend, but is valuable when you need the simplicity of the text link to visualise or debug the link. Once the code is complete, you can delete the text link in the Map view if you wish: stretchtext does not need it.

The direct alternative is to type in the complete stretchtext code. Assuming that you get it correct, this should work straightaway, and you do not need to make any text link, although you can if you wish.

Leaving a text link in the anchor text of stretchtext has one disadvantage: there can be a small area around the anchor text which will still trigger the link rather than the stretchtext. This appears most probable once the stretchtext insertion has occurred, and before any other stretchtext has been inserted.

Inserted stretchtext will not bring with it any text links which might appear in the original copy of the inserted content. However it does preserve stretchtext and other text substitutions, so you can – as Ted Nelson and others originally envisaged – nest stretchtext. I would expect that there is a code limit to the depth of nesting, and there certainly must be a cerebral limit in most readers, but stretchtext works very well indeed using two or three levels of nesting.


Stretchtext also brings with it any non-text content from the linked writing space, such as embedded images.


Current limitation

The only problem that I have encountered in using stretchtext in Storyspace version 3.2 is that there is no simple means to unstretch, that is to return the writing space back to its original state without the inserted stretchtext. At present the reader must deselect the writing space and select it again, in order to reload its content.


A straightforward workaround is to provide a text link to a writing space which uses a shark link to return to the original immediately. If that shark link has no guard, it will always be followed, and by transiting invisibly through it, all the exposed stretchtext will be cleared instantly. This doesn’t always happen if you use nested stretchtext and more than one top level of stretchtext is open. I am not sure why that is, and cannot find a solution other than resorting to deselecting the writing space and selecting it again, in the Map view.

As ever, I provide my example Storyspace document for you to explore, here: StretchtextDemo1
This works with both licensed Storyspace and Storyspace Reader; the latter comes with another example file here: falloficarus

Happy hypertexting!



Landow GP (2006) Hypertext 3.0, Critical Theory and New Media in an Era of Globalization, Johns Hopkins UP. ISBN 978 0 8018 8257 9.

Many thanks to Mark Anderson for providing links, information, and guidance (as ever).