"Watch What I Do" Chapter 14


Text Formatting by Demonstration

Brad A. Myers


We have developed a text formatter that combines the best features of what-you-see-is-what-you-get (WYSIWYG) text formatters, such as MacWrite and Microsoft Word, with batch-oriented, embedded-command formatters such as troff, TEX, and Scribe. Our formatter is WYSIWYG, but in addition, the user can define styles by demonstration using the regular user interface of the editor, to describe how various portions of the document should look. These are used for the same things as macros in embedded-command formatters. The users do not need to learn a complex programming language like those built into embedded-command formatters. However, they can still ensure that all parts of the document look consistent, and make it easy to edit the formatting of all parts at the same time.

For people who only want to follow a pre-defined style sheet, and therefore do not want to create their own styles, this editor should still be easier to use than conventional WYSIWYG editors, because demonstrational techniques make it easier to create tables, citations for bibliographic references, and to use the styles created by others.

Some word processors, such as Microsoft Word 4.0, provide a "styles" mechanism. The user selects a piece of text and gives the command "Define Styles..." This brings up a dialog box that shows all the properties of the selected text. The user can give a name to this set of formatting properties, and then apply them as a group to a different piece of text. However, this is too limited to solve the problem since a style only represents a single set of formatting commands. Figure 1 would require at least 3 styles which the user would have to create and maintain separately. (Another example is the chapter titles for this book.) Also, the styles mechanism cannot usually insert general text, such as the word "Chapter," so some other mechanism would have to be used if the user wanted to change it to "Section" in all the headings.

Figure 1. A chapter heading that includes different formatting for different parts and the constant word "Chapter."

Unlike most of the other systems in this book, the Text Formatting by Demonstration system does not create macros from a transcript of the user's actions. Instead, it looks at the final result (the example of the desired style), and infers the generalization from that. It is irrelevant what sequence of steps was used to create the example.

Furthermore, unlike systems such as Turvy (Chapter 11) and TELS (Chapter 8), this system contains significant knowledge about the typical formats used in documents. Whereas Turvy must be instructed how to find the author field in a bibliography by looking at the punctuation, the Text Formatting by Demonstration system has the concept of the author field built-in, and so it knows where to look for it. The use of this domain knowledge makes the inferencing in this system much more successful and more likely to be correct.

Nevertheless, the system does work by example, since it uses heuristics to infer generalizations from a formatted example of text. Therefore, the reader should not assume that all "by example" or "by demonstration" systems have to be based on macro recorders.


Uses and Users

Application domain: Word processor

Tasks within the domain: Text formatting

Intended Users: Non-programmers

User Interaction

How does the user create, execute and modify programs?
The user creates an example of the desired style and then directs Tourmaline to parse the style and apply it elsewhere.
Any instance of the style can be edited to modify the style.

Feedback about capabilities and inferences:
Inferences about tables are applied immediately, so the user can see if they are correct. The user can also view a textual explanation of each inference, as in Peridot. For styles, a dialog box shows the inferred classification of the parts of the document.


Works from a completed example of the desired style, not from a history trace of how the style was created.

Program constructs: Variables. Single parameter for headings.


Types and sources of information:
Knowledge about typical heading, table, and bibliography formats (e.g. how to locate the "author" field in a bibliography).


Machine, language, size, date:
Headings in WordBasic for Microsoft Word for Windows. Tables in Garnet. 1990 and 1992.

back to ... Table of Contents Watch What I Do