implement IMF; # HTML implementation # Ed Bacher, evb@lucent.com include "sys.m"; sys: Sys; print, fprint, sprint, stat: import sys; stderr: ref sys->FD; # declares regex: Regex include "regexutils.m"; regexu: RegexUtils; match, match_mult, sub, sub_re, subg, subg_re: import regexu; include "daytime.m"; daytime: Daytime; include "imf.m"; TOP = ""; BOTTOM = ""; # for target-specific character processing specials(text: string): string { return text; } init() { if (sys == nil) sys = load Sys Sys->PATH; stderr = sys->fildes(2); daytime = load Daytime Daytime->PATH; if (daytime == nil) { fprint(stderr, "error loading Daytime from %s: %r\n", Daytime->PATH); return; } # HTML header information TOP += "\n\n"; # NOTE: add this string (or similar) to TOP to force browser to use unicode character set # (not all browsers will do it) # "\n" # do BOTTOM BOTTOM += "\n\n"; # get time information now := daytime->time(); mtime := now; (ntoks, nowlist) := sys->tokenize(now, " "); date_mdy, year: string; if (ntoks == 6) { month := hd tl nowlist; day := hd tl tl nowlist; yr := hd tl tl tl tl tl nowlist; year = yr; date_mdy = month + ". " + day + ", " + yr; } # special characters emdash_tag = " — "; space_tag = " "; zero_tag = ""; lt_tag = "<"; gt_tag = ">"; # example tag array, ex, exl (left), and ex0 (0 margin) extag = array[] of { "", # nil to bump up index ".ex", ".exl", ".ex0", }; notag = array[] of { "", "", "" }; # blocktags (not needed for html) blocktags = array[] of {""}; # tag definitions: general form is: # ".tag", "", "", # tags = array[] of { # basic paragraph tags ".p", "\n

\n", "\n

\n", ".pin", "\n

\n", "\n

\n", ".p0", "\n

\n", "\n

\n", # structural font tags ".v", # variable "", "", ".em", # emphasis (instead of .i) "", "", ".strong", # strong "", "", ".m", # menu items "", "", ".opt", # command options "", "", ".n", # name (misc. names) "", "", ".url", # URLs "", "", ".ref", # references (books, etc.) "", "", ".l", # literal "", "", ".in", # user input "", "", ".ip", # user input "", "", ".file", # filenames "", "", ".fn", # function names "", "", ".cmd", # command names "", "", # specific (physical) font changes ".i", "", "", ".b", "", "", ".c", "", "", ".cb", "", "", ".ci", "", "", # structural headings for man pages # like .SH (section (or sub) head) and .SS (secondary subhead) of man ".sh", "\n

", "

\n", ".ss", "\n

", "

\n", # .h for general manpage heading ".h", "\n

", "

\n", # .ht for manpage head at top of page -- manpage(section) ".ht", "\n

", "

\n", # .hl for literal heading (function prototypes as headings) ".hl", "\n

", "

\n", # numbered headings (these are kind of physical, since they are basically HTML) ".h1", "\n

", "

\n", ".h2", "\n

", "

\n", ".h2n", "\n

", "

\n", ".h3", "\n

", "

\n", ".h4", "\n

", "

\n", # indented example ".ex", "\n
\n", "
\n", # left justified example ".exl", "
\n", "
\n", # 0 indent example (no difference for HTML) ".ex0", "
\n", "
\n", # simplified table ".tab", "", "", # table on left margin ".table", "

\n", "\n
\n", # table centered ".tablecenter", "

\n", "\n
\n", # table row ".tr", "\n", "\n\n", # table data (regular plus shortcuts for literal, name, variable, menu item) ".td", "", "\n\n", ".tdl", "\n", "\n\n", ".tdv", "\n", "\n\n", ".tdn", "\n", "\n", ".tdm", "\n", "\n\n", # ordered list ".ol", "
    \n", "\n
\n", # unordered list ".ul", "
    \n", "\n
\n", # unordered list item ".uli", "\n
  • \n", "", # ordered list (first) item ".oli1", "\n
  • \n", "", # ordered list item ".oli", "\n
  • \n", "", # punctuation marks ".", ".\n", "", ",", ",\n", "", # included file ".include", "", "", # definition list ".dl", "

    \n", "\n
    \n", # definition list items (regular, literal, variable, name, menu item) dt, then dd (with

    after) ".dt", "

    \n", "\n
    ", ".dtl", "
    \n", "\n
    \n", ".dtv", "
    \n", "\n
    \n", ".dtn", "
    \n", "\n
    \n", ".dtm", "
    \n", "\n
    \n", # definition list definition ".dd", "
    \n", "

    \n", # NOTE ".note", "\n

    \nNOTE:\n

    \n", "\n
    \n", # cross reference (to man page) ".x", "\n\n", # comment (will appear in doc unless turned off with -C) ".com", "/***BEGIN ", " END***/", # hyperlink label ".label", "\n", # general link ".link", "\n", # image link ".img", "\n", # insert date information ".date", mtime, "", ".dateshort", date_mdy, "", ".year", year, "", # horizontal rule ".hr", "\n
    \n", "", # line break ".br", "\n
    \n", "", ".#", "", "", # HTML title ".title", "", "\n\n\n", # manual page name paragraph (under NAME section) ".name", "\n

    \n", "\n

    \n", }; }