File: gri2html

package info (click to toggle)
gri 2.12.26-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 5,952 kB
  • ctags: 2,396
  • sloc: cpp: 36,598; sh: 4,196; lisp: 3,764; perl: 1,362; ansic: 1,046; makefile: 606
file content (62 lines) | stat: -rwxr-xr-x 1,996 bytes parent folder | download | duplicates (11)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/perl
die "Usage: gri2html file.gri file.html" if ($#ARGV !=1);
$filename_gri = $ARGV[0];
$filename_html = $ARGV[1];
open(IN,  "$filename_gri")   || die "Can't open `$filename_gri'  for input\n";
open(OUT, ">$filename_html") || die "Can't open `$filename_html' for output\n";

print OUT "<html>\n";
print OUT "<head>\n";
print OUT "<title>$ARGV[0]</title>\n";
print OUT "</head>\n";
print OUT "<body bgcolor=\"#FFFFFF\">\n";
print OUT "<i># This html document was prepared by gri2html based on the Gri script named</i>\n";
print OUT "<br><i>#    <a href=\"$ARGV[0]\">$ARGV[0]</a></i>\n";
print OUT "<br># <i>Gri is available for free at <a href=\"http://gri.sourceforge.net\">http://gri.sourceforge.net</a></i>\n";
print OUT "<pre>\n";

while(<IN>) {
    s,<,&lt;,g;
    s,>,&gt;,g;
    s,//(.*),<i>//$1</i>,;
       
    if (/^[ ]*\#/) {
        s,(\#.*),<font color=\#B22222>$1</font>,;
        print OUT "$_";
        next;
    }
    # #Comments
    s,(\#.*),<font color=\#B22222>$1</font>,;

    # \.factor. =
    s,(\\\.[^.]+\. [\+\*/^-]?=),<font color=\#0000EE>$1</font>,;
    # .gulf_emphasisGSL. = 
    s,(\.[^.]+\. [\+\*/^-]?=),<font color=\#0000EE>$1</font>,;
    # \xl = 
    s,(\\[^\\]+ [\+\*/^-]?=),<font color=\#0000EE>$1</font>,;

    # \.factor.
    s,(\\\.[^ .]+\.),<font color=\#CDAD00>$1</font>,g;
    # .factor.
    s,( \.[^ .]+\.),<font color=\#CDAD00>$1</font>,g;
    # ..ysize..
    s,(\.\.[^ .]+\.\.),<font color=\#006400>$1</font>,g;
    # \xl
    s,( \\[^\ ]+),<font color=\#0000EE>$1</font>,g;

    # `newcommand'
    s,^(\`.*\')$,<font color=\#0000EE>$1</font>,;

    # system stuff
       s,system (.*),<font color=\#9400D3>system</font> <font color=\#FF0000>$1</font>,;
    # "strings"
    s,(".*"),<font color=\#2F4F4F>$1</font>,g;

    s,\b(quit|return|if|else( if)?|end (if|while)|break|while|rpn)\b,<font color=\#9400D3>$1</font>,g;

#   s,"(.*)",<u>"$1"</u>,g;
    print OUT "$_";
}
print OUT "</pre>\n";
print OUT "</body>\n";
print OUT "</html>\n";