DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(enscript.info.gz) Output Languages

Info Catalog (enscript.info.gz) Styles (enscript.info.gz) Writing New Highlighting Definitions
 
 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;
        }
      }
 
Info Catalog (enscript.info.gz) Styles (enscript.info.gz) Writing New Highlighting Definitions
automatically generated byinfo2html