| @@ -16,6 +16,8 @@ include "daytime.m"; · 15 unmodified lines |
| 16 | include "string.m"; | 16 | include "string.m"; |
| 17 | str: String; | 17 | str: String; |
| 18 | | 18 | |
| | 19 | include "arg.m"; |
| | 20 | |
| 19 | Man2html: module | 21 | Man2html: module |
| 20 | { | 22 | { |
| 21 | init: fn(ctxt: ref Draw->Context, args: list of string); | 23 | init: fn(ctxt: ref Draw->Context, args: list of string); |
| @@ -315,10 +317,12 @@ Global: adt { · 293 unmodified lines |
| 315 | softp: fn(g: self ref Global): string; | 317 | softp: fn(g: self ref Global): string; |
| 316 | }; | 318 | }; |
| 317 | | 319 | |
| | 320 | header := "<HTML><HEAD>"; |
| | 321 | trailer := "</BODY></HTML>"; |
| 318 | | 322 | |
| 319 | usage() | 323 | usage() |
| 320 | { | 324 | { |
| 321 | sys->fprint(stderr, "Usage: man2html file [section]\n"); | 325 | sys->fprint(stderr, "Usage: man2html [-h header] [-t trailer] file [section]\n"); |
| 322 | raise "fail:usage"; | 326 | raise "fail:usage"; |
| 323 | } | 327 | } |
| 324 | | 328 | |
| @@ -329,11 +333,20 @@ init(nil: ref Draw->Context, args: list of string) · 4 unmodified lines |
| 329 | stderr = sys->fildes(2); | 333 | stderr = sys->fildes(2); |
| 330 | str = load String String->PATH; | 334 | str = load String String->PATH; |
| 331 | dt = load Daytime Daytime->PATH; | 335 | dt = load Daytime Daytime->PATH; |
| 332 | g := Global_init(); | 336 | arg := load Arg Arg->PATH; |
| 333 | if(args != nil) | 337 | arg->init(args); |
| 334 | args = tl args; | 338 | arg->setusage("man2html [-h header] [-t trailer] file [section]"); |
| | 339 | while((o := arg->opt()) != 0) |
| | 340 | case o { |
| | 341 | 'h' => header = arg->earg(); |
| | 342 | 't' => trailer = arg->earg(); |
| | 343 | * => arg->usage(); |
| | 344 | } |
| | 345 | args = arg->argv(); |
| 335 | if(args == nil) | 346 | if(args == nil) |
| 336 | usage(); | 347 | arg->usage(); |
| | 348 | arg = nil; |
| | 349 | g := Global_init(); |
| 337 | page := hd args; | 350 | page := hd args; |
| 338 | args = tl args; | 351 | args = tl args; |
| 339 | section := "1"; | 352 | section := "1"; |
| @@ -341,6 +354,7 @@ init(nil: ref Draw->Context, args: list of string) · 1 unmodified line |
| 341 | section = hd args; | 354 | section = hd args; |
| 342 | hit := Hit ("", "man", section, page); | 355 | hit := Hit ("", "man", section, page); |
| 343 | domanpage(g, hit); | 356 | domanpage(g, hit); |
| | 357 | g.print(trailer+"\n"); |
| 344 | g.bufio->g.bout.flush(); | 358 | g.bufio->g.bout.flush(); |
| 345 | } | 359 | } |
| 346 | | 360 | |
| @@ -1342,7 +1356,7 @@ title(g: ref Global, t: string, search: int) · 995 unmodified lines |
| 1342 | { | 1356 | { |
| 1343 | if(search) | 1357 | if(search) |
| 1344 | ; # not yet used | 1358 | ; # not yet used |
| 1345 | g.print("<HTML><HEAD>\n"); | 1359 | g.print(header+"\n"); |
| 1346 | g.print(sprint("<TITLE>Inferno's %s</TITLE>\n", demark(t))); | 1360 | g.print(sprint("<TITLE>Inferno's %s</TITLE>\n", demark(t))); |
| 1347 | g.print("</HEAD>\n"); | 1361 | g.print("</HEAD>\n"); |
| 1348 | g.print("<BODY bgcolor=\"#FFFFFF\">\n"); | 1362 | g.print("<BODY bgcolor=\"#FFFFFF\">\n"); |