- Change the font and font size of the line numbers. You can specify your preferred font and font size for the line numbers by defining the style
IncludeCodeListing_linenum using css. For example, if you define IncludeCodeListing_linenum as the following:
<style type="text/css">
<!--
.IncludeCodeListing_linenum {
font-family: Times New Roman Bold Italic;
font-size: 16px;
color: #0000ff;
}
-->
</style>
To use the above style, you have to use the setting use_css=1. Don't forget to enclose this in square brackets.
{include_code_listing sample1.1.php [use_css=1]}
You will get this:
1 2 3 4 5 6 7 8
|
<?php # sample1.php echo "now = ".date('F j, Y H:i:s')."\n";
for ($i=0; $i<10; ++$i) { print "$i: ".$i*$i."\n"; } ?>
|
- Set the background color for the line numbers. You can set a different color for the line numbers by defining the style
td.IncludeCodeListing_linenum_td using css. For example, if you define td.IncludeCodeListing_linenum_td as the following:
<style type="text/css">
<!--
.IncludeCodeListing_linenum {
font-family: "Courier New", Courier, monospace;
font-size: 9px;
font-style: italic;
color: #FF3399;
}
td.IncludeCodeListing_linenum_td {
background-color: #99E9FF;
}
-->
</style>
To use the above style, you have to use the setting use_css=1. Don't forget to enclose this in square brackets.
{include_code_listing sample1.1.php [use_css=1]}
You will get this:
1 2 3 4 5 6 7 8
|
<?php # sample1.php echo "now = ".date('F j, Y H:i:s')."\n";
for ($i=0; $i<10; ++$i) { print "$i: ".$i*$i."\n"; } ?>
|
- Change the font and style of the code display. The codes are displayed using the standard HTML tag
<code>. So if you wish to change the font or style of the code display, you do this by changing the style of the HTML tag <code> using the style sheet. For example, let's define <code> as follows:
<style type="text/css">
<!--
code {
font-family: "Times New Roman", Times, serif;
font-size: 16px;
font-style: italic;
color: #FF3399;
}
-->
</style>
Note that for this to work, you do not need the setting use_css=1. (Unless, of course, if you intend to specify the font of the line number, you will then need to use the setting use_css=1 as outlined in (1) above.)
{include_code_listing sample1.1.php}
You will get this:
1
2
3
4
5
6
7
8
|
<?php # sample1.php echo "now = ".date('F j, Y H:i:s')."\n";
for ($i=0; $i<10; ++$i) { print "$i: ".$i*$i."\n"; } ?>
|
- Suppress line numbers. If you prefer without the line numbers, use the following syntax. Note that all settings should reside within the square brackets, delimited by commas.
{include_code_listing c:\sample apps\php\sample1.1.php [show_linenum=0]}
<?php # sample1.php echo "now = ".date('F j, Y H:i:s')."\n";
for ($i=0; $i<10; ++$i) { print "$i: ".$i*$i."\n"; } ?>
|
- Specifying the indent for multi-lines. When there is a word wrap, I give a 2-space indent for the second and subsequent lines. To change this, use the setting multiline_indent.
Compare this with indent=2 (the default)
{include_code_listing c:\sample apps\php\sample3.php [wrap_column=40, multiline_indent=2]}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<?php # sample3.php # from joomla index.php
// Set flag that this is a parent file define( '_VALID_MOS', 1 );
// checks for configuration file, if none found loads installation page if (!file_exists( 'configuration.php' ) || filesize( 'configuration.php' ) < 10) { $self = rtrim( dirname( $_SERVER[ 'PHP_SELF'] ), '/\\' ) . '/'; header("Location: http://" . $_SERVER['HTTP_HOST'] . $self . "installation/index.php" ); exit(); }
require( 'globals.php' ); require( 'configuration.php' );
// SSL check - $http_host returns <live site url>:<port number if it is 443> $http_host = explode(':', $_SERVER[ 'HTTP_HOST'] ); if( (!empty( $_SERVER['HTTPS'] ) && strtolower( $_SERVER['HTTPS'] ) != 'off' || isset( $http_host[1] ) && $http_host[1] == 443) && substr( $mosConfig_live_site, 0, 8 ) != 'https://' ) { $mosConfig_live_site = 'https://'. substr( $mosConfig_live_site, 7 ); }
?>
|
and this with indent=0
{include_code_listing c:\sample apps\php\sample3.php [wrap_column=40, multiline_indent=0]}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<?php # sample3.php # from joomla index.php
// Set flag that this is a parent file define( '_VALID_MOS', 1 );
// checks for configuration file, if none found loads installation page if (!file_exists( 'configuration.php' ) || filesize( 'configuration.php' ) < 10) { $self = rtrim( dirname( $_SERVER[ 'PHP_SELF'] ), '/\\' ) . '/'; header("Location: http://" . $_SERVER['HTTP_HOST'] . $self . "installation/index.php" ); exit(); }
require( 'globals.php' ); require( 'configuration.php' );
// SSL check - $http_host returns <live site url>:<port number if it is 443> $http_host = explode(':', $_SERVER[ 'HTTP_HOST'] ); if( (!empty( $_SERVER['HTTPS'] ) && strtolower( $_SERVER['HTTPS'] ) != 'off' || isset( $http_host[1] ) && $http_host[ 1] == 443) && substr( $mosConfig_live_site, 0, 8 ) != 'https://' ) { $mosConfig_live_site = 'https://'. substr( $mosConfig_live_site, 7 ); }
?>
|
- Force wrap. If a line exceeds the wrap column, you can choose to force wrap the line with the setting
force_wrap=1.
{include_code_listing c:\sample apps\php\sample4.php [wrap_column=40, force_wrap=1]}
The force_wrap is turned on by default. You could turn it off with force_wrap=0:
{include_code_listing c:\sample apps\php\sample4.php [wrap_column=40, force_wrap=0]}
I will not show it here as it would mess up the layout of this page.