What's new? | Help | Directory | Sign in
Google
                
Search
for
Updated Mar 06, 2008 by martin.balazik
Labels: code, example
HelpCodeSnippets  
How to use FSHL

Short code snippets

If you are looking for ready-to-use source codes, try the "examples" directory in the installation package.

First steps

First example shows basic usage of the FSHL.

Include library into your project:

require_once(__PATH_TO_FSHL__ . '/fshl/fshl.php');

Then prepare some text for highlighting and setup for the parser.

$your_supa_dupa_text = '<pre><?php echo "hello world"; ?></pre>';
$output_module = 'HTML';
$start_language = 'HTML';

Now it's time for parser creation. Create a new instance of the fshlParser class

$parser = new fshlParser($output_module);

Call FSHL to highlight your string. Result from the highlightString() method; actual highlighted HTML code, is displayed on the output.

echo '<pre class="normal">';
echo $parser->highlightString($start_language, $your_supa_dupa_text);
echo '</pre>';

Where are the colors?

FSHL never adds a stylesheet to the output. It only uses predefined style classes and thus you have to link CSS stylesheet manually into HTML page showing the highlighted code. Nice example is located in the fshl/styles/COHEN_style.css file. Feel free to move it to more suitable folder in your project.



Sign in to add a comment