GNU Info

Info Node: (enscript.info)Output Languages

(enscript.info)Output Languages


Prev: Styles Up: Writing New Highlighting Definitions
Enter node , (file) or (file)node

Output Languages
================

 - Function: map_color (R, G, B)

 - Function: language_print (STRING)

 - Function: language_symbol (SYMBOL)

 - Function: header ()

 - Function: trailer ()

 - Function: face_on (FACE)

 - Function: face_off (FACE)

 - Variable: LANGUAGE_SPECIALS

   The following example creates a new output language `simple_html'
that creates simple HTML outputs.  The output language is defined in a
file called `lang_simple_html.st'.  The file must define a state called
`lang_simple_html'.  The file can be located in any directory that is
in the load path of the states program.

   The output language definitions are defined in the `BEGIN' block of
the `lang_simple_html' state.  Please, note that the `BEGIN' block is
ended with a `return'-statement.  This statement will return the
control to the calling state that is the start state of the enscript
highlight program.  If the `return'-statement was omitted, the states
would start processing the input with the `lang_simple_html' state
which is obviously a wrong choice.

     state lang_simple_html
     {
       BEGIN {
         sub map_color (r, g, b)
         {
           return sprintf ("#%02X%02X%02X", r, g, b);
         }
     
         sub language_print (str)
         {
           str = regsuball (str, /\&/, "&");
           str = regsuball (str, /</, "&lt;");
           str = regsuball (str, />/, "&gt;");
           str = regsuball (str, /\"/, "&quot;");
           print (str);
         }
     
         sub language_symbol (symbol)
         {
           return false;
         }
     
         sub header ()
         {
           print ("<html>\n<head>\n<title>Simple HTML Output</title>\n");
           print ("</head>\n<body>\n");
         }
     
         sub trailer ()
         {
           print ("</body>\n</html>\n");
         }
     
         sub fase_on (face)
         {
           if (face(boldp])
             print ("<B>");
           if (face(italicp])
             print ("<I>");
           if (face[fg_color])
             print ("<FONT COLOR=\", face[fg_color], "\">");
         }
     
         sub face_off (face)
         {
           if (face[fg_color])
             print ("</FONT>");
           if (face[italicp])
             print ("</I>");
           if (face[boldp])
             print ("</B>");
         }
     
         LANGUAGE_SPECIALS = /[<>\&\"]/;
     
         return;
       }
     }


automatically generated by info2www version 1.2.2.9