home / experts / javascript / column56 |
|
Text Formatting ExampleOur first example macro deals with formatting a document according to a predefined layout rules. In order to observe this macro's effect, please turn off the Enable Source Layout button in Tools->Customization. We first initialize some global variables upon opening the application. The name of the macro must be
This macro will be called upon opening the HoTMetaL application. Its sole purpose is to define three constants that are needed for other macros. These constants simply represent three corresponding HoTMetaL views. Navigate along the window tabs on the left bottom corner of HoTMetaL's editing window. You'll see the The following macro checks that the current view is the source view and formats the whole documents according to predefined rules. If the view is not the source view, a message is printed to the user, asking him to switch views:
Notice we have used here two HoTMetaL's objects: Let's test this macro now. Open a document in HoTMetaL and switch to the Source View. You can pick, for example, one of the chapters in the
Now suppose that you want to format just a selected portion of the document. The desired macro, called Format Current Selection, is very similar to the above macro, Format Current Document. The difference is that instead of the
Let's see this macro in action. We indented two lines in the open document. The first one starts with "does not specify," and the other one starts with "referred to in this ma:"
Now we select three lines including the one that starts with "does not specify:"
And finally we click the green arrow at the top left corner of the window, next to the macro name (Format Current Selection) that is shown in the window of the pull-down menu:
Notice that only the selected line has been formatted back to its original paragraph boundary. The second line that starts with "referred to in this ma" stayed indented and unformatted. |
Produced by Yehuda Shiran and Tomer Shiran
Created: January 18, 2000
Revised: January 18, 2000
URL: http://www.webreference.com/js/column56/layout.html