Published by SoftQuad Inc. 56 Aberfoyle Crescent Suite 810 Toronto, Canada M8X 2W4 Telephone: (416) 239-4801 Fax: (416) 239-7105 e-mail: hotmetal@sq.com Document version SoftQuad HoTMetaL First Edition (June 1994) SoftQuad Inc. makes no warranty of any kind with respect to the completeness or accuracy of this book. SoftQuad may make improvements and/or changes to the product(s) and/or programs described in this book at any time and without notice. Trademarks and copyrights Copyright 1994 SoftQuad Inc. All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means--electronic, mechanical, recording, or otherwise--without the prior written consent of the publisher, excepting brief quotes used in connection with reviews written specifically for inclusion in a magazine or newspaper. SoftQuad HoTMetaL is a trademark of SoftQuad Inc. Windows is a trademark of Microsoft Corporation Notice Agencies of the United States Government please note: RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 52.227-7013 and in similar clauses in the FAR and NASA FAR Supplement. 1. Getting started This chapter tells you how to start up HoTMetaL and gives the basic information you need to get going with creating and editing files. If you are new to HoTMetaL or to SGML, you should certainly read this section, as it will help you get acquainted with the product and learn about the components and procedures you'll need to get your work done. 1.1. Purpose HoTMetaL is an editor for creating files that can be read by graphical browsers (such as Mosaic) that are connected to the World Wide Web (WWW). The file format for such files is called HTML. The HTML format is actually a type of file format defined using the Standard Generalized Markup Language (SGML). In other words, all HTML files are SGML files (the converse is not true, however--there are many other file formats described by SGML, so most SGML files are not in HTML format.) You can see what the HTML format looks like by invoking the View Source... command in Mosaic's File menu. HoTMetaL provides an easy-to-use, graphical, structured editor for creating files in this format. 1.2. Text and markup Like most electronic documents, an HTML file consists of text and markup. (Markup is special codes inside the file that indicate how part of the file is to be processed: for example, a word-processor file would contain markup indicating typographical features such as the font and font size for various parts of the document.) In an HTML file the markup consists primarily of elements. Elements normally consist of a start-tag that is placed at the beginning of a section of the text, and an end-tag that is placed at the end of that section of text. In HoTMetaL, when you insert an element in the document, you are actually positioning its start- and end-tags. When you want words and phrases to be considered distinct elements, you surround them with tags. For example, a title in an HTML file would look like this: This is a title! (As you will see, when you are editing documents with HoTMetaL, you don't have to deal with tags on this level: for example, the start- and end-tags are represented on the screen by icons so that you don't have to type them literally, and HoTMetaL will insert both tags for you when you select a portion of the text to be surrounded by an element.) When you are marking up a document in HTML format, you mark up parts of the document according to their function in the structure of the document. For example, there are different elements for divisions, headings, lists, list items, paragraphs, titles, and many other parts of a document's structure. It is important to realize that HTML markup is not primarily intended to indicate how the document is formatted typographically, it is meant to describe the document's structure. One of the reasons for using HTML (and SGML) is that the files can be readily re-processed in a different format by other publishing, browsing, database, etc., applications. In addition to describing the structure of a document, some elements also describe the links to other documents that are found in an HTML document. HTML documents are structured documents, that is, the elements must be arranged according to specific rules: otherwise, the document is considered invalid. When you are using HoTMetaL, you don't have to keep track of these rules yourself--HoTMetaL does it for you. One of HoTMetaL's most important features is automatic rules checking, which ensures that you do not violate the required structure as you are creating a document. As well, when you open or save a document, HoTMetaL checks that the markup is correct and complete. Many HTML browsers have permitted a very loose, unstructured document format. Therefore, if you are editing existing HTML files, you may find that the structure that HoTMetaL imposes on documents is somewhat constraining. If you need to, you can relax these constraints using the Turn Rules Checking Off command in HoTMetaL's Markup menu. Because there is an emerging trend toward browsers that require a stricter document structure, we believe that you will find it to your advantage to create all your new HTML documents with HoTMetaL's default rules in force. It will also be worthwhile to modify existing documents to conform to these rules. When you open a document, HoTMetaL will automatically turn off the rules checking if the document does not conform. If you click on Turn Rules Checking On in the Markup menu, you will get an error message describing the first error found in the file, and the insertion cursor will move to the location of the error. After the error has been corrected, you can repeat this procedure until all the errors have been removed. To receive a rules file which is flexible enough to accept almost any HTML file, send e-mail to the following address: loose-dtd-request@sq.com 1.2.1. Inserting markup The most common operations you will carry out in order to add or change markup are: -- The Insert Element... command in the Markup menu inserts a new, empty element in which you can type text or insert other elements. -- The Surround... command in the Markup menu lets you surround a selection with an element: if some part of the document should be contained in a particular element, then you can highlight that portion and select this command to choose an element to surround it with. -- The Change... command in the Markup menu lets you change the markup: if you want to tag part of the document with a different element you can select this command to get a list of valid elements to replace it. -- Deleting markup: if you want to remove an element without deleting its contents, you should do the following: + Highlight the contents. + Invoke Copy or Cut from the Edit menu. + Highlight the element (including the start- and end-tags) + Press the Backspace key. This will delete the element. + Invoke Paste from the Edit. This will restore the contents of the element. 1.2.2. Special characters If you type the characters `<' or `&' (both of which are special characters in SGML files) they will be replaced by small rectangular icons: lt and amp, respectively. 1.2.3. Rules files The rules that determine how elements can be arranged in an SGML file are described by a set of declarations collectively known as a document type declaration, or DTD. HTML files are no exception to this. HoTMetaL reads a DTD in a special, binary form called a rules files which contains the same information as the DTD but in a different format, one which is more efficient for HoTMetaL to read. It is not necessary for you to know more details about DTDs and rules files. You just need to be aware that HoTMetaL uses a rules file called html.mtl: this file is located in a directory called rules in the HoTMetaL directory. Normally there will be no need for you to move this file; if for some reason you do, the new location of the rules file must be specified using the rules_path configuration variable--otherwise HoTMetaL will not be able to find it. For example: rules_path=c:\wendy\rules See the chapter The configuration mechanism for more information on configuration files. If you are interested in seeing the DTD for HTML files, look at the file html.dtd in the dtds directory underneath the HoTMetaL directory. 1.3. The configuration mechanism HoTMetaL's configuration mechanism allows you to modify certain aspects of HoTMetaL's behavior: find and save options, location of auxiliary files and directories, etc. HoTMetaL reads parameters called configuration variables from two configuration files: these are the file sqhm.ini in the HoTMetaL installation directory, and the file sqhm.ini in the Microsoft Windows directory (usually this is the c:\windows directory. Specific configuration variables are discussed in various locations throughout this manual. For full details, see the chapter The configuration mechanism. 1.4. Links It is normal for HTML documents to contain links to other documents, which can be located anywhere on the WWW. These links are provided by Universal Resource Locators (URLs), which are identifiers that name the location and filename of a document, and the protocol used to access it. There are a number of elements available to you whose function it is to contain URLs: one such element is called "A" (you may think of this name as standing for "Anchor"). Rather than typing in the URL between the tags as text, you edit something called an attribute of the element: this is a piece of information attached to an element. HoTMetaL has three commands for working with URLs: -- Publish... in the File menu is used if you want to change the URLs in the document from identifiers that refer to files on your local system to identifiers that refer to publicly-available files on one or more WWW servers. -- Show Link and Context View in the View menu is used to display the URL (if there is one) in the current element. -- Edit Attributes and Links... in the Markup menu is used to edit the URL (if there is one) in the current element. More information on each of these commands may be found in that chapters on their respective menus. 1.5. Screen formatting HoTMetaL provides screen-formatting capabilities which facilitate the document creation process by allowing you to assign distinctive styles to the elements in your document. This formatting is in effect only while you are editing the file in HoTMetaL. Another application may (in fact, almost certainly will) format the document differently. Because SGML files are structured documents, setting a style for an element means setting it for all elements of that type. The following kinds of typographical properties can be set: -- Character-based properties: font family, font size, font style, line height, justification, fill mode, and format type. All of these properties are set using the Character... command. (Font style allows you to adjust the font by making it bold, superscript, etc.; the fill mode determines how carriage returns are treated--in fill mode, they are treated like spaces, but in no fill mode they cause a line break; format type lets you choose whether an element appears inline or starts on a new line.) -- Separation: using the Separation... command, you can set off elements by adding space on top and on bottom. This command also lets you cause an element to be formatted as if it started with a tab. 1.5.1. Displaying icons Using the Show/Hide Tags command in the View menu, you can cause the special character icons and the tag icons that represent elements to be visible or invisible. 1.5.2. Displaying a document outline The command Show Structure View in the View menu displays a nested outline view of the document. You can cut, copy, paste, and navigate in this outline. For more information, see this command's documentation in the chapter The View Menu. 1.5.3. New lines Although pressing the Return or Enter will put a "new line" into the file, Mosaic and other browsers follow the SGML whitespace rules, and therefore will ignore new line characters in some circumstances. 1.6. An overview of the menus This section provides a summary of the main features. n File menu: file manipulation, e.g., opening and closing files n Edit menu: cutting and pasting; finding and replacing strings and patterns n View menu: screen formatting; displaying different views of the document structure. n Markup menu: inserting and changing markup; checking document conformance n Help menu: on-line help. 1.7. How to run HoTMetaL The usual way to run HoTMetaL is by double-clicking on the icon labeled HoTMetaL in the HoTMetaL Program Group. If this group has not been created, you should create it, as explained below. The icon must have a command line associated with it. You can check the command line associated with this icon by using the Properties... command in the Windows File menu. You may also change the HoTMetaL command line by using the Properties... command. You may create a new program group using the New... command in the Windows File menu, then add HoTMetaL to that group (also using the New... command). Alternatively, you could add HoTMetaL to an existing program group. When adding HoTMetaL to a group, associate it with a command line like c:\hotmetal\sqhm.exe as appropriate. An icon will be provided for you by HoTMetaL. Two other ways you can launch HoTMetaL from within a Windows session are: -- Using the File Manager, move to the directory where you installed HoTMetaL. Now double-click on the file sqhm.exe -- Use the Run... command in the Windows Program Manager with an explicit command line such as: c:\hotmetal\sqhm.exe You can also start HoTMetaL from the DOS prompt at the same time as you start up Windows. To start HoTMetaL from the prompt, type the following: win ae For this to work, the location of the HoTMetaL binary ( sqhm.exe) must be in your PATH, normally set in the AUTOEXEC.BAT file. 1.8. Creating and editing files This section gives the basic information needed to start editing files with HoTMetaL. 1.8.1. Creating a new file HoTMetaL comes up with a new, empty HTML document ready for you to use. You can also create a new file as follows: + Click on the New... command in the File menu. HoTMetaL brings up a new, empty file. 1.8.2. Editing an existing HTML file If you already have an HTML file that you want to edit: + Click on the Open... command in the File menu. + In the dialog box that appears, choose the file that you want to edit. Once you've done this, HoTMetaL opens the file and you can begin editing. 2. The File menu The File menu contains commands for creating, opening, closing, saving, and publishing files edited with HoTMetaL. It also contains commands for importing and exporting documents so that they can be used by other publishing and database software. 2.1. New... Creates a new, empty HoTMetaL file. 2.2. Open... Opens a previously saved file. HoTMetaL presents you with a dialog box allowing you to select a rules file. The dialog box is called a file selection dialog; a similar dialog box appears when you select the Save As... command.The structure and function of the file selection dialog for the Open... command is explained here. The dialog box has several parts: -- A drop-down list box labeled List Files of Type. This list box lets you choose whether to display files with the default file extension (usually .htm) or display all files in the current directory. -- a text box labeled File NameThis text box can contain a relative or absolute path name, which terminates in a file name or directory name, and can optionally start with a drive name. A file name (which may contain an extension) can contain the following "wildcard" (special) characters: -- * (asterisk): matches any sequence of characters in a file name -- ? (question mark): matches any single character in a file name Such a pattern containing wildcard characters is used to filter the file names displayed in the list box directly below. If the File Name box contains a path name terminating with a directory name, then all file names in that directory are displayed and the pattern becomes `*.*'. The default pattern in this dialog box is `*.htm'. You can type a pattern in the box directly or choose it from the List Files of Type list. If the File Name box contains a path name that ends in a file name without wildcard characters, clicking on OK will cause that file to be chosen as the rules file for the new file being created. Note: If you want to change the default file extension for this dialog box, you must set the new default extension with the `import_ext' configuration variable. -- an information field labeled Directories The current directory (including the drive name) appears underneath the label. The default directory is the one specified first by the import_path configuration variable. -- a list box underneath the File Name text box This list contains the files in the current directory that match the pattern in the File Name box. The list of files is updated whenever a new directory is chosen, and when you click on the OK button Clicking once on a file in this list causes the name to go in the File Name box. Double-clicking causes the file to be opened. This has the same effect as clicking once on the file name and then clicking on the OK button. -- a list box, on the right side of the dialog, underneath the Directories information fieldThis box allows you to navigate in the directory structure of a drive by double-clicking on the directories shown in the list. The top level "directory" displayed is the current drive; if you double-click on this directory, its subdirectories are displayed, slightly indented to indicate the nesting relationship. If you click on one of these directories, its subdirectories will be displayed, and so forth. At any particular time the list will display the sequence of directories that you have navigated along, ending with the subdirectories of the last directory you selected. -- A drop-down list box labeled Drives. This allows you to choose which drive to navigate. By pressing Tab or Shift-Tab you can make the File Name box, the list of directories, the list of files, or either of the buttons the active item in the dialog box. When either of the lists is active, you can select a list item by pressing repeatedly on the first letter of the item until it is selected. When the File Name box is active, you can enter text in it. In summary: you may select a directory from which a file may be opened by using the list of directories, or by typing the path name in the File Name text box. You may choose a file by doing one of the following: -- double-clicking in the list of files -- selecting a file in the list of files and then clicking on OK -- entering the file name in the File Name text box and clicking on OK If the file you selected is already open, you will receive a warning message informing you of this, and the file will become the current document. Note: In this window, the default directory is the one specified first with the `import_path' configuration variable. The default extension for a file to be opened is specified with the `import_ext' configuration variable. 2.2.1. Locating the rules file There will sometimes be a document type declaration (DOCTYPE) at the top of an SGML file, specifying which rules file to use. This declaration is not mandatory with files being opened with HoTMetaL, because all HTML files use the HTML rules file. In fact, if the DOCTYPE declaration is missing, or is present but does not specify the HTML rules file, HoTMetaL will use the HTML rules file in the default location. If the DOCTYPE points to the HTML rules file in another location, that file will be used. 2.2.2. Error checking As the file is being opened, HoTMetaL checks for fatal SGMLerrors. Fatal errors include start-tags without end-tags and vice versa, element names that do not exist in the rules file, and many other SGML errors. In such cases, HoTMetaL displays a message describing the problem and then opens the text file so that you can correct the errors. If no errors are found, the file is formatted, checked once more for errors as if the Turn Rules Checking On command in the Markup menu had been selected for the new file. At this stage, non-fatal errors--SGML errors may be detected. Examples of these are incorrectly placed elements, and text at a point where no text is permitted. Errors of this kind do not prevent the file from being opened. Finally the file is validated: this stage of error checking ensures that the SGML markup is correct and complete. This example illustrates the difference between rules checking and validation: if you open a file which has an HTML element that does not contain an FRONT element, rules checking will not complain, because you have not yet violated the rules file. Validation, however, will alert you to the fact that the required FRONT element is missing. 2.3. Open Template... This command allows you to work with templates, which are pre-defined structures for documents. Templates are used as forms or document outlines that you can enter text into without having to insert any of the markup yourself. 2.3.1. Opening a template To open a template, click on the Open Template... command. This brings up a file selection dialog box labeled Open Template. If you have a templates directory (see below) the dialog box will display the all files from that directory. Each file corresponds to a template: to open a template, just open it as you would any other file. The document name in the title bar will be the same as the template name, but with a number added to the first part of the filename: for example, the first time you open a template called fax.htm, the document will be called fax1.htm, the second time the document will be calledfax2.htm, and so forth. When the template file is opened you can enter text or elements into it, and later save the file. When you save the file, you will have to choose a file name--the name in the title bar is not automatically adopted. If you save this file in the templates directory, make sure you do not overwrite the original template file. 2.3.2. Creating your own templates A number of templates are shipped with HoTMetaL, but it is expected that you will normally be working with templates that were created at your own site. 2.3.2.1. Templates directory In order to work with templates successfully, a directory must be designated as the templates directory. This is a central location containing all of your template files, and it is the directory whose files are displayed when the Open Templates... dialog box comes up. By default, this is the directory called tmplts in the directory where HoTMetaL is installed. If you want to use another directory for this purpose, you will have to name that directory using the templates_path configuration variable. For example: templates_path=c:\susan\tmplts If the default templates directory does not exist (someone has removed it), and no alternative directory is specified with the templates_path variable, the current directory will be used as the templatesdirectory. 2.3.2.2. Creating templates To create a template file with HoTMetaL, you should do the following: + Create a document as you normally would. + Invoke the Save As... command in the File menu. + Choose a directory and filename. You can save the file directly in the templates directory, or move it there later. + Click on the Save As button. 2.3.2.3. Installing a template When the template file has been created, it should be saved in the templates directory (or you can save it elsewhere and move it later) so that it will be easily accessible from the Open Template dialog box. 2.4. Save Saves the current file (that is, the file that is opened in the to disk. HoTMetaL saves the document in the file name shown in the title bar at the top of the window. You will be given a file selection dialog box in which to provide a name for the new file being created. Note: The default directory is the first directory that is specified by the `export_path' configuration variable. 2.4.1. Save options There are several save options that you may set by way of configuration variables, if you need to do so: -- You may choose to save a document type declaration (DOCTYPE), at the top of the file. The default may be set using the export_doc_type_dec configuration variable. -- If your file contains special characters (those outside the ASCII range 0-127), you may choose to have these converted to SGML character references. The default setting for this option (ON or OFF) may be set with the export_convert_special_chars configuration variable. -- You can choose the character(s) that HoTMetaL uses to mark the end of a line in the saved file. You may choose one of the values MAC, UNIX, and MSDOS, which will cause the end-of-line character to be carriage return , line feed, or carriage return and line feed, respectively The default end-of-line marker can be set with the export_eol configuration variable. If you don't provide a value for this variable, the default will be UNIX. -- For elements that are formatted in fill mode (see the documentation on the Characters... menu item) you can set the length of lines in the saved file by telling HoTMetaL to insert end-of-line characters after a specified number of characters. This option can be turned on or off by default with the export_add_line_breaks configuration variable..The number of characters in a line can be set with the export_max_line_len configuration variable. HoTMetaL will not cause a line break in the saved file to occur between an element and adjoining text. The file will be validated prior to saving, and you will be notified of any errors that are detected. If you have rules checking turned on, such errors will prevent the file from being saved. If rules checking is turned off, a file with errors may be saved. 2.5. Save As... Creates a new file whose content is the same as the current file, and closes the current file leaving the new file open. HoTMetaL gives you the file selection dialog box with which to specify the name of the new file. You should follow the same instructions for selecting a file or directory as were described in the section on the Open... command. Note: In this window, the default directory is the one specified first by the `export_path' configuration variable.The default extension for a file to be opened is specified by the `export_ext' configuration variable. Note that any changes made to the original file since it was last saved will not appear in that file after the Save As... command is used (although they will, of course, be saved in the newly created file). The save options that were specified for Save will also apply to Save As. 2.6. Close File This command closes the current file. If the file has had changes made to it since it was last saved, you will be prompted to save the changes before closing it. 2.7. Preview When you invoke this command it will save the current document to a temporary file and then launch Mosaic to display the file. 2.8. Publish... Before a completed HTML document is moved to the server, all URLs should refer to documents that are available on some WWW server. (While the document is being created, they may refer to documents on your local system.) The Publish... command gives you the opportunity to edit all the URLs, modifying them if necessary. When you invoke this command you will get a dialog box containing two text boxes. The first box (labeled Change From) contains a part of the URL that you want to change; the second box (labeled Change To) contains the string that you want to change it to. The default values in these two boxes are specified by two configuration variables: publish_change_from specifies the part of the URL that should be changed; publish_change_to specifies the new value for this part of the URL. For example, when you are creating a document the URLs may consist of local filenames such as: file:///c|/rodney/orwell/homage.htm When the document is placed on your server, you must substitute URLs that refer to documents that are available on your server or some other server. For example: http://sqrex.sq.com/sqmosaic/orwell/homage.htm If there were a large number of URLs for which you needed to change a local directory such as file:///c|/rodneyto a a string such as http://sqrex.sq.com/sqmosaic, you could set your configuration variables as follows: publish_change_from=file:///c|/rodney publish_change_to=http://sqrex.sq.com/sqmosaic This would cause the Change From text box to contain "file:///c|/rodney" and the Change Totext box to contain "http://sqrex.sq.com/sqmosaic". 2.8.1. Finding and Replacing URLs When you click on the Find button, HoTMetaL finds the next element that has an HREF attribute (this attribute represents a URL). The search starts at the insertion point (or selection) and wraps around to the top of the document if necessary. When an element with an HREF is found, the insertion point is placed inside that element, and the document scrolls to its location. The field labeled URL at the top of the dialog box will display the value of the HREF (this field is not editable). If the URL contains the text in the Change From box, clicking on the Replace button will change it to the text in the Change To box. The URL field will be updated to reflect the change. Clicking on the Replace All button will make this change for all URLs in the document that contain the Change From text. A field at the bottom of the dialog box will indicate how many changes were made. You can edit the Change From and Change To text if you want to perform substitutions other than the default one. 2.9. Exit Quits HoTMetaL. If an open file has been changed since the last time it was saved, you will be prompted to save the file before exiting. 3. The Edit menu The Edit menu contains commands to do the basic editing: cut, copy, and paste a selection, undo your last action, and perform find and replace operations. Commands in this menu make extensive use of the clipboard. The clipboard is an area that holds parts of a document that have been cut or copied. It may contain markup. The clipboard may be used to transfer information between documents as well as within a document. Note that if markup is involved, it must comply with the rules file for the document into which the material is to be pasted. 3.1. Undo Allows the effect of the last operation to be undone. Most commands can be undone. There are, however, some HoTMetaL actions that cannot be undone: -- any command from the File menu -- scrolling and windowing commands -- text selection -- Undo itself -- Show Structure View, Show Context View -- Any actions performed prior to the last time the document was saved cannot be undone. If you imagine a sequence of undo-able commands as a list, successive Undo commands will proceed through the list, starting at the most recent. Therefore, if you execute two Undo commands in a row you will undo the most recent action, and then undo the second most recent action. Note that since Undo is not itself an undo-able command, one Undo cannot undo another. This function is reserved for Redo, which is the inverse of Undo. (See the section on Redo.) If you undo a Copy or Cut command, the previous contents of the clipboard will be restored. 3.1.1. Undo limit The number of previous commands which can be undone is not limitless but is controlled by an undo limit. Once this limit is reached, each successive command will cause the oldest undoable command to be committed, that is, it will no longer be possible to undo that command. For example, if the undo limit is set to 1 and you Cut a selection and then Paste what you just cut, you will be able to undo the paste but not the cut. If the undo limit were two or greater, both the cut and paste could be undone. The default value for the undo limit is 10, but this can be changed by setting the undo_limit configuration variable. 3.2. Redo Allows the most recent undone command to be redone. Redo operates in a way similar to Undo: a sequence of Redo commands re-does the most recent redo-able commands (i.e., commands that have been undone) in reverse order. Redo and Undo are inverses of each other: the net effect of an Undo and its corresponding Redo is to cause no change to the document. If an undoable action is performed after a series of one or more Undo commands then the Undo commands will no longer be redo-able. To illustrate how Redo works, suppose you Cut a selection in a document, and then Paste that selection somewhere else. If you perform two Undo commands, first the Paste and then the Cut will be undone. If you then execute a Redo, the Cut will be redone. A second Redo will then redo the Paste. 3.3. Cut Removes the current selection from the document and places it in the clipboard. Any previous contents of the clipboard will be erased. The selection can then be pasted. This command is used when you want to remove a section of text that will probably be pasted in elsewhere, in the same or another document. 3.4. Copy Copies the contents of the current selection into the clipboard and erases any previous contents. The document is left unchanged. This command is used when you want to duplicate a portion of the document without erasing it. The copied selection can be inserted elsewhere using the Paste command. 3.5. Paste Transfers the contents of the clipboard to the document. If the document contains an insertion point, the clipboard is pasted at that point; if it contains a selection, then the contents of the clipboard replace the selection. The clipboard may contain markup. If the paste would result in an incorrectly marked-up document, you will be prompted to either cancel the paste operation or continue with rules checking turned off. 3.6. Find and Replace... Allows text, elements, and patterns to be found and replaced. You are presented with a dialog box that allows you to enter various values and parameters. 3.6.1. Specifying the search and replace strings The Find text box allows you to specify a search string of text characters, tags, entity references, or patterns. If the document contains a selection when you invoke Find and Replace... the selected text will automatically become the search string. If the selected text is longer than 255 characters, it will be truncated. If it contains a markup icon, e.g., an element, comment, or entity reference, it will be truncated at the last character before the icon. A selection that starts with a markup icon will become a null search string, and therefore an existing selection cannot be used to cause an element to be the search string. The Replace text box allows you to specify a replace string consisting of text characters, tags, or patterns with which you want to replace the search string. The Find In text box allows you to restrict your search to a particular element. The Find, Replace, and Find In strings are described in more detail below. 3.6.2. Command buttons There are five buttons (including Cancel) along the bottom of the Find & Replace dialog box that allow you to carry out several search and replace operations. 3.6.2.1. Find Find causes HoTMetaL to search through the document for the search string according to the various search parameters chosen. If you click on Find and the search is successful, HoTMetaL activates the document window, selects the text and/or elements that were found, and scrolls to the selection. If the search fails, HoTMetaL will beep. Also, a Not found message will be displayed at the bottom of the Find & Replace dialog box. Text searches will not match if parts of the search string are found within different elements. If you are searching for Fred and Barney, but the word and is in a separate element (emphasized, for example), the search string will not be matched. 3.6.2.2. Replace Replace replaces the current selection in the document with the replace string. This command is enabled only when you have a selection. 3.6.2.3. Replace then Find Replace then Find replaces the current selection in the document with the replace string, and then resumes the search procedure. This command will be enabled only if you have a selection. You would use this option if you wanted to manually examine each occurrence of the search string before doing a replacement: if you decide to perform the replacement, click on Replace then Find again; otherwise, click on Find to go to the next occurrence of the search string. 3.6.2.4. Replace All Replace All replaces all occurrences of the search string with the replace string. This command automates the whole find and replace process, not giving you the opportunity to choose individual cases. It is possible that some of the occurrences of the search string which are found cannot be replaced, because this would cause an incorrectly marked-up document. If so, these occurrences are skipped over. After the operation has been completed, a message will be displayed in the Find & Replace dialog box showing how many occurrences of the search string were found, and how many were replaced. The insertion point will now be at the end of the last replacement. 3.6.3. Specifying search patterns as regular expressions When the Find Patterns option is on (see below), the characters you type in the Find text box are interpreted as patterns by HoTMetaL: that is, the search string can contain certain special search characters which allow the search string to match a class of strings, or markup constructs. If your search string does not contain any special search characters, HoTMetaL will search for exactly the string you have typed. On the other hand, if the search string does contain special search characters, it is interpreted as a regular expression which defines a pattern of characters to be matched. For example, the special search character `.' (period) is used in the pattern m...y to match a sequence of five characters beginning with `m' and ending with `y', e.g., the words money, marry, murky, etc. A complete description of Author/Editor regular expressions and special search characters appears below. 3.6.4. Regular expressions and special search characters The following characters are special search characters in a search pattern: \ . * ? + ^ $ [ ] In addition, the characters `&' and `<' are special when one or the other appears as the first character of the pattern. If you want to search for any of these as ordinary characters when Find Patterns is turned on, it must be preceded by a backslash. For example, \. is used to match a period. Regular expressions are sequences of ordinary characters and special characters, combined according to certain rules. The following list summarizes how these special search characters are interpreted, and how regular expressions are formed. -- An ordinary character represents itself. -- A string beginning with a `<', immediately followed by an element name, is used to match a whole element (which may include attributes and content, as discussed below). -- A period or dot, `.', represents a single, arbitrary character (including a blank). So fo.d would match food, ford, fond, fold, etc. Similarly, s.o. matches stop, shot, snow, and so on. -- A single character, or a string enclosed in parentheses, followed by an asterisk, `*', matches zero or more occurrences of that character or string. For example, l*ama would match ama, lama, llama, lllama, etc. b(an)*a would match ba, bana, banana, and so on. It is possible to combine the `*' with `.' to match arbitrary strings of characters. So s.*ch matches search, such, stretch, stopwatch, as well as sch and `skip lunch'. The search pattern represents strings that start with `s' followed by zero or more occurrences of an arbitrary single character (it doesn't have to be the same character over and over) followed by the characters `ch'. Since the period can match a blank space, this pattern can match a multi-word string. -- A single character, or a string enclosed in parentheses, followed by a question mark, `?', matches zero or one occurrences of that character or string. For example, to search for instances of both color and colour, you would use: colou?r -- A single character, or a string enclosed in parentheses, followed by a plus sign, `+', matches one or more occurrences of that character or string. For example, the following expression matches ben, been, beeen, and so forth, but not `bn'. be+n -- Regular expressions may be enclosed within parentheses for grouping. -- Two regular expressions separated by a vertical bar, `|', match any string that matches either of the regular expressions. For example, if you wanted to search for either love or money, you would use the expression: love|money In a more complex example, you could combine two regular expressions given above: s.*ch|fo.d -- A caret, `^', at the very beginning of a search pattern means that text will match the pattern only if it immediately follows markup. Such text must not be separated from the markup by white space. Anywhere else, the caret is not treated as a special search character (except in sub-strings, see below). For example, if you wanted to search for the word Note immediately following markup, you could use: ^Note -- A dollar sign, `$', at the very end of a search pattern means that text will match the pattern only if it is immediately followed by markup. Such text must not be separated from the markup by white space. Anywhere else, the dollar sign is not treated as a special search character. For example, if you wanted to search for the word sub immediately preceding markup, you could use: sub$ -- A pair of square brackets [ ] around any string of characters defines a sub-string that matches any one of the characters between the brackets. For example, an[dy] matches and and any. By contrast, a string of characters preceded by a caret, `^', within brackets, matches any character not in the string. For example, th[^ei][a-z]* matches any word that begins with th, which is not followed by an e or i. It would match that and thought but not therefore or this. -- A sub-string, within square brackets, of the form [char1-char2] matches any character in the range of ASCII characters beginning at char1 and ending at char2. For example, the sub-string [e-p] matches any lowercase letter between `e' and `p', inclusive. The substring [A-z] matches any upper- or lower-case letter. Note that if searching is not in case-sensitive mode (see below), no distinction between lower case and upper case letters is made in character ranges. In this case, for example, the character range [a-z] would match any upper- or lower-case letter. -- An expression of the form [^char1-char2] matches any character not in the range of ASCII characters beginning at char1 and ending at char2. -- A range can occur inside a sub-string. For example, the pattern: [ac-fh] matches any of `a', `c' through `f', and `h'. -- If you wish to use any of the characters `^', `]', or `-' as a regular character within a sub-string rather than as a special search character, there are certain rules you must follow. -- The `^' character is special only if it occurs as the first character in a sub-string. Otherwise, it's treated as a regular character. E.g., [joy^] will match any of the characters `j', `o', `y', and `^'. -- The character `-' is a special search character if it occurs between other characters in the sub-string. If it occurs at the beginning or end of the sub-string, it is a regular character. For example, the sub-string [a-] will match `a' or `-'. -- The character ']' terminates a sub-string unless it occurs as the first character. For example, []ab] will match `a' or `b' or `]'. But [ab]] matches `a' or `b' followed by `]'. None of the otherwise special search characters, including `\' and `[' has special meaning within a sub-string. -- If you surround a sub-expression in the search string by parentheses, '(' and ')', you can refer in the replace string to whatever this sub-expression matches. In general, an expression in the replace string of the form \n, where n is a number from 1 to 9, means "replace this expression with whatever the nth expression in brackets in the search string has matched". For example, if the search string is (.*)read and the replace string is \1ox then if the search string matches bread, the found text will be replaced by box. This is because the sub-expression (.*) matched the letter b; the expression \1 in the replace string means "replace this expression with whatever is matched by the first expression in parentheses in the search string". Therefore b is substituted for \1 and the replace string becomes box.Here is a more complicated example: suppose the search string is (v.*e) (v.*a) and the replace string is \2 \1 Now the search string may match the words vice versa. The first sub-expression, (v.*e), matches vice and the second sub-expression, (v.*a), matches versa. In the replace string, HoTMetaL replaces \2 by what the second sub-expression in the search string matched, and replace \1 by what the first sub-expression matched. Therefore the replace string becomes versa vice. The net effect of the operation is to replace an occurrence of vice versa with versa vice. It is possible to nest sub-expressions. In this situation, the sub-expressions are numbered according to the order of occurrence of their left parentheses. For example, if the search string were (a(bc)d) and the replace string \2 \1 the effect would be to find abcd and replace it by bc abcd. The expression \0 in a replace string refers to the entire string that was matched by the search string. E.g., if the search string were fish and the replace string were gone \0ing then an occurrence of fish would be replaced by gone fishing. 3.6.5. Elements as search patterns A search string which begins with an open angle bracket, `<', followed by a valid element name matches an element of that name. If the search succeeds, the insertion point is positioned to the left of the start tag. It does not matter here or in other search options whether tags are visible or not (see Show/Hide Tags in the View menu). The name in the search string can optionally be followed by a closing angle bracket (>). For example, The would match the word The anywhere within the element P. This is similar to the kind of restrictive searching that can be done using the Find In string but it can be used in conjunction with that feature to further restrict the search. In the last example, if the Find In string is set to