Headers and Footers for Your Code - GeSHi/geshi-1.0 GitHub Wiki

So you want to add some special information to the highlighted source? GeSHi can do that too! You can specify headers and footers for your code, style them, and insert information from the highlighted source into your header or footer.

Keyword Substitution

In your header and footer, you can put special keywords that will be replaced with actual configuration values for this GeSHi object. The keywords you can use are:

  • <TIME> or {TIME}: Is replaced by the time it took for the parse_code() method - i.e., how long it took for your code to be highlighted. The time is returned to three decimal places.
  • <LANGUAGE> or {LANGUAGE}: Is replaced by a nice, friendly version of the language name used to highlight this code.
  • <SPEED> or {SPEED}: Is replaced by the speed at which your source has been processed.
  • <VERSION> or {VERSION}: The GeSHi version used to highlight the code.

Setting Header Content

The header for your code is a <div>, which is inside the containing block. Therefore, it is affected by the method set_overall_style, and should contain the sort of HTML that belongs in a <div>. You may use any HTML you like, and format it as an HTML document. You should use valid HTML - convert to entities any quotemarks or angle brackets you want displayed. You set the header content using the method set_header_content():

$geshi->set_header_content($content);

Where $content is the HTML you want to use for the header.

Setting Footer Content

The footer for your code is a <div>, which is inside the containing block. Therefore, it is affected by the method set_overall_style, and should contain the sort of HTML that belongs in a <div>. You may use any HTML you like, and format it as an HTML document. You should use valid HTML - convert to entities any quotemarks or angle brackets you want displayed. You set the footer content using the method set_footer_content():

$geshi->set_footer_content($content);

Where $content is the HTML you want to use for the footer.

Styling Header Content

You can apply styles to the header content you have set with the set_header_content_style:

$geshi->set_header_content_style($styles);

Where $styles is the stylesheet declarations you want to use to style the header content.

Styling Footer Content

You can apply styles to the footer content you have set with the set_footer_content_style:

$geshi->set_footer_content_style($styles);

Where $styles is the stylesheet declarations you want to use to style the footer content.

⚠️ **GitHub.com Fallback** ⚠️