/[webpac]/openisis/0.9.9e/uti/mikiman
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /openisis/0.9.9e/uti/mikiman

Parent Directory Parent Directory | Revision Log Revision Log


Revision 604 - (hide annotations)
Mon Dec 27 21:49:01 2004 UTC (19 years, 4 months ago) by dpavlin
File size: 2471 byte(s)
import of new openisis release, 0.9.9e

1 dpavlin 604 #!/usr/bin/perl
2     # $Id: mikiman,v 1.4 2004/06/15 12:06:08 kripke Exp $
3    
4     # convert a http://openisis.org/Doc/MikiDoc to manpage
5     # uti/mikiman <doc/CmdLine.txt |nroff -man|less
6     #
7     # first section is always assumed NAME
8     # document should have standard * sections
9     # SYNOPSIS DESCRIPTION OPTIONS RETURN VALUES ENVIRONMENT FILES
10     # EXAMPLES DIAGNOSTICS ERRORS SEE ALSO STANDARDS BUGS
11     # SECURITY CONSIDERATIONS
12     #
13     # ; is a comment line. a first line starting ;man sets textheading and man mode
14     # $ (code mode) toggles .nf - .fi (nofill - fill)
15     # * is .SH
16     # - is .TP or .HP in man mode, else .IP \(bu
17     # *foo* is .B
18     # _foo_ is .IR
19     #
20     # c.f. man groff_man
21     # c.f. http://www.schweikhardt.net/man_page_howto.html
22     # c.f. http://cm.bell-labs.com/sys/doc/troff.html
23     #
24     # TODO: should get .TH defaults from .man file
25     # TODO: use tbl for ||| constructs
26    
27     use POSIX qw(strftime);
28    
29     $mode = 'p'; # plain code list table
30     $noman = 1;
31     # if first line has man instructions, treat as real manpage
32     # else use "documentation" mode
33     $_ = <STDIN>;
34     if (/^;man/) {
35     chomp;
36     ($foo, $title, $section, $footmid, $footleft, $headmid) = split /\t/;
37     $noman = 0;
38     $_ = <STDIN>;
39     } else {
40     ($title, $section) = ($ARGV[0] || 'malete', $ARGV[1] || 7);
41     }
42     $footmid ||= gmtime;
43     $footleft ||= 'Malete 0.9.9x';
44     $headmid ||= 'Malete database';
45     print ".TH \"$title\" \"$section\" \"$footmid\" \"$footleft\" \"$headmid\"
46     .SH NAME
47     ";
48    
49     do {{
50     ($mark, $line) = /(.)\t?(.*)/;
51     if ('c' eq $mode) { # in code mode
52     if ('$' ne $mark) {
53     print $_;
54     } else {
55     $mode = 'p';
56     print ".fi\n\n";
57     }
58     next;
59     }
60     $pre = '';
61     if ('l' eq $mode && $mark !~ /[->\t]/) { # end list
62     print ".P\n";
63     $mode = 'p';
64     }
65     if ('*' eq $mark) { # section heading
66     $pre = '.SH ';
67     $line = uc($line);
68     } elsif ('-' eq $mark) { # start list entry
69     if ( $line =~ /^--/ ) { print "\n\\l'|40'\n.P\n"; next; }
70     $pre = $noman ? ".IP \\(bu 4\n" # noice bullets in noman's land
71     : 40 > length($line) ? ".TP\n.I " : ".HP\n";
72     $mode = 'l';
73     } elsif ('$' eq $mark) {
74     $pre = '.nf';
75     $mode = 'c';
76     } elsif ('>' eq $mark) { # link
77     $pre = '.I ';
78     if (2 == (($tgt,$name) = split(/\t/, $line))) {
79     $line = "$name (\\(-> $tgt)"
80     } else {
81     $pre .= '\\(-> ';
82     }
83     } elsif (';' eq $mark) { # comment
84     next;
85     } elsif ("\t" eq $mark) { # nothing
86     } else {
87     chomp($line = $_);
88     }
89     $line =~ s/^\./\\&./; # prepend the "zero width filler"
90     $line =~ s/_(\S+)_/\\fI$1\\fR/g;
91     $line =~ s/\*(\S+)\*/\\fB$1\\fR/g;
92     print $pre, $line, "\n";
93     }} while (<STDIN>);

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26