;;; menus.mhtml: -*- Meta-HTML -*-  Macros make menus easier.
;;;
;;;  Copyright (c) 1996 Brian J. Fox
;;;  Author: Brian J. Fox (bfox@ai.mit.edu) Sat Feb 10 16:13:30 1996.

<defmacro menu whitespace=delete>
  <in-package menu>
    <set-var lines[]=<prog %body>>
    <set-var i[]=<symbol-info lines> i=0>
    <set-var nobr=<match "%1" "nobr=true" caseless=true>>
    <small-caps upper="+2" lower="+0" other="+2">
      <when <get-var nobr>>
	<nobr><b>%0</b></nobr>
      </when>
      <when <not <get-var nobr>>>
	<b>%0</b>
      </when>
    </small-caps>
    <br>
    <ul>
      <while <lt i i[1]>>
	<set-var
	  item=<get-var lines[i]>
	  link=<match <get-var item> ":.*$" action=extract>
	  item=<match <get-var item> ":.*$" action=delete>
	  link=<match <get-var link> "^:[ \t]*" action=delete>>
	<if <not <match <substring <get-var link> 0 4> "http">>
	    <if <not <match <substring <get-var link> 0 1> "/">>
		<set-var link =
		  <concat <get-var mhtml::url-to-dir>/<get-var link>>>
	      <set-var link = <concat <get-var mhtml::http-prefix link>>>>>
	<li> <a href="<get-var link>">
	  <if <get-var nobr>
	      <concat <nobr><b><get-var item></b></nobr>>
	    <concat <b><get-var item></b>>>
	</a>
	<p>
	<increment i>
      </while>
    </ul>
  </in-package>
</defmacro>
