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", "\n", "\n
\n", ".pin", "\n\n", ".p0", "\n\n", "\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", # left justified example ".exl", "\n", "
\n", "\n", # 0 indent example (no difference for HTML) ".ex0", "
\n", "\n", # simplified table ".tab", "", "", # table on left margin ".table", "
\n", "\n
\n", "\n
after) ".dt", "
\n", "\n
\n", "\n
\n", # NOTE ".note", "\n
/***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", "\n
\n", }; }