The R Project SVN R

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2195 hornik 1
#! @PERL@
7357 hornik 2
#
3
# ${R_HOME}/bin/Sd2Rd for converting S documentation to Rd format
2195 hornik 4
 
12256 pd 5
# Copyright (C) 1997-2001 The R Core Development Team
2195 hornik 6
#
7
# This document is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2, or (at your option)
10
# any later version.
11
#
12
# This program is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
# General Public License for more details.
16
#
17
# A copy of the GNU General Public License is available via WWW at
18
# http://www.gnu.org/copyleft/gpl.html.  You can also obtain it by
5458 ripley 19
# writing to the Free Software Foundation, Inc., 59 Temple Place,
20
# Suite 330, Boston, MA  02111-1307  USA.
2195 hornik 21
 
7357 hornik 22
use Getopt::Long;
11515 hornik 23
use R::Utils;
2195 hornik 24
 
14558 ripley 25
my $revision = ' $Revision: 1.21 $ ';
7357 hornik 26
my $version;
27
my $name;
2195 hornik 28
 
7357 hornik 29
$revision =~ / ([\d\.]*) /;
30
$version = $1;
31
($name = $0) =~ s|.*/||;
2195 hornik 32
 
7357 hornik 33
sub usage {
34
  print STDERR <<END;
8245 leisch 35
Usage: R CMD Sd2Rd [options] FILE
2195 hornik 36
 
7357 hornik 37
Convert S documentation in FILE to R documentation format.
38
 
39
Options:
40
  -h, --help		print short help message and exit
41
  -v, --version		print version info and exit
42
  -n			render examples non-executable by wrapping them
43
			into a \\dontrun{} environment
12256 pd 44
  -x			(S3 docs) interpret all single-quoted names 
45
                        as code names
7357 hornik 46
 
10633 hornik 47
Email bug reports to <r-bugs\@r-project.org>.
7357 hornik 48
END
49
  exit 0; 
50
}
51
 
11515 hornik 52
@knownoptions = ("v|version", "h|help", "n", "x");
53
GetOptions(@knownoptions) || &usage();
54
&R_version($name, $version) if $opt_v;
7357 hornik 55
&usage() if $opt_h;
56
 
12256 pd 57
@lines = <>;
58
## peek at the first line of the file, then dispatch to
59
## S3-style (nroff) or S4-style (SGML spec).
60
if(@lines[0] =~ /^<!doctype/) { doS4(); } else { doS3(); }
61
exit 0;
62
 
