/[pcre]/code/trunk/132html
ViewVC logotype

Diff of /code/trunk/132html

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

code/trunk/maintain/132html revision 97 by ph10, Mon Mar 5 12:36:47 2007 UTC code/trunk/132html revision 461 by ph10, Mon Oct 5 10:59:35 2009 UTC
# Line 24  if ($inpara) Line 24  if ($inpara)
24    {    {
25    print TEMP "</PRE>\n" if ($inpre);    print TEMP "</PRE>\n" if ($inpre);
26    print TEMP "</P>\n";    print TEMP "</P>\n";
27    }    }
28  $inpara = $inpre = 0;  $inpara = $inpre = 0;
29  $wrotetext = 0;  $wrotetext = 0;
30  }  }
# Line 34  $wrotetext = 0; Line 34  $wrotetext = 0;
34  sub new_para {  sub new_para {
35  &end_para();  &end_para();
36  print TEMP "<P>\n";  print TEMP "<P>\n";
37  $inpara = 1;  $inpara = 1;
38  }  }
39    
40    
41  # Main program  # Main program
42    
43    $innf = 0;
44  $inpara = 0;  $inpara = 0;
45  $inpre = 0;  $inpre = 0;
46  $wrotetext = 0;  $wrotetext = 0;
# Line 48  $ref = 1; Line 49  $ref = 1;
49    
50  while ($#ARGV >= 0 && $ARGV[0] =~ /^-/)  while ($#ARGV >= 0 && $ARGV[0] =~ /^-/)
51    {    {
52    $toc = 1 if $ARGV[0] eq "-toc";    $toc = 1 if $ARGV[0] eq "-toc";
53    shift;    shift;
54    }    }
55    
56  # Initial output to STDOUT  # Initial output to STDOUT
57    
# Line 64  print < Line 65  print <
65  <p>  <p>
66  Return to the <a href="index.html">PCRE index page</a>.  Return to the <a href="index.html">PCRE index page</a>.
67  </p>  </p>
68  <p>  <p>
69  This page is part of the PCRE HTML documentation. It was generated automatically  This page is part of the PCRE HTML documentation. It was generated automatically
70  from the original man page. If there is any nonsense in it, please consult the  from the original man page. If there is any nonsense in it, please consult the
71  man page, in case the conversion went wrong.  man page, in case the conversion went wrong.
72  <br>  <br>
73  End  End
74    
75  print "<ul>\n" if ($toc);  print "<ul>\n" if ($toc);
# Line 77  open(TEMP, ">/tmp/$$") || die "Can't ope Line 78  open(TEMP, ">/tmp/$$") || die "Can't ope
78    
79  while (<STDIN>)  while (<STDIN>)
80    {    {
81    # Handle lines beginning with a dot    # Handle lines beginning with a dot
82    
83    if (/^\./)    if (/^\./)
84      {      {
85      if (/^\.br/)      # Some of the PCRE man pages used to contain instances of .br. However,
86        # they should have all been removed because they cause trouble in some
87        # (other) automated systems that translate man pages to HTML. Complain if
88        # we find .br or .in (another macro that is deprecated).
89    
90        if (/^\.br/ || /^\.in/)
91          {
92          print STDERR "\n*** Deprecated macro encountered - rewrite needed\n";
93          print STDERR "*** $_\n";
94          die "*** Processing abandoned\n";
95          }
96    
97        # Instead of .br, relevent "literal" sections are enclosed in .nf/.fi.
98    
99        elsif (/^\.nf/)
100          {
101          $innf = 1;
102          }
103    
104        elsif (/^\.fi/)
105        {        {
106        print TEMP "<br>\n" if $wrotetext;        $innf = 0;
107        }        }
108    
109      # Handling .sp is subtle. If it is inside a literal section, do nothing if      # Handling .sp is subtle. If it is inside a literal section, do nothing if
110      # the next line is a non literal text line; similarly, if not inside a      # the next line is a non literal text line; similarly, if not inside a
111      # literal section, do nothing if a literal follows. The point being that      # literal section, do nothing if a literal follows. The point being that
112      # the <pre> and </pre> that delimit literal sections will do the spacing.      # the <pre> and </pre> that delimit literal sections will do the spacing.
113      # Always skip if no previous output.      # Always skip if no previous output.
114    
115      elsif (/^\.sp/)      elsif (/^\.sp/)
116        {        {
117        if ($wrotetext)        if ($wrotetext)
# Line 99  while () Line 119  while ()
119          $_ = <STDIN>;          $_ = <STDIN>;
120          if ($inpre)          if ($inpre)
121            {            {
122            print TEMP "\n" if (/^[\s.]/);            print TEMP "\n" if (/^[\s.]/);
123            }            }
124          else          else
125            {            {
126            print TEMP "<br>\n<br>\n" if (!/^[\s.]/);            print TEMP "<br>\n<br>\n" if (!/^[\s.]/);
127            }            }
128          redo;    # Now process the lookahead line we just read          redo;    # Now process the lookahead line we just read
129          }          }
130        }        }
131      elsif (/^\.TP/ || /^\.PP/ || /^\.P/)      elsif (/^\.TP/ || /^\.PP/ || /^\.P/)
132        {        {
133        &new_para();        &new_para();
134        }        }
135      elsif (/^\.SH\s*("?)(.*)\1/)      elsif (/^\.SH\s*("?)(.*)\1/)
136        {        {
137        # Ignore the NAME section        # Ignore the NAME section
# Line 119  while () Line 139  while ()
139          {          {
140          <STDIN>;          <STDIN>;
141          next;          next;
142          }          }
143    
144        &end_para();        &end_para();
145        my($title) = &do_line($2);        my($title) = &do_line($2);
146        if ($toc)        if ($toc)
147          {          {
148          printf("<li><a name=\"TOC%d\" href=\"#SEC%d\">$title</a>\n",          printf("<li><a name=\"TOC%d\" href=\"#SEC%d\">$title</a>\n",
149            $ref, $ref);            $ref, $ref);
150          printf TEMP ("<br><a name=\"SEC%d\" href=\"#TOC1\">$title</a><br>\n",          printf TEMP ("<br><a name=\"SEC%d\" href=\"#TOC1\">$title</a><br>\n",
151            $ref, $ref);            $ref, $ref);
152          $ref++;          $ref++;
153          }          }
154        else        else
155          {          {
156          print TEMP "<br><b>\n$title\n</b><br>\n";          print TEMP "<br><b>\n$title\n</b><br>\n";
157          }          }
158        }        }
159      elsif (/^\.SS\s*("?)(.*)\1/)      elsif (/^\.SS\s*("?)(.*)\1/)
160        {        {
161        &end_para();        &end_para();
162        my($title) = &do_line($2);        my($title) = &do_line($2);
163        print TEMP "<br><b>\n$title\n</b><br>\n";        print TEMP "<br><b>\n$title\n</b><br>\n";
164        }        }
165      elsif (/^\.B\s*(.*)/)      elsif (/^\.B\s*(.*)/)
166        {        {
167        &new_para() if (!$inpara);        &new_para() if (!$inpara);
168        $_ = &do_line($1);        $_ = &do_line($1);
169        s/"(.*?)"/$1/g;        s/"(.*?)"/$1/g;
170        print TEMP "<b>$_</b>\n";        print TEMP "<b>$_</b>\n";
171        $wrotetext = 1;        $wrotetext = 1;
172        }        }
173      elsif (/^\.I\s*(.*)/)      elsif (/^\.I\s*(.*)/)
174        {        {
175        &new_para() if (!$inpara);        &new_para() if (!$inpara);
176        $_ = &do_line($1);        $_ = &do_line($1);
177        s/"(.*?)"/$1/g;        s/"(.*?)"/$1/g;
178        print TEMP "<i>$_</i>\n";        print TEMP "<i>$_</i>\n";
179        $wrotetext = 1;        $wrotetext = 1;
180        }        }
181    
182      # A comment that starts "HREF" takes the next line as a name that      # A comment that starts "HREF" takes the next line as a name that
183      # is turned into a hyperlink, using the text given, which might be      # is turned into a hyperlink, using the text given, which might be
184      # in a special font. If it ends in () or (digits) or punctuation, they      # in a special font. If it ends in () or (digits) or punctuation, they
185      # aren't part of the link.      # aren't part of the link.
186    
187      elsif (/^\.\\"\s*HREF/)      elsif (/^\.\\"\s*HREF/)
188        {        {
189        $_=<STDIN>;        $_=<STDIN>;
190        chomp;        chomp;
191        $_ = &do_line($_);        $_ = &do_line($_);
192        $_ =~ s/\s+$//;        $_ =~ s/\s+$//;
193        $_ =~ /^(?:<.>)?([^<(]+)(?:\(\))?(?:<\/.>)?(?:\(\d+\))?[.,;:]?$/;        $_ =~ /^(?:<.>)?([^<(]+)(?:\(\))?(?:<\/.>)?(?:\(\d+\))?[.,;:]?$/;
194        print TEMP "<a href=\"$1.html\">$_</a>\n";        print TEMP "<a href=\"$1.html\">$_</a>\n";
195        }        }
196    
197      # A comment that starts "HTML" inserts literal HTML      # A comment that starts "HTML" inserts literal HTML
198    
199      elsif (/^\.\\"\s*HTML\s*(.*)/)      elsif (/^\.\\"\s*HTML\s*(.*)/)
200        {        {
201        print TEMP $1;        print TEMP $1;
202        }        }
203    
204      # A comment that starts < inserts that HTML at the end of the      # A comment that starts < inserts that HTML at the end of the
205      # *next* input line - so as not to get a newline between them.      # *next* input line - so as not to get a newline between them.
206    
207      elsif (/^\.\\"\s*(<.*>)/)      elsif (/^\.\\"\s*(<.*>)/)
208        {        {
209        my($markup) = $1;        my($markup) = $1;
210        $_=<STDIN>;        $_=<STDIN>;
211        chomp;        chomp;
212        $_ = &do_line($_);        $_ = &do_line($_);
213        $_ =~ s/\s+$//;        $_ =~ s/\s+$//;
214        print TEMP "$_$markup\n";        print TEMP "$_$markup\n";
215        }        }
216    
217      # A comment that starts JOIN joins the next two lines together, with one      # A comment that starts JOIN joins the next two lines together, with one
218      # space between them. Then that line is processed. This is used in some      # space between them. Then that line is processed. This is used in some
219      # displays where two lines are needed for the "man" version. JOINSH works      # displays where two lines are needed for the "man" version. JOINSH works
220      # the same, except that it assumes this is a shell command, so removes      # the same, except that it assumes this is a shell command, so removes
221      # continuation backslashes.      # continuation backslashes.
222    
223      elsif (/^\.\\"\s*JOIN(SH)?/)      elsif (/^\.\\"\s*JOIN(SH)?/)
224        {        {
225        my($one,$two);        my($one,$two);
# Line 210  while () Line 230  while ()
230        $two =~ s/^\s+//;        $two =~ s/^\s+//;
231        $_ = "$one $two";        $_ = "$one $two";
232        redo;            # Process the joined lines        redo;            # Process the joined lines
233        }        }
234    
235        # .EX/.EE are used in the pcredemo page to bracket the entire program,
236        # which is unmodified except for turning backslash into "\e".
237    
238        elsif (/^\.EX\s*$/)
239          {
240          print TEMP "<PRE>\n";
241          while (<STDIN>)
242            {
243            last if /^\.EE\s*$/;
244            s/\\e/\\/g;
245            s/&/&amp;/g;
246            s/</&lt;/g;
247            s/>/&gt;/g;
248            print TEMP;
249            }
250          }
251    
252      # Ignore anything not recognized      # Ignore anything not recognized
253    
254      next;      next;
255      }      }
256    
257    # Line does not begin with a dot. Replace blank lines with new paragraphs    # Line does not begin with a dot. Replace blank lines with new paragraphs
258    
259    if (/^\s*$/)    if (/^\s*$/)
260      {      {
261      &end_para() if ($wrotetext);      &end_para() if ($wrotetext);
262      next;      next;
263      }      }
264    
265    # Convert fonts changes and output an ordinary line. Ensure that indented    # Convert fonts changes and output an ordinary line. Ensure that indented
266    # lines are marked as literal.    # lines are marked as literal.
267    
268    $_ = &do_line($_);    $_ = &do_line($_);
269    &new_para() if (!$inpara);    &new_para() if (!$inpara);
270    
271    if (/^\s/)    if (/^\s/)
272      {      {
273      if (!$inpre)      if (!$inpre)
274        {        {
275        print TEMP "<pre>\n";        print TEMP "<pre>\n";
276        $inpre = 1;        $inpre = 1;
277        }        }
278      }      }
279    elsif ($inpre)    elsif ($inpre)
280      {      {
281      print TEMP "</pre>\n";      print TEMP "</pre>\n";
282      $inpre = 0;      $inpre = 0;
283      }      }
284    
285    print TEMP;    # Add <br> to the end of a non-literal line if we are within .nf/.fi
286    $wrotetext = 1;  
287    }    $_ .= "<br>\n" if (!$inpre && $innf);
288    
289      print TEMP;
290      $wrotetext = 1;
291      }
292    
293  # The TOC, if present, will have been written - terminate it  # The TOC, if present, will have been written - terminate it
294    
295  print "</ul>\n" if ($toc);  print "</ul>\n" if ($toc);
# Line 257  print "\n" if ($toc); Line 298  print "\n" if ($toc);
298    
299  close(TEMP);  close(TEMP);
300  open(TEMP, "/tmp/$$") || die "Can't open /tmp/$$ for input\n";  open(TEMP, "/tmp/$$") || die "Can't open /tmp/$$ for input\n";
301    
302  print while (<TEMP>);  print while (<TEMP>);
303    
304  print <<End ;  print <<End ;

Legend:
Removed from v.97  
changed lines
  Added in v.461

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12