(this page is translated by Google; We're working hard on a human translation)

Configurations demo

This setting is used in the demo :

 $texy = new Texy; 

$texy ->imageModule->root = '/images/' ;
$texy ->imageModule->linkedRoot = '/images/' ;
$texy ->headingModule->generateID = TRUE ;

// syntax highlighting
$texy ->addHandler( 'block' , 'blockHandler' );

Handler for the syntax uses the library FSHL :

 /** 
* User handler for code block
*
* @param TexyHandlerInvocation handler invocation
* @param string block type
* @param string text to highlight
* @param string language
* @param TexyModifier modifier
* @return TexyHtml
*/

function blockHandler( $invocation , $blocktype , $content , $lang , $modifier )
{
if ( $blocktype !== 'block/code' ) {
// nothing to do
return $invocation ->proceed();
}

$lang = strtoupper ( $lang );
if ( $lang == 'JAVASCRIPT' ) $lang = 'JS' ;

$parser = new fshlParser( 'HTML_UTF8' , P_TAB_INDENT);
if (! $parser ->isLanguage( $lang )) {
return $invocation ->proceed();
}

$texy = $invocation ->getTexy();

$content = Texy::outdent( $content );
$content = $parser ->highlightString( $lang , $content );
$content = $texy ->protect( $content , Texy::CONTENT_BLOCK);

$elPre = TexyHtml::el( 'pre' );
if ( $modifier ) $modifier ->decorate( $texy , $elPre );
$elPre ->attrs[ 'class' ] = strtolower ( $lang );

$elCode = $elPre ->create( 'code' , $content );

return $elPre ;
}

After completion of the conversion, moreover, the text confuses some characters as entities in order to better illustrate:

 $html = $texy ->process( $text ); 

$html = str_replace (
array ( "\xc2\xa0" , "\xc2\xad" , "\xe2\x80\x93" , "\xe2\x80\x94" ),
array ( ' ' , '­' , '–' , '—' ),
$html
);