63
sub doS3 {
13792 pd 64
  $braceLevel = 0;
65
  $inReferences = 0;
66
  $inVerbatim = 0;
67
  $inSeeAlso = 0;
68
  $inCode = 0;
69
  $isDataSet = 0;
70
  $doprint = 1;
71
  $needArg = 1;
72
  $needVal = 0;
73
  $underlineNext = 0;
74
  $output = "";
7357 hornik 75
 
12256 pd 76
  foreach $_ (@lines) {
77
    chop;
78
    &substitute unless /^\./;
79
    my @word = split;
2195 hornik 80
 
12256 pd 81
    if (/^\s*$/) { &output("\n"); }
82
    if (/^[^.]/) { 
83
      if ($underlineNext) {
84
	$_ = "\\emph{" . $_ ."}";
85
	$underlineNext = 0;
86
      }
87
      &output($_);
88
    }
10338 hornik 89
 
12256 pd 90
    ## Added by BDR 1998-08-27
91
    if (/^\.\\\"/o) {
92
      s/^\.\\\"/%/;
93
      &output($_);
94
    }
95
    ## End
96
 
97
    if (/^\.BG D/) {
98
      $isDataSet = 1;
99
    }
100
    if (/^\.AG/) {
101
      if ($isDataSet) {
102
	if ($needArg) {
103
	  &section(1, "\\describe\{");
104
	  $needArg = 0;
105
	}
106
	$arg = $_;
107
	$arg =~ s/^\.AG\s//;
108
	&section(2, "\\item\{\\code\{$arg\}\}\{");
109
      } else {
110
	if ($needArg) {
111
	  &section(0, "\\arguments\{");
112
	  $needArg = 0;
113
	}
114
	$arg = $_;
115
	$arg =~ s/^\.AG\s//;
116
	&section(1, "\\item\{$arg\}\{");
10338 hornik 117
      }
12256 pd 118
    }
119
    if (/^\.CS/) {
120
      &section(0, "\\usage\{");
121
      $inVerbatim = 1;
122
    }
123
    if (/^\.DN/) { &section(0, "\\description\{"); }
124
    if (/^\.DT/) { &section(0, "\\details\{"); }
125
    if (/^\.EX/) {
126
      if ($opt_n) {
127
	&section(1, "\\examples\{\\dontrun\{");
128
      } else {
129
	&section(0, "\\examples\{");
10338 hornik 130
      }
12256 pd 131
      $inVerbatim = 1;
2195 hornik 132
    }
12256 pd 133
    if (/^\.FN/) {
134
      unless($fun) { $fun = $word[1]; }
135
      push(@aliases, $word[1]);
2195 hornik 136
    }
12256 pd 137
    if (/^\.(IP|PP)/) { &output("\n"); }
138
    if (/^\.KW/) { 
139
      if ($braceLevel > 0) {
140
	&section(0, "");
141
	$braceLevel = 0;
142
      }
143
      if ($word[1] =~ /sysdata/) {
144
	&output("\\keyword\{datasets\}");
145
      } else {
146
	&output("\\keyword\{$word[1]\}");
147
      }
148
    }
149
    if (/^\.RC/) {
150
      if ($needVal) {
151
	$needVal = 0;	    
152
	&section(0, "\\value\{\n$output\n");
153
	$doprint = 1;
154
      }
155
      &section(1, "\\item\{" . join(" ", @word[1..$#word]) . "\}\{");
156
    }
157
    if (/^\.RT/) {
158
      $needVal = 1;
159
      $doprint = 0;
160
      $output = "";
161
    }
162
    if (/^\.SA/) {
163
      &section(0, "\\seealso\{");
164
      $inSeeAlso = 1;
165
    }
166
    if (/^\.SE/) { &section(0, "\\section\{Side Effects\}\{"); }
167
    if (/^\.SH/) {
168
      if ($word[1] =~ /REFERENCE/) {
169
	&section(0, "\\references\{");
170
	$inReferences = 1;
14558 ripley 171
      } elsif ($word[1] =~ /AUTHOR/) {
172
	&section(0, "\\author\{");
12256 pd 173
      } elsif ($word[1] =~ /NOTE/) {
174
	&section(0, "\\note\{");
175
      } elsif ($word[1] =~ /SOURCE/) {
176
	&section(0, "\\source\{");
177
	$inReferences = 1;
178
      } elsif ($word[1] =~ /SUMMARY/) {
179
	&section(0, "\\description\{");
14558 ripley 180
      } elsif ($word[1] =~ /WARNINGS/) {
181
	&section(0, "\\section{Warnings}\{");
182
      } elsif ($word[1] =~ /WARNING/) {
13792 pd 183
	&section(0, "\\section{Warning}\{");
12256 pd 184
      } elsif (join(" ", @word[1..2]) =~ /DATA DESCRIPTION/) {
185
	&section(0, "\\usage\{\ndata($fun)");
186
	&section(0, "\\format\{");
187
      } else {
188
	# This line may be of the form .SH "A B C"
189
	($tmp = join(" ", @word[1..$#word])) =~ s/\"(.*)\"/$1/;
190
	&section(0, "\\section\{$tmp\}\{");
191
      }
192
    }
14558 ripley 193
    if (/^\.sp/) {
194
      if($word[1] == 0) {
195
	output("\\cr")
196
      } else {
197
	output("\n")
198
      }
199
    }
12256 pd 200
    if (/^\.TL/) {
201
      print("\\name\{$fun\}\n");
202
      print("\\alias\{", join("\}\n\\alias\{", @aliases), "\}\n");
203
      &section(0, "\\title\{");
204
      $inVerbatim = 1;
205
    }
206
    if (/^\.WR/) {
2195 hornik 207
      &section(0, "");
12256 pd 208
      print("% Converted by $name version $version.\n");
2195 hornik 209
    }
12256 pd 210
    if (/^\.AO/) {
211
      output("Arguments for function \\code\{$word[1]()\} can also be");
212
      output("supplied to this function.");
3609 pd 213
    }
12256 pd 214
    if (/^\.GE/) {
215
      output("This is a generic function.");
216
      output("Functions with names beginning in \\code\{$fun.\} will be");
217
      output("methods for this function.");
218
      output("Classes with methods for this function include:");
2195 hornik 219
    }
12256 pd 220
    if (/^\.GR/) {
221
      output("Graphical parameters (see \\code\{\\link\{par\}\}) may also");
222
      output("be supplied as arguments to this function.");
223
    }
224
    if (/^\.ME/) {
225
      output("This function is a method for the generic function");
226
      output("\\code\{$word[1]()\} for class \\code\{\"$word[2]\"\}.");
227
      output("It can be invoked by calling \\code\{$word[1](x)\} for an");
228
      output("object \\code\{x\} of the appropriate class, or directly by");
229
      output("calling \\code\{$word[1].$word[2](x)\} regardless of the");
230
      output("class of the object.");
231
    }
232
    if (/^\.NA/) { output("Missing values (\\code\{NA\}s) are allowed."); }
233
    if (/^\.Tl/) {
234
      output("In addition, the high-level graphics control arguments");
235
      output("described under \\code\{\\link\{par\}\} and the arguments to");
236
      output("\\code\{\\link\{title\}\} may be supplied to this function.");
237
    }
238
    if (/^\.ul/) { $underlineNext = 1; }
239
    ## End
2195 hornik 240
  }
241
}
242
 
243
sub substitute {
244
  if (!$inVerbatim) {
245
    s/\{/\\\{/g;
246
    s/\}/\\\}/g;
10338 hornik 247
#    s/&/\\&/g; removed BDR 2000-02-10
248
    ## Added by BDR 1998-06-20
2195 hornik 249
    s/\\\(aa/'/g;		# extra ' for highlight matching
250
    s/\\\(em/--/g;		# em dash
251
    s/\\\(tm/ (TM) /g;		# Trademark
252
    s/\\\(mu/ x /g;		# multiply sign
253
    s/\\\(\*a/\alpha/g;		# greek
254
    s/\\\(\*b/\beta/g;
255
    s/\\\(\*e/\epsilon/g;
256
    s/\\\(\*l/\lambda/g;
257
    s/\\\(\*m/\mu/g;
258
    s/\\\(\*p/\pi/g;
259
    s/\\\(\*s/\sigma/g;
260
    ## End
261
  }
10217 pd 262
  s/\.\.\./\\dots/g;
2195 hornik 263
  s/\\fB/\\bold\{/g;
264
  s/\\fR/\}/g;
10338 hornik 265
  ## Added by BDR 1998-06-20
2195 hornik 266
  s/\\fI/\\emph\{/g;
267
  s/\\fP/\}/g;
268
  ## End
269
  s/\%/\\%/g;
270
  s/\\\.(.*)$/# $1)/g;
10439 hornik 271
  if($inCode && s/\'/\}/) {
272
    $inCode = 0;
273
  }
2195 hornik 274
  if ($inSeeAlso) {
275
    if ($opt_x) {
276
      s/\`?([\.\w]*\w+)\'?/\\code{\\link{$1}}/g;
277
    } else {
278
      s/\`([^\']*)\'/\\code{\\link{$1}}/g;
279
    }
280
  } elsif (!$inVerbatim) {
10439 hornik 281
    if(s/\`([^\']*)$/\\code\{$1/) {
282
      $inCode = 1;
283
    }
10338 hornik 284
    s/\`([^\']*)\'$/\\code{$1}/g;
285
    s/\`([^\']*)\'([^\'])/\\code{$1}$2/g;  
2195 hornik 286
  }
10338 hornik 287
  if ($inReferences) {
288
    s/([0-9])-([0-9])/$1--$2/g;
289
  }
2195 hornik 290
}
291
 
292
sub section {
7357 hornik 293
  my($level, $text) = @_;
2195 hornik 294
  $n = $braceLevel - $level;
7636 hornik 295
  print "\}" x $n, "\n" if ($n > 0);
2195 hornik 296
  if ($needVal) {
7636 hornik 297
    print("\\value\{\n$output\n\}\n");
2195 hornik 298
    $needVal = 0;
299
  }
7636 hornik 300
  print("$text\n") if $text;    
2195 hornik 301
  $braceLevel = $level + 1;
10338 hornik 302
  $inReferences = 0;
2195 hornik 303
  $inVerbatim = 0;
304
  $inSeeAlso = 0;
305
  $doprint = 1;    
306
}
307
 
308
sub paragraph {
7357 hornik 309
  my($name) = @_;
2195 hornik 310
  &output("\n\\bold\{$name.\} ");
311
}
312
 
313
sub output {
7357 hornik 314
  my($text) = @_;
2195 hornik 315
  if ($doprint) {
7636 hornik 316
    print("$text\n");
2195 hornik 317
  } elsif ($output) {
318
    $output .= "\n$text";
319
  } else {
320
    $output = $text;
321
  }
322
}
323
 
12256 pd 324
 
325
## ---------------------------- S4 section -------------------------
326
 
327
my $skipping = 0;
328
my $nextskipping = 0;
329
my $text = "";
330
my $fun;
331
my $InArgs = 0;
332
 
333
sub doS4 {
334
  foreach $_ (@lines) {
335
    # skip header
336
    if (/^<!doctype/) {
337
      $skipping = 1;
338
      $nextskipping = 1 unless />\s*$/s;
339
    }
340
    if($skipping && /^>/) { $nextskipping = 0;}
341
    # skip comments
342
    $skipping = $nextskipping = 1 if (/^\s*<\!-- /);
343
    if($skipping && /-->\s*$/) { $nextskipping = 0;}
344
    if(!$skipping) {
345
      $text = $text . $_;
346
    }
347
    $skipping = $nextskipping;
348
  }
349
 
350
  ($type, $text, $rest) = get_group($text); # s-function-doc or whatever
351
  if($type ne "function-doc" && $type ne "method-doc") {
352
    die "Document class `s-$type' is not supported";
353
  }
354
 
355
  chomp $text;
356
 
357
  while(length($text) > 0) {
358
    ($type, $body, $text) = get_group($text);
359
    process_group($type, $body);
360
  }
361
  print "% Converted by $name version $version.\n";
362
  ## End
363
}
364
 
365
sub get_group
366
{
367
    my $text = $_[0];
368
    my $body;
369
    my $rest;
370
 
371
    die "not at beginning of a group in |$text|" unless 
372
	$text =~ /^\s*<s-(.+?)>/s;
373
    my $type = $1;
374
    my $tt = $type;
375
    $tt =~ s/([a-zA-Z-]+).*/$1/;
376
    if($text =~ /^\s*<s-\Q$type\E>(.*?)<\/s-$tt>(.*)/s) {
377
	$body = $1;
378
	$rest = $2;
379
    } else { 
380
	warn "no match for `s-$tt'";
381
	$text =~ /^\s*<s-\Q$type\E>\s*(.*)/s;
382
	$body = $1;
383
	$rest = "";
384
    }
385
    ($type, $body, $rest);
386
}
387
 
388
sub process_group {
389
    my $type = $_[0];
390
    my $text = $_[1];
391
 
392
    if($InArgs && ($type =~ /^args/) != 1) {
393
	print "}\n";
394
	$InArgs = 0;
395
    }
396
 
397
    $text =~ s/^\n*//;
398
    $text =~ s/\n*$//;
399
 
400
    if ($type eq "topics") {
401
	process_sub_groups($text, "topic");
402
 
403
    } elsif ($type eq "title") {
404
	print "\\title{\n  $text\n}\n";
405
 
406
    } elsif ($type eq "description") {
407
	print "\\description{\n", sub4($text), "\n}\n";	
408
 
409
    } elsif ($type eq "usage") {
410
	## new-style usage is not catered for here: no examples seen
411
	## it will be passed through verbatim.
412
	if ($text =~ /^\s*<s-old-style-usage>\s*(.*?)\s*<\/s-old-style-usage>/s) {
413
	    $text = $1;
414
	}
415
	print "\\usage{\n$text\n}\n";	
416
 
417
    } elsif ($type eq "args" || $type eq "args-optional" 
418
	     || $type eq "args-required" ) {
419
	if(!$InArgs) {
420
	    print "\\arguments{\n";
421
	    $InArgs = 1;
422
	}
423
	## some files seem to have text before args
424
	my $pre = $text =~ /^\s*<s-arg/;
425
	if($pre != 1) {
426
	    my $pre;
427
	    if($text =~ s/^\s*(.*?)(<s-arg)/$2/s) {
428
		$pre = $1;
429
	    } else {
430
		## There are no <s-arg> groups!
431
		$pre = $text;
432
		$text = "";
433
	    }
434
	    print sub4($pre), "\n";
435
	}
436
	process_sub_groups($text, "arg");
437
 
438
    } elsif ($type eq "value") {
439
	print "\\value{\n";
440
	my $t;
441
	my @groups = split /<s-return-component /, $text;
442
	foreach $t (@groups) {
443
	    if ($t =~ /name=\"(.*?)\">\s*(.*)<\/s-return-component>/s) {
444
		my $name=$1;
445
		$t = $2;
12778 pd 446
		print "\\item{$1}{\n", sub4($t), "}\n";
12256 pd 447
	    } else {
448
		print sub4($t), "\n";
449
	    }
450
	}
451
	print "}\n";
452
 
453
    } elsif ($type eq "details") {
454
	print "\\details{\n", sub4($text), "\n}\n";	
455
 
456
    } elsif ($type eq "see") {
457
 	print "\\seealso{\n", makelinks($text), "\n}\n";	
458
 
459
    } elsif ($type eq "examples") {
460
	print "\\examples{\n";
461
	print "\\dontrun{\n" if $opt_n;
462
	process_sub_groups($text, "example");
463
	print "}\n" if $opt_n;
464
	print "}\n";
465
 
466
    } elsif ($type eq "note" || $type eq "notes") {
467
	print "\\note{\n", sub4($text), "\n}\n";	
468
 
469
    } elsif ($type eq "bugs") {
470
 	print "\\section{Bugs}{\n", sub4($text), "\n}\n";	
471
 
472
    } elsif ($type eq "references") {
473
	print "\\references{\n", inref(sub4($text)), "\n}\n";	
474
 
475
    } elsif ($type =~ /^section\s+name\s*=\s*(.*)/) {
476
	my $name = $1;
477
	$name =~ s/\s*\"(.*?)\"/$1/o;
478
	$name =~ s/^\s*//o;
479
	if ($name =~ /^reference$/io) {
480
	    print "\\references{\n", inref(sub4($text)), "\n}\n";	
481
	} elsif ($name =~ /^source$/io) {
482
	    print "\\source{\n", inref(sub4($text)), "\n}\n";	
483
	} elsif ($name =~ /^note$/io) {
484
	    print "\\note{\n", sub4($text), "\n}\n";	
485
	} elsif ($name =~ /^summary$/io) {
486
	    print "\\description{\n", sub4($text), "\n}\n";	
487
	} elsif ($name =~ /^data description$/io) {
488
	    print "\\usage{\ndata($fun)\n}\n";
489
	    print "\\format{\n", sub4($text), "\n}\n";	
490
	} else {
491
	    $name = lc($name);
492
	    $name =~ s/^([a-z])/\U$1/;
493
	    print "\\section{$name}{\n", sub4($text), "\n}\n";	
494
	}
495
 
496
    } elsif ($type eq "docclass") {
497
	print "% docclass is $text\n";
498
 
499
    } elsif ($type eq "warnings") {
500
	process_sub_groups($text, "warning");
501
 
502
    } elsif ($type eq "warning") {
503
	print "\\section{Warning}{\n", sub4($text), "\n}\n";	
504
 
505
    } elsif ($type eq "background") {
506
	print "\\section{Background}{\n", sub4($text), "\n}\n";	
507
 
508
    } elsif ($type eq "side-effects") {
509
	print "\\section{Side Effects}{\n", sub4($text), "\n}\n";	
510
 
511
    } elsif ($type eq "author") {
512
	print "\\author{\n", sub4($text), "\n}\n";	
513
 
514
    } elsif ($type eq "keywords") {
515
	process_sub_groups($text, "keyword");
516
 
517
    } else {
518
	warn "unknown SGML entity `$type'";
519
	print "%type:\n%$text\n";
520
    }
521
}
522
 
523
sub process_sub_groups{
524
    my $text = $_[0];
525
    my $topic = $_[1];
526
 
527
    while(length($text) > 0) {
528
	($type, $body, $text) = get_group($text);
529
	die "invalid subgroup" unless $type =~ /^$topic/;
530
	process_sub_group($type, $body);
531
    }
532
}
533
 
534
sub process_sub_group{
535
    my $topic = $_[0];
536
    my $text = $_[1];
537
    my $nalias = 0;
538
    my $example = 0;
539
 
540
    $text =~ s/^\n*//;
541
    $text =~ s/\n*$//;
542
    if ($type eq "topic") {
543
	 $text =~ s/^\s*//; $text =~ s/\s*$//;
544
	if(!$nalias) {
545
	    print "\\name{$text}\n";
546
	    $nalias = 1;
547
	    $fun = $text;
548
	}
549
	print "\\alias{$text}\n";
550
    } elsif ($type eq "warning") {
551
	print "\\section{Warning}{\n", sub4($text), "\n}\n";	
552
    } elsif ($type eq "keyword") {
553
	print "\\keyword{$text}\n";
554
    } elsif ($type =~ /^example/) {
555
	if ($nexample++ > 0) { print "\n"; }
556
	print verbsub($text), "\n";
557
    } elsif ($type =~ /^arg/) {
558
	$type =~ /^arg\s+name\s*=\s*(.*)/;
559
	my $name = $1;
560
	$name =~ s/\s*\"(.*?)\"/$1/o;
561
	$name =~ s/\s*(\w*)\s*/$1/o;
562
	$name =~ s/\.\.\./\\dots/;
563
	print "\\item{$name}{\n", sub4($text), "\n}\n";	
564
    } else {
565
	warn "unknown SGML entity `$type'";
566
	print "%type:\n%$text\n";
567
    }
568
}
569
 
570
sub inref {
571
    my $text = $_[0];
572
    $text =~ s/([0-9])-([0-9])/$1--$2/go;
573
    $text;
574
}
575
 
576
sub verbsub {
577
    my $text = $_[0];
578
    $text =~ s/&gt;/>/go;
579
    $text =~ s/&lt;/</go;
580
    $text =~ s/&#38;/&/go;
581
    $text =~ s/\%/\\%/go;
582
    $text;
583
}
584
 
585
sub sub4 {
586
    my $text = $_[0];
587
    $text =~ s/\{/\\\{/go;
588
    $text =~ s/\}/\\\}/go;
589
 
590
    ## These tags can have id's
591
    $text =~ s+<s-expression(.*?)>(.*?)</s-expression>+\\code{$2}+go;
592
    $text =~ s+<s-object(.*?)>(.*?)</s-object>+\\code{$2}+go;
593
    $text =~ s+<s-function(.*?)>(.*?)</s-function>+\\code{$2}+go;
594
    $text =~ s+<s-class(.*?)>(.*?)</s-class>+\\code{$2}+go;
595
    $text =~ s+<s-method(.*?)>(.*?)</s-method>+\\code{$2}+go;
596
    $text =~ s+<s-dataset(.*?)>(.*?)</s-dataset>+\\code{$2}+go;
597
    ## I have never seen these used
598
    $text =~ s+<s-expref(.*?)>(.*?)</s-expref>+\\code{$2}+go;
599
    $text =~ s+<s-objref(.*?)>(.*?)</s-objref>+\\code{$2}+go;
600
    $text =~ s+<s-function-ref(.*?)>(.*?)</s-function-ref>+\\code{$2}+go;
601
    $text =~ s+<s-clsref(.*?)>(.*?)</s-clsref>+\\code{$2}+go;
602
    $text =~ s+<s-mthref(.*?)>(.*?)</s-mthref>+\\code{$2}+go;
603
    $text =~ s+<s-datref(.*?)>(.*?)</s-datref>+\\code{$2}+go;
604
    $text =~ s+<s-chpref(.*?)>(.*?)</s-chpref>+\\code{$2}+go;
605
 
606
    $text =~ s+<it>(.*?)</it>+\\emph{$1}+go;
607
    $text =~ s+<sl>(.*?)</sl>+\\emph{$1}+go;
608
    $text =~ s+<em>(.*?)</em>+\\emph{$1}+go;
609
    # not clear what to do with <sf>
610
    $text =~ s+<sf>(.*?)</sf>+\\bold{$1}+go;
611
    $text =~ s+<bf>(.*?)</bf>+\\bold{$1}+go;
612
    $text =~ s+<tt>(.*?)</tt>+\\code{$1}+go;
613
    $text =~ s+<url>(.*?)</url>+\\url{$1}+go;
614
    $text =~ s/\n*<p>\n*/\n\n/go;
615
    $text =~ s/(<br>\n*)+/\n/go;
616
    $text =~ s/\$/\\\$/go;
617
    $text =~ s/@/\\@/go;
618
 
619
    verbsub($text);
620
}
621
 
622
sub makelinks {
623
    my $text = $_[0];
624
 
625
    $text =~ s+<s-function name="(.*?)">(.*?)</s-function>+\\code{\\link{$2}}+go;
626
    $text;
627
}
628
 
629
 
2195 hornik 630
### Local Variables: ***
631
### mode: perl ***
632
### perl-indent-level: 2 ***
633
### End: ***