AddMenu

#subs

In addition to the built-in substitutions, AddMenu allows the user to specify additional text substitutions using the #subs marker with a specified file. The author uses a .txt file although any file type could be used. Each substitution requires two lines in that file: The first gives the text that will be replaced. The second gives what that the text will be replaced by.

Lets illustrate with two examples.

  1. Suppose that after writing a source file, the you decide that every occurrence of "Java" should be bolded. You would specify that "Java" should be replaced by "<b>Java</b>".
  2. You find that frequent use of the HTLM tag <span class = "blue"> really makes your source file hard to read. You might decide to have the preprocessor replace '(@' by '<span class = "blue">' and '@)' with '</span>'. Then instead of writing '<span class = "blue">a word</span>' you could just write '(@a word@)'.

The following file could be used to specify these substitutions:

Java
<b>Java</b>
(@
<span class="blue">
@)
</span>

If that file is named AddMenuSubs.txt, then the following marker would be used to invoke it some place before it actually used.

#subs AddMenuSubs.txt

Then the source code

AddMenu is written Java because Java can be used on most computers.
<br><br>
(@This text is blue@)
and this is (@some more blue text@)

would be replaced by

AddMenu is written <b>Java</b> because <b>Java</b> can be used on most computers.
<br><br>
<span class="blue">This text is blue</span> 
and this is <span class="blue">some more blue text</span>.

Assuming the style "blue" is defined properly, a browser would displayed this as

AddMenu is written Java because Java can be used on most computers.

This text is blue and this is some more blue text

A #subs marker can be used as many times as desired in the source file. Each time it is used, all the previous user supplied substitutions are removed before the new ones are added. Moreover, using #subs without a file name just removes all existing user defined substitutions. Together, this allows using a different set of substitutions in different parts of a file and no substitutions in other parts. (In fact, #subs markers were used while writing the source file for this page to show the above result and make this sentence blue.)

Notes:


Top of file

Revised 12/15/2019 21:30.

Questions, suggestions or comments: James Brink