(file) Return to lang_html.st CVS log (file) (dir) Up to [RizwankCVS] / testProject / source / states / hl

  1 rizwank 1.1 
  2             state lang_html
  3             {
  4               BEGIN {
  5                 /* RGB -> HTML color mapper function. */
  6                 sub map_color (r, g, b)
  7                   {
  8             	return sprintf ("#%02X%02X%02X", r, g, b);
  9                   }
 10             
 11                 LANGUAGE_SPECIALS = /[<>\&\"]/;
 12             
 13                 sub language_print (str)
 14                   {
 15             	str = regsuball (str, /\&/, "&amp;");
 16             	str = regsuball (str, /</, "&lt;");
 17             	str = regsuball (str, />/, "&gt;");
 18             	str = regsuball (str, /\"/, "&quot;");
 19             	print (str);
 20                   }
 21             
 22 rizwank 1.1     sub language_symbol (symbol)
 23                   {
 24             	return false;
 25                   }
 26             
 27                 sub header ()
 28                   {
 29             	local i;
 30             
 31             	if (current_input_file == 1)
 32             	  {
 33             	    print ("<!DOCTYPE html PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n");
 34             	    print ("<HTML>\n<HEAD>\n<TITLE>");
 35             	    language_print (document_title);
 36             	    print ("</TITLE>\n</HEAD>\n",
 37             		   color
 38             		   ? "<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\" LINK=\"#1F00FF\" ALINK=\"#FF0000\" VLINK=\"#9900DD\">"
 39             		   : "<BODY>",
 40             		   "\n<A NAME=\"top\">\n");
 41             
 42             	    if (need_version (1, 5, 1) && int (toc) == 1)
 43 rizwank 1.1 	      {
 44             		if (length (argv) == 0)
 45             		  argv[0] = "(stdin)";
 46             
 47             		print ("<H1>Contents</H1>\n<OL>\n");
 48             		for (i = 0; i < length (argv); i = i + 1)
 49             		  print ("  <LI><A HREF=\"#file", i + 1, "\">", argv[i],
 50             			 "</A>\n");
 51             		print ("</OL>\n<HR>\n");
 52             	      }
 53             	  }
 54             
 55             	print ("<A NAME=\"file", current_input_file, "\">\n<H1>");
 56             	language_print (filename);
 57             
 58             	if (int (num_input_files) > 1)
 59             	  print (" ", current_input_file, "/", num_input_files);
 60             
 61             	print ("</H1>\n");
 62             
 63             	/* Navigation bar. */
 64 rizwank 1.1 	if (need_version (1, 5, 1))
 65             	  {
 66             	    if (length (argv) >= 2 )
 67             	      {
 68             		print ("[<A HREF=\"#top\">top</A>]");
 69             
 70             		if (current_input_file == 1)
 71             		  print ("[prev]");
 72             		else
 73             		  print ("[<A HREF=\"\#file", current_input_file - 1,
 74             			 "\">prev</A>]");
 75             
 76             		if (current_input_file == length (argv))
 77             		  print ("[next]");
 78             		else
 79             		  print ("[<A HREF=\"#file", current_input_file + 1,
 80             			 "\">next</A>]");
 81             	      }
 82             	  }
 83             	else
 84             	  print ("[<A HREF=\"#top\">top</A>]");
 85 rizwank 1.1 	print ("\n<PRE>\n");
 86                   }
 87             
 88                 sub trailer ()
 89                   {
 90             	print ("</PRE>
 91             <HR>\n");
 92             	if (current_input_file == int (num_input_files))
 93             	  print ("<ADDRESS>Generated by ",
 94             		 "<A HREF=\"http://www.iki.fi/~mtr/genscript/\">",
 95             		 substring (version, strchr (version, 'G'), length (version)),
 96             		 "</A>.</ADDRESS>
 97             </BODY>
 98             </HTML>\n");
 99                   }
100             
101                 sub face_on (face)
102                   {
103             	if (face[boldp])
104             	  print ("<B>");
105             	if (face[italicp])
106 rizwank 1.1 	  print ("<I>");
107             
108             	if (face[fg_color])
109             	  print ("<FONT COLOR=\"", face[fg_color], "\">");
110             	/* The background color is not supported in HTML. */
111                   }
112             
113                 sub face_off (face)
114                   {
115             	if (face[fg_color])
116             	  print ("</FONT>");
117             
118             	if (face[italicp])
119             	  print ("</I>");
120             	if (face[boldp])
121             	  print ("</B>");
122                   }
123             
124                 return;
125               }
126             }
127 rizwank 1.1 
128             
129             /*
130             Local variables:
131             mode: c
132             End:
133             */

Rizwan Kassim
Powered by
ViewCVS 0.9.2