[BACK]Return to lang_cvsweb.st CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / cvsweb / enscript

File: [cvsweb.bsd.lv] / cvsweb / enscript / Attic / lang_cvsweb.st (download)

Revision 3.1, Thu May 1 15:47:33 2003 UTC (19 years, 7 months ago) by scop
Branch: MAIN

Syntax highlighting using GNU Enscript (1.6.2+).

Submitted by:	Neal Horman <neal@wanlink.com>

/*
   GNU Enscript language file for FreeBSD-CVSweb.
   $FreeBSD$
 */

state lang_cvsweb
{
  BEGIN {
    /* RGB -> HTML color mapper function. */
    sub map_color (r, g, b)
      {
	return sprintf ("#%02X%02X%02X", r, g, b);
      }

    LANGUAGE_SPECIALS = /[<>\&\"]/;

    sub language_print (str)
      {
	str = regsuball (str, /\&/, "&amp;");
	str = regsuball (str, /</, "&lt;");
	str = regsuball (str, />/, "&gt;");
	str = regsuball (str, /\"/, "&quot;");
	print (str);
      }

    sub language_symbol (symbol)
      {
	return false;
      }

    sub header ()
      {
	print ("<pre>");
      }

    sub trailer ()
      {
	print ("</pre>");
      }

    sub face_on (face)
      {
	if (face[boldp])
	  print ("<b>");
	if (face[italicp])
	  print ("<i>");

	if (face[fg_color])
	  print ("<span style=\"color: ", face[fg_color], "\">");
	if (face[bg_color])
	  print ("<span style=\"background-color: ", face[bg_color], "\">");
      }

    sub face_off (face)
      {
 	if (face[fg_color])
	  print ("</span>");
 	if (face[bg_color])
	  print ("</span>");

	if (face[italicp])
	  print ("</i>");
	if (face[boldp])
	  print ("</b>");
      }

    return;
  }
}


/*
Local variables:
mode: c
End:
*/