summaryrefslogtreecommitdiff
path: root/web/noweb/contrib/partingr/mm2tex
blob: 79fd7a9c3db3f691d3197d67c60d441172bd7f38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/common/bin/perl
do "TeXthings" || die "$!";
print "\\input nwmac ";
while(<>)
{
  if(/^@begin code (.*)$/)    { print "\\nwbegincode{$1}"; $code=1; $text=5; }
  elsif(/^@end code/)         { print "\\nwendcode{}\\filbreak$defing"; $code=0; }
  elsif(/^@begin docs (.*)$/) { print "\\nwbegindocs{$1}"; $text=0; $textmode=0; }
  elsif(/^@end docs/)         { print "\\nwenddocs{}"; }
  elsif(/^@text (.*)$/)
  { $text+=length $1;
    if($code==1)       { print  &escapebslash($1); }
    elsif($quoting==1) { print  &TeXliteral($1); }
    else               { print  $1; }
    $textmode=1 if $text>0;
  }
  elsif(/^@nl$/)
  { if($code==0)
    { if($text==0)
        { if($textmode==1) { print  "\\nwdocspar\\noindent\n"; }
          else             { print  "\n"; }
          $textmode=1; $text=1;
        }
      else         { print  "\n"; }
    }
    elsif($quoting) { print  "\\nwnewline"; }
    else { if($text>0) { print  "\n"; } }
  }
  elsif(/^@defn (.*)$/)
  { $name=$1;
    print  "\\moddef{",&convquotes($name),"}\\",@defns{$name},"endmoddef";
    @defns{$name}='plus';
  }
  elsif(/^@use (.*)$/)
   { print  "\\LA{}",&convquotes($1),"\\RA{}"; }
  elsif(/^@quote$/)           { $quoting=1; print  "{\\tt "; }
  elsif(/^@endquote$/)        { $quoting=0; print  "}"; $textmode=0; }
  elsif(/^@file (.*)$/)       { $filename=$1; print  "\\filename{$filename}"; }
  elsif(/^@literal (.*)$/)    { print  "$1"; }
}
print "\\bye\n";