Current Version:  2.5 Implements WYSIWYG HTML!
                  (See What's New in Version 2.5 and Version History)
Last updated:     26 July 1995

HTML Macros Version 2.5


About These Macros

Nisus Writer is a fantastic word processor for HTML writing because styled documents can be served directly, and its Find/Replace and non-contiguous selection features are outstanding. Here is a set of Nisus Writer macros to assist World Wide Web authors to generate HTML documents. These macro commands run unmodified in both version 3.25 and version 4 (Nisus Writer).

Thanks to Sandra Silcot for all the hard work and dedication to creating these HTML Macros and supporting Nisus Writer on the Internet. Sandra can be reached at ssilcot@www.unimelb.edu.au.

New in Version 2: It may be useful to have WYSIWYG visual cues in editing html. Version 2 now optionally supports styled html editing. In styled editing mode, when you run a macro command to insert HTML tags, the replacement is made attribute sensitive to the defined character styles in the macro file. If you prefer working with plain text, you may continue to do so by leaving styled editing turned off. Let me explain this a little more. Text between and including the angle brackets e.g. <...> is a HTML tag. Running the macro command * Apply HTML Styles will apply the *tag style to all such HTML tags regardless of whether styled mode editing is on or off. If you have styled editing mode turned on, the text in-between the opening and closing tags will also have an appropriate style applied "on the fly" by the tag inserting macro commands where appropriate e.g. Header- 1, or Style-Strong will apply styles, whereas the macro commands for list items and paragraphs do not.

The HTML Macros are distributed with styled editing OFF. If you want to try the styled editing, PLEASE read the documentation on styled mode first. Enable styled editing by running the macro command * HTML Styles ON in Macros. To see what the distributed defined styles do, open a copy of a HTML document, run the * Apply HTML Styles macro command, and be patient! Then toggle the display of Invisible Text on and off.

Enjoy!


Installation Notes and Web Source

Here's how to install the HTML Macros and obtain new versions:

  1. Obtaining New Versions

    The package is available for Nisus Software's Web Site at Demos, Updates and Extras.

    The package, a binhexed self-extracting-archive, contains:

  2. Install Keyboard Shortcuts Preferences.

    New users:
    This is a once only task. Open the macro file HTML Keyboard Shortcuts Setup. Execute the macro command named ***Assign Keyboard Short 3 or ***Assign Keyboard Short 4 depending on which version of Nisus you use. These assignments can be removed with the macro command ***Remove Keyboard Short 3 or ***Remove Keyboard Short 4. The keyboard shortcuts assigned are noted below.
  3. Customise the Macro Suite

    Open and Edit the macro file HTML Macros. Customize the macro commands ×Template Footer and ×Template Header (not needed if you prefer to use a stationery document.). See also instructions for customizing defined character styles for the HTML tags.

  4. Turn on Styled Editing (optional)

    If you want to use styled editing, you must run the macro command * HTML Styles ON in Macros (The HTML Macros are distributed with styled mode editing OFF).

You are now ready to start writing HTML.

Note: The shortcuts follow the abbreviation of the HTML tag name. If you wish to assign different shortcuts, modify ***Assign Keyboard Short as required before running it, or modify them later as required using Nisus Writer's Keyboard Shortcuts command.


Features

Cross-version Compatibility

These HTML Macros run unmodified in both version 3.25 and version 4 (Nisus Writer). You do NOT need to run the Nisus Writer conversion macro, "Convert version 3 to 4 Macros." They have been tested on 3.25 Nisus and 4 NisusWriter.

Support for Non-contiguous Selections!

Probably the most powerful feature of these HTML Macros is that they are designed to support Nisus' non-contiguous selections. e.g. using command-option selections, or a find command, to select all your level 2 headings, then simply execute the Header- 2 macro command. All the selected headings will now be wrapped with h2 tags.

Supports All Commonly Used Style Tags (except forms)

Includes:

Form tags not supported yet.

Flexible Support for All List Types

Includes: individual marking of list items (<li> tag only), list wrapper tags only for <ol>, <ul>, <dl> type lists, or wrappers as well as list item marking in one command. Two discursive list macro commands provided to enable dt/dd parts to be delimited by tabs or returns. Includes a macro command to quickly convert all bulleted paragraphs to html unordered lists (sorry, no smart list nesting yet).

Supplies Often Neglected End Paragraphs And List Tags

These macro commands impose <p></p> and <li></li> syntax so your html won't break when browsers start conforming to the html DTD specs. Includes a macro command to quickly convert all non-tagged or non-bulleted paragraphs to html paragraphs.

Support for Header/Footer Templates

Three template macro commands are supplied. One inserts a header at the top of a document and prompts for a title and h1 string. One inserts a standard footer at the bottom of a document. The other simply calls the other two.

Please customize these macro commands as required to suit yourself.

Powerful Aids for Generating Hypertext Tables of Contents

The List-Header to Unordered macro command generates properly nested unordered lists of all h2-6 tags in a document, including auto-calculated anchor names on headings, hypertext links on the contents items, and places the result in the Clipboard for you to copy into your document (very useful for a Table of Contents section). The List-Files to Unordered macro command works as per List-Header to Unordered except it works on all the files selected in the Catalog window, creates a new file, and includes the level 1 heading. Again, proper hypertext referencing is done for you.

Optional Styled Tags

Version 2 implements, optionally, automatic styling of tags and tagged text. The intention is to provide some basic visual editing assistance. This feature is not, I repeat not, intended to make these HTML Macros into a Web browser! The styles are totally brain-dead when it comes to embedded lists. Please use a proper Web browser to see what your HTML will actually look like.

Installation of Keyboard Shortcuts

For your convenience, a separate macro file is supplied to install keyboard shortcuts for each macro command. This works by mirroring the macro commands in the actual macro file, and supplying macro code to setup keyboard shortcuts.

Simply open the macro file named HTML Keyboard Shortcuts Setup and execute the macro named ***Assign Keyboard Short the default keyboard shortcuts are assigned.

The OPTION key is used as the modifier
e.g.

This is easily changed in the macro file itself. You only need run this once of course.


Guide to Styled Mode Editing

If you choose to work in styled mode, it is very important you understand how the styles have been implemented. For best results, please take the time to read the following documentation.

WARNING: When you run * Apply HTML Styles, the styles applied are NOT ADDITIVE and will replace any existing formatting. If you are working with a document containing your own stylenames or formatting which you want to retain, do NOT use the styled HTML mode (ie. execute * HTML Styles OFF in Macros) and do NOT execute * Apply HTML Styles.

Changing to/from Styled Editing Mode

You may switch modes at any time by running * HTML Styles ON in Macros or * HTML Styles OFF in Macros as required. In all appropriate replace commands, styles exist in the replace text. With styled mode ON, the replacement is attribute sensitive - this will import and apply the stylename. With styled mode OFF the replacement is not attribute sensitive.

When working in styled mode, over time the styles will fragment. This can be minimized if you assign a function key to the *normal style, and remember to press that key when adding text to the right of an opening HTML tag.

You can run * Apply HTML Styles at any time to clean up the fragmentation.

Default Styles and Their Attributes

A minimal set of defined character styles exist in the macro file (there is no use of rulers in these styles):

*anchor
The anchor text seen in a hyperlink
Distributed as: Blue, Underline, Additive.

*em
The logical HTML style for emphasis
Distributed as: Italic, Not Additive.

*H1-6 (one for each heading level)
The six HTML heading levels.
Distributed as: Plain, Palatino, Black, Not Additive.

*normal
"Normal" text. When you * Apply HTML Styles, everything is first reset to this.
Distributed as: Plain, Palatino, Black, Not Additive, 12 point.

*pre
This style is applied to <pre>, <code> and <tt> tags.
Distributed as: Courier, 10 point, Additive (so you don't lose other styles when you wrap stuff in <pre> tags.

*strong
The logical HTML style for strong emphasis.
Distributed as: Bold, Not Additive.

*tag
All HTML tags i.e. anything between angle brackets but excluding what is contained by the opening and closing HTML tags.
Distributed as: Plain, Monaco, Green, Not Additive, 9 point, Ignore Spelling.
Note: You may wish to make this style Invisible.

Changing the Defined Style Attributes

The define styles in the macro file can be edited to reflect your own stylistic choices but you should not change the additive attributes on any defined styles. Edit the macro file and select Define Styles. Choose the style to change, make and save your changes.

If you change your mind later, the macro command * Remove HTML Style Names should be run, followed by * Apply HTML Styles, on any documents edited with your prior style formatting choices in order to bring them back in sync with the macro file's formatting choices.

How to See Your HTML without Tags

Several options are available.
Make the *tag Style Invisible
Advantages: it is very fast to use Nisus Writer's menu item for display or non-display of visible text, especially if you assign that menu item a keyboard shortcut. Disadvantages: Its very easy to be confused when editing with invisible text hidden - the tags will not appear. It is strongly suggested that you always display invisible text when editing.

Use the * Show/Hide HTML Tags Macro Command
Advantages: *tag style may be kept as visible, so they will always appear when editing. Disadvantages: on large documents it may take some time to execute the formatting change.

Use the * Convert HTML to Text Macro Command
Advantages: reasonably fast. Disadvantages: Creates another file.

Ultimately, the best option is to save your work and view it in a Web browser!

Design Issues

When implementing HTML styles in this macro file, a critical design decision was whether or not to make the HTML define styles additive. Additive character styles would have the advantage of better coexisting with existing non-HTML related formatting. This is important if users want a single document suitable for hardtop and Web format, and they want additional formatting beyond the scope of html tags in the print version and have used styles to achieve this. On the other hand, without additive styles there would be no way of ensuring a consistent output from the macro command which applies HTML styles. For example, with additive styles, running * Apply HTML Styles a second time would actually remove the HTML styles. To get consistent output, one needs to apply formatting from a consistent base. This means removing all existing formatting.

In this release, consistency of output was chosen i.e. implementing NON-additive HTML styles. The fact that applying HTML styles will remove any existing formatting is a conscious design choice. You can still make excellent use of these HTML Macros by simply using them in non-styled mode. In this case, no attributes are changed in replacements. You are free to make the macro file's define styles NON-additive but be warned you may be surprised with the results.


The HTML Markup Macro Commands in Detail


Macro Commands to Manage Styled Editing Mode

Note: I have chosen not to include any keyboard shortcuts for these style related macro commands in the distribution because their use and combinations will be very personal.


    * Add HTML to Document               * Reapply HTML Styles

    * Apply HTML Styles                  * Remove HTML Style Names

    * HTML Styles OFF in Macros          * Remove HTML Styles

    * HTML Styles ON in Macros           * Show/Hide HTML Tags  

    * Ignore Spelling Tags

* Add HTML to Document
Force the macro file define styles to be present in the document (does not apply them).

* Apply HTML Styles
This macro command will apply the macro file define styles to all HTML tags and text. WARNING: THIS MACRO COMMAND REMOVES ALL OTHER DEFINE STYLES AND FORMATTING from the text and leaves only the HTML formatting styles. There is a warning dialogue to this effect - reply yes to continue. These styles are controlled by the formatting choices defined in the macro file define styles.. The macro does alot of processing and runs very slowly on large HTML documents.

* HTML Styles OFF in Macros
Modifyies and saves the macro file so that styles are not applied when executing HTML tag macro commands. This in effect provides a plain text editing mode. The macros are distributed in this mode i.e. Styles OFF..

* HTML Styles ON in Macros
Modifies and saves the macro file so that styles will be applied when executing HTML tag macro commands.

* Ignore Spelling Tags
For those who prefer unstyled editing, but still want to avoid spelling checks on the tags. It implements this by selecting all the tags, invoking the dictionary dialogue and keying cmd-M for Ignore. The macro only works if styled editing is off, as it is assumes that if you use styles you will want to retain no spelling on the *tag style.

* Reapply HTML Styles
Selects text by HTML style and undoes the style by re-applying it for each defined html styles. Written to assist in debugging style choices but not really useful other than as a model for your own find commands based on the styles.

* Remove HTML Style Names
Removes the HTML define styles from a document's Style menu. Useful for reverting to plain text mode, or bringing a document's define styles back in sync with the macro define styles formats if you are getting Nisus Writer define style conflict dialogs.

* Remove HTML Styles
Make everything plain text - effectively removes all style formatting (but not defined styles) from the document.

* Show/Hide HTML Tags
This macro command selects all HTML tags and toggles the Invisible Text attribute on or off. It does not modify the named style attributes of the *tag defined style. Very useful if you retain the Invisible Text attribute on your *tag define style.
Shortcut: cmd-opt-vt.


HTML Tag Macro Commands

This section describes what each macro command concerned with inserting HTML markup tags does.

Note:

  1. all macros support non-contiguous selections unless otherwise noted.
  2. "&" indicates whatever is selected when the macro is executed.
× Address  × Title  ×Stationery  ×Template Footer  ×Template Header

*Header- 1  *Header- 2  *Header- 3  *Header- 4  *Header- 5  *Header- 6

*Link-Anchor  *Link-To Document  *Link-In Document  *Link-Image
*Link-Create Anchor List

*List-Definition Descrip.  *List-Definition (R)  *List-Definition (Tabs)
*List-Definition (Wrap)  *List-Definition Term  *List-Item
*List-Ordered  *List-Ordered (Wrap)  *List-Unordered
*List-Unordered (Wrap)  *List-Bullet to Unordered  *List-Header to Unordered
*List-Files to Unordered

*Netscape-Center  *Netscape-Font

*Special-Line Break  *Special-Horizontal Rule  *Special-Paragraph Break  
*Special-R to Paragraphs

*Style-Bold  *Style-Code  *Style-Emphasis  *Style-Italic  *Style-Strike
*Style-Strong  *Style-Underline  *Style-Block Quote  *Style-Citation
*Style-Preformatted  *Style-Typewriter  *Style-Delete Preformat R


× Address
Wraps selection(s) with × Address&</address>.
Shortcut: cmd-opt-ad.

× Title
Wraps selection(s) with <title>&</title>.
Shortcut: cmd-opt-t.

×Stationery
Inserts header and footer at top and bottom respectively, and prompts for a title.
Shortcut: cmd-opt-tem.

×Template Footer
Inserts footer html at bottom of file.
Shortcut: cmd-opt-tf.

×Template Header
Inserts header html at bottom of file, and prompts for a title.
Shortcut: cmd-opt-th.

*Header- 1
Wraps selection(s) with <h1>&</h1>.
Shortcut: cmd-opt-h1.

*Header- 2
Wraps selection(s) with <h2>&</h2>.
Shortcut: cmd-opt-h2.

*Header- 3
Wraps selection(s) with <h3>&</h3>.
Shortcut: cmd-opt-h3.

*Header- 4
Wraps selection(s) with <h4>&</h4>.
Shortcut: cmd-opt-h4.

*Header- 5
Wraps selection(s) with <h5>&</h5>.
Shortcut: cmd-opt-h5.

*Header- 6
Wraps selection(s) with <h6>&</h6>.
Shortcut: cmd-opt-h6.

*Link-Anchor
Wraps selection(s) with <a name="&">&</a>.
Shortcut: cmd-opt-a.

*Link-To Document
Wraps selection(s) with <a href="XXXXXXX.html">&</a> and highlights the XXXXXXX.html (so you can easily paste a URL if you have it in the Clipboard).
Shortcut: cmd-opt-h.

*Link-In Document
Wraps selection(s) with <a href="#&">&</a> and highlights the anchor name so you can easily modify it.
Shortcut: cmd-opt-hi.

*Link-Image
Inserts in-line image tags, for example: <img src="GGGGGGGG.gif" align=BOTTOM alt="&">
Shortcut: cmd-opt-img.

*Link-Create Anchor List
Creates a new document containing a set of hrefs to all internal anchor names in the current selection (or whole file if nothing selected). Useful for generating internal cross-references.

*List-Definition Descrip.
Wraps selection(s) with <dd>&</dd>.
Shortcut: cmd-opt-dd.

*List-Definition (R)
Wraps selection(s) with <dl>&</dl> and for each pair of lines, wraps first in <dt></dt> and second in <dd></dd> (nb: return delimited).
Shortcut: cmd-opt-dlr.

*List-Definition (Tabs)
Wraps selection(s) with <dl>&</dl> and for each pair of data with a tab in between, wraps first field in <dt></dt> and second in <dd></dd> (nb: tab delimited).
Shortcut: cmd-opt-dlt.

*List-Definition (Wrap)
Wraps selection(s) with <dl>&</dl>.
Shortcut: cmd-opt-dlw.

*List-Definition Term
Wraps selection(s) with <dt>&</dt>.
Shortcut: cmd-opt-dt.

*List-Item
Wraps selection(s) with <li>&</li>.
Shortcut: cmd-opt-li.

*List-Ordered
Wraps selection(s) with <ol>&</ol> and for line wraps it in <li></li>.
Shortcut: cmd-opt-ol.

*List-Ordered (Wrap)
Wraps selection(s) with <ol>&</ol>.
Shortcut: cmd-opt-olw.

*List-Unordered
Wraps selection(s) with <ul>&</ul> and for line wraps it in <li></li>.
Shortcut: cmd-opt-ul.

*List-Unordered (Wrap)
Wraps selection(s) with <ul>&</ul>.
Shortcut: cmd-opt-ulw.

*List-Bullet to Unordered
Convert all paragraphs in current selection(s) which start with a bullet, dash, tab, asterisk (i.e. characters likely to be used for lists) to html list items, ignoring leading spaces, and removing the list character. Does NOT handle indented lists (single level only).
Shortcut: cmd-opt-dpu.

*List-Header to Unordered
Auto-generates a table of contents for all headings in the current file, and places it in the Clipboard. WARNING: This macro calculates and assigns its own anchor names on all heads, thus overwriting any anchors you may have assigned. It retains any hrefs which already exist in the heading. It ignores any text following end heading tags.

*List-Files to Unordered
As per *List-Header to Unordered except it works on files currently selected in the Catalog. WARNING: This macro command calculates and assigns its own anchor names on all heads, thus overwriting any anchors you may have assigned.
Shortcut: cmd-opt-hc.

*Netscape-Center
Simple implementation of Netscape's <centre>...</center> tag.
Shortcut: cmd-opt-ce.

*Netscape-Font
Simple implementation of Netscape's <font size=N>...</font> tag.
Shortcut: cmd-opt-fo.

*Special-Line Break
Inserts a line break <br> tag at the insertion point (non-contiguous selections make no sense here).
Shortcut: cmd-opt-br.

*Special-Horizontal Rule
Inserts a tab followed by <hr> at start of all selections. Also displays a line across the screen using a named ruler and a tab mark with leading. To modify the rulers appearance, change the ruler present in the xxxRulersOnHRs macro. Supports non-contiguous selection, so now its easy to use Nisus Writer to select, say, all <h2> tags and insert a horizontal rule in front of all level 2 headings.
Shortcut: cmd-opt-hr.

*Special-Paragraph Break
If nothing is selected, inserts <p> at the insertion point. Otherwise, wraps selections in <p></p>.
Shortcut: cmd-opt-p.

*Special-R to Paragraphs
For the current selection(s), convert all returns to paragraph html so long as the paragraphs doesn't start with an html tag, bullet, dash, tab, asterisk (that probably signifies a list item). Also changes any soft-returns to *Special-Line Break. Use in conjunction with the *Unbreak Lines macro command.
Shortcut: cmd-opt-rp.

*Style-Bold
Wraps selection(s) with <b>&</b>.
Shortcut: cmd-opt-b.

*Style-Code
Wraps selection(s) with <code>&</code>.
Shortcut: cmd-opt-c.

*Style-Emphasis
Wraps selection(s) with <em>&</em>.
Shortcut: cmd-opt-em.

*Style-Italic
Wraps selection(s) with <i>&</i>.
Shortcut: cmd-opt-i.

*Style-Strike
Wraps selection(s) with <strike>&</strike>.
Shortcut: cmd-opt-ik.

*Style-Strong
Wraps selection(s) with <strong>&</strong>.
Shortcut: cmd-opt-st.

*Style-Underline
Wraps selection(s) with <u>&</u>.
Shortcut: cmd-opt-u.

*Style-Block Quote
Wraps selection(s) with <blockquote>&</blockquote>.
Shortcut: cmd-opt-bq.

*Style-Citation
Wraps selection(s) with <cite>&</cite>.
Shortcut: cmd-opt-ci.

*Style-Preformatted
Wraps selection(s) with <pre>&</pre> and applies a mono-spaced font.
Shortcut: cmd-opt-pre.

*Style-Typewriter
Wraps selection(s) with <tt>&</tt>.
Shortcut: cmd-opt-tt.

*Style-Delete Preformat R
Removes html paragraph tags within preformatted text.
Shortcut: cmd-opt-kp.


Other Convenience Macro Commands

The package includes a number of other macro commands not specifically concerned with HTML tags, but of convenience to HTML authors.

*Convert HTML to Text  *Convert Tags to "< >"  *Convert to HTML Entities
*Convert UNIX to Mac Text  *Remove HTML Stylesheets  *Remove Redundant R
*RTF Stylesheet Extract  *Select Content  *Select HTML Tags  *Unbreak Lines

Add Marker  Copy Pathname  Copy Pathnames (All Docs)
Delete Paragraph Rulers  Find Selection


*Convert HTML to Text
Selects all text which is not in HTML tags, copies it to a new file suffixed with .txt instead of .html.

*Convert Tags to "< >"
In current selection(s), translate html tag characters < and > to their equivalent html entities.
Shortcut: cmd-opt-isi.

*Convert to HTML Entities
In current selection(s), translate non html tag special characters to their equivalent html entities (i.e. not < or > - see below). Easily extendable.
Shortcut: cmd-opt-iso.

*Convert UNIX to Mac Text
Changes UNIX end of lines to Mac returns.

*Remove HTML Stylesheets
Removes html from selections.
Shortcut: cmd-opt-k.

*Remove Redundant R
Removes multiple returns and inserts an extra return at the start of a genuine HTML paragraph, heading, list item, etc.

*RTF Stylesheet Extract
If you open as text an RTF file, this macro command extracts out the define style information.

*Select Content
Selects everything not wrapped in HTML tags within the current selection or if no selection is made, the contents of the entire document is selected.

*Select HTML Tags
Selects HTML tags within the current selection or if no selection is made, all the tags of the entire document are selected.

*Unbreak Lines
Remove returns from selected text.

Add Marker
This macro command is exactly the same as "Mark" in Nisus Writer but it works on non-contiguous selections.

Copy Pathname
Copies the full pathname of the current document onto the Clipboard.

Copy Pathnames (All Docs)
Copies the full pathnames of all open documents onto the Clipboard. If a macro file is the front document, only the macro file will be found.

Delete Paragraph Rulers
Deletes all rulers (except the first) from the current document.

Find Selection
Finds next occurrence of the current selection.

Document Macro File

Used to print a macro file. Copy Document Macro File to any macro file, execute it, and it will generate an indexed list of the macro file's contents (non-displayable special characters are converted to meaningful names).
IMPORTANT: this macro relies on an arbitrary convention of delimiting each macro command from another. It uses the convention:
//==================== MACRO macro-name-here
at the start of each macro command. The macro file contents are copied, these marker lines are picked up and the names are marked and indexed.

Version History

Version 2.5.2, 13 October 1995

Version 2.5.1, 22 September 1995

Version 2.5, 26 July 1995

Version 2.0, 8 Mar 1995

Version: 1.3, 27 Dec 1994

Version: 1.2, 14 Dec 1994

Version 1.1 10 Dec 1994

Version 1.0 10 Nov 1994 - Initial version.


Planned Enhancements

Support for Forms
Plans to include a form "template" macro command, plus macro commands for commonly used form tags.
Better Support for Installation of New Versions
To work out a way to let install new versions but retain user defined style preferences. Ideas on how to do this are welcome!

Bug Reports and Comments

Sandra Silcot has allowed Nisus Software to distribute these HTML Macros with Nisus Writer and through Nisus Software's Web site. Click here to go to Nisus Software. You can reach Sandra Silcot at

You may forward all bug reports, comments, and requests to features@nisus-soft.com as well as any other suggestions you may have about Nisus Writer.


Sandra Silcot,
Information Technology Services,
University of Melbourne.
Email: ssilcot@www.unimelb.edu.au
WWW:   http://www.unimelb.edu.au/~ssilcot/

Nisus Software
107 S. Cedros Ave.
Solana Beach, CA 92075
USA
Email: support@nisus-soft.com
WWW:   http://www.nisus-soft.com/~nisus
FTP:   ftp://ftp.nisus-soft.com/pub/nisus