| 1 |
#!/usr/bin/perl -w |
| 2 |
# Convert macros into texi format. Macros are: |
| 3 |
# |
| 4 |
# @c EQUIVALENCE .* .* -> translate 1st string (one word) to 2nd (possibly several words) |
| 5 |
# @c SYNTAX .* -> make pretty list, establish link to 'how to read syntax' |
| 6 |
# @c EXAMPLE .* -> example with a title |
| 7 |
# @c QUIETEXAMPLE .* -> as EXAMPLE but no title |
| 8 |
# @c TESTFILE .* -> establish link to testfile |
| 9 |
# @c STYLE .* -> formatting for examples |
| 10 |
# @c CLICKABLE_SAMPLE .* .* -> for html, graph+code. First is gif, second code (normally as html). |
| 11 |
while(<>) { |
| 12 |
next if /\@c -\*- mode:/; |
| 13 |
foreach $target (keys (%equivalence)) { |
| 14 |
s/$target/$equivalence{$target}/g; |
| 15 |
} |
| 16 |
if (/\@c\s*EQUIVALENCE\s([^ ]*)\s*([^\n]*)/) { |
| 17 |
$equivalence{$1} = $2; |
| 18 |
print STDERR "Established Equivalance '$1' -> '$2'\n"; |
| 19 |
} elsif (/\@c\s*STYLE\s*(.*)/) { |
| 20 |
$item = $1; |
| 21 |
s,\@c\s*STYLE.*,\@noindent\n\@emph{Style $item} ---,; |
| 22 |
} elsif (/\@c\s*SYNTAX\s*(.*)/) { |
| 23 |
$item = $1; |
| 24 |
$item =~ s/\\N/\n/g; |
| 25 |
s,\@c\s*SYNTAX.*,\n\n\@c HTML <A HREF=\"\#CautionaryNotesOnSyntax\">\n\@emph{Syntax:}\n\@c HTML </A>\n\@example\n$item\n\@end example,; |
| 26 |
} elsif (/\@c\s*EXAMPLE\s*(.*)/) { |
| 27 |
$item = $1; |
| 28 |
$item =~ s/\\N/\n/g; |
| 29 |
s,\@c\s*EXAMPLE.*,\n\@emph{Example:}\n\@example\n$item\n\@end example,; |
| 30 |
} elsif (/\@c\s*QUIETEXAMPLE\s*(.*)/) { |
| 31 |
$item = $1; |
| 32 |
$item =~ s/\\N/\n/g; |
| 33 |
#print STDERR; |
| 34 |
s,\@c\s*QUIETEXAMPLE.*,\@example\n$item\n\@end example,; |
| 35 |
#print STDERR; |
| 36 |
} elsif (/\@c\s*CLICKABLE_SAMPLE\s*([^\s]*)\s*([^\s]*)/) { |
| 37 |
print "\@c HTML (Click figure below to see the code that generated it.)\n"; |
| 38 |
print "\@c HTML <br><a href=\"$2\"><img src=\"$1\"></a>\n"; |
| 39 |
next; # skip the command itself |
| 40 |
} elsif (/\@c\s*TESTFILE/) { |
| 41 |
s,\@c\s*TESTFILE\s(.*),\n\ |
| 42 |
\@c HTML <a href="tst_suite/$1.html">Test file `<tt>$1.gri</tt>'.</a><p>\ |
| 43 |
\@iftex\ |
| 44 |
\@sp 1\ |
| 45 |
\@noindent Test file \@file{$1.gri}:\ |
| 46 |
\ |
| 47 |
\@cartouche\ |
| 48 |
\@include tst_suite/$1.texi\ |
| 49 |
\@end cartouche\ |
| 50 |
\@end iftex,; |
| 51 |
} |
| 52 |
print; |
| 53 |
} |