Changeset 609ba11 in git for doc/doc2tex.pl


Ignore:
Timestamp:
Jul 9, 1999, 4:12:59 PM (25 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
34fbd934a748fec8c0dcc9325052eddde20bd10e
Parents:
63374c2a45ce7f0660de1047f95a58b4d23d5055
Message:
* use smallexample for examples


git-svn-id: file:///usr/local/Singular/svn/trunk@3254 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/doc2tex.pl

    r63374c r609ba11  
    11#!/usr/local/bin/perl
    2 # $Id: doc2tex.pl,v 1.4 1999-07-07 16:38:34 obachman Exp $
     2# $Id: doc2tex.pl,v 1.5 1999-07-09 14:12:47 obachman Exp $
    33###################################################################
    44#  Computer Algebra System SINGULAR
     
    292292        # break after $ex_length characters
    293293        $to_do = $_;
    294         while (length($to_do) > $ex_length)
     294        while (length($to_do) > $ex_length && $to_do =~ /\w/)
    295295        {
    296296          $done .= substr($to_do, 0, $ex_length)."\\\n   ";
     
    570570        {
    571571          print LDOC "\@strong{Example:}\n";
    572           print LDOC "\@example\n\@c example\n";
     572          print LDOC "\@smallexample\n\@c example\n";
    573573          print LDOC $example;
    574           print LDOC "\n\@c example\n\@end example\n";
     574          print LDOC "\n\@c example\n\@end smallexample\n";
    575575        }
    576576        OutRef(\*LDOC, $ref) if $ref;
     
    639639sub FormatInfoText
    640640{
    641   s/^\s*//; # remove whitespaces from beginning and end
    642   s/\s*$//;
    643   s/ +/ /g;  # replace double whitespeces by one
    644   &protect_texi; # protect texinfo special chars
    645   s/\n/\n\@*/g; # replace newline by forced newline
     641  my $length = shift;
     642  $length = 0 unless $length;
     643  # insert @* infront of all lines whose previous line is shorter than
     644  # 60 characters
     645  $_ = ' ' x $length . $_;
     646  if (/^(.*)\n/)
     647  {
     648    $_ .= "\n";
     649    my $pline;
     650    my $line;
     651    my $ptext = $_;
     652    my $text = '';
     653    while ($ptext =~ /(.*)\n/g)
     654    {
     655      $line = $1;
     656      $text .= '@*'
     657        if ($line =~ /\w/ && $pline =~ /\w/ &&
     658            ((length($pline) < 60) || $line =~ /^\s*\w\(.*?\)/));
     659      $line =~ s/\s*$//;
     660      $text .= "$line\n";
     661      $pline = $line;
     662    }
     663    $_ = $text;
     664  }
     665  s/\t/ /g;
     666  s/\n +/\n/g;
     667  s/\s*$//g;
     668  s/ +/ /g;  # replace double whitespaces by one
     669  s/\@\*\s*/\@\*/g;
     670  s/(\@[^\*])/\@$1/g; # escape @ signs, except @*
     671  s/{/\@{/g;
     672  s/}/\@}/g;
    646673}
    647674
     
    678705    if ($l_fun)
    679706    {
    680       print $FH "\@strong{$item}\n\@menu\n";
     707      print $FH "\@strong{$item:}\n\@menu\n";
    681708    }
    682709    else
    683710    {
    684       print $FH "\@item \@strong{$item}\n\@table \@asis\n";
     711      print $FH "\@item \@strong{$item:}\n\@table \@asis\n";
    685712    }
    686713    while ($text =~ /(.*\n)/g)
     
    725752  {
    726753    # just print the text
    727     &FormatInfoText;
     754    FormatInfoText(length($item) + 1);
    728755    # if functions are in text, then make it in code
    729756    s/(\w+\(.*?\))/\@code{$1}/g
     
    741768  s/^[;\s]*//;
    742769  s/\n/ /g;
    743   &FormatInfoText;
     770  FormatInfoText();
    744771 
    745772  if ($l_fun)
     
    790817  # erase EXAMPLE, echo and pause statements
    791818  $example =~ s/"EXAMPLE.*"[^;]*;//g;
    792   $example =~ s/echo[^;\n]*;//g;
    793   $example =~ s/pause\(.*?\)[^;]*;//g;
     819  $example .= "\n";
     820  my ($mexample, $line);
     821  while ($example =~ m/(.*)\n/g)
     822  {
     823    $line = $1;
     824    $line =~ s|echo[^;]*;||g if $line !~ m|(.*)//(.*)echo[^;]*;|;
     825    $line =~ s|pause\(.*?\)[^;]*;||g if $line !~ m|(.*)//(.*)pause\(.*?\)[^;]*;|;
     826    $mexample .= "$line\n";
     827  }
     828  $example = $mexample;
    794829 
    795830  # prepend LIB command
Note: See TracChangeset for help on using the changeset viewer.