]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - pgsrc/PhpHighlightPlugin
rename split_pagename to SplitPagename
[SourceForge/phpwiki.git] / pgsrc / PhpHighlightPlugin
1 Date: Sat, 23 Nov 2002 01:21:01 +0100
2 Mime-Version: 1.0 (Produced by PhpWiki 1.3.4pre)
3 X-Rcs-Id: $Id: PhpHighlightPlugin,v 1.3 2004-05-09 00:36:21 rurban Exp $
4 Content-Type: application/x-phpwiki;
5   pagename=PhpHighlightPlugin;
6   flags="";
7   pgsrc_version="2 $Revision: 1.3 $";
8   markup=2;
9   charset=iso-8859-1
10 Content-Transfer-Encoding: binary
11
12 The PhpHighlightPlugin pretty-prints PHP code using the
13 php-function:highlight-string.
14
15 !!! Usage
16
17 You specify options for the plugin on the same line as the =<?plugin=,
18 and put the code on the following lines, until the final =?>=:
19
20 <verbatim>
21 <?plugin PhpHighlight [wrap?] [color options]
22 code to be highlighted
23 ?>
24 </verbatim>
25
26 !!! Description
27
28 Depending on the =wrap= option, then the plugin will take care of
29 adding =<?php= and =?>= to the code before passing it to
30 php-function:highlight-string. If the PHP delimiters were added, then
31 the plugin removes them again from the highlighted string, before
32 presenting it.
33
34 !!! Options
35
36 Automatic Wrapping:
37
38   If you don't want the plugin to automatically wrap the source code
39   in =<?php= and =?>=, then set =wrap= to =0=. The default value is =1=
40   which means that the plugin takes care of adding and removing
41   =<?php= and =?>= automatically.
42
43   If you set =wrap= to =0=, then you'll be able to mix PHP code with
44   HTML. The plugin will then translate '=< ?php=' into '=<?php=' and
45   '=? >=' into '=?>=' to allow you to start and stop PHP mode in your
46   code.
47
48 Color Options:
49
50   The plugin accepts optional color arguments which correspond to the
51   highlight settings in *php.ini*. Specified colors must be a valid
52   hexadecimal color or
53   [HTML 4 color name|http://www.w3.org/TR/REC-html40/types.html#h-6.5]
54   in lowercase, such as ='#0f0344'= or =blue=. You can set the
55   following options:
56
57   =string=, =comment=, =keyword=, =bg=, =default=, and =html=
58
59 !!! Examples
60
61 !! PHP with default colors from =php.ini=:
62
63 <?plugin PhpHighlight
64 function hello() {
65     echo "Hello World<p>";
66 }
67 ?>
68
69 !! HTML with embedded PHP
70
71 Here we have to use =wrap=0= to prevent automatic wrapping, and escape
72 '=?>=' as '=? >=':
73
74 <?plugin PhpHighlight wrap=0 html='#000000' bg='#dddddd'
75 <html>
76   <head>
77     <title>PHP Test</title>
78   </head>
79   <body>
80     < ?php echo "<p>Hello World</p>\n"; ? >
81   </body>
82 </html>
83 ?>
84
85 !! C Source
86
87 Although =highlight_string()= was designed with PHP code in mind it is
88 suitable for basic syntax-highlighting of most C code because the two
89 syntax are similar.
90
91 <?plugin PhpHighlight default=black string=blue comment=gray keyword=purple
92 #include <stdio.h>
93 /* Get load */
94 int
95 getload(void)
96 {
97     if ((fp = fopen("/proc/loadavg", "r")) == NULL) {
98         syslog(LOG_ERR, _("%s %s: unable to open %s: %s"), _("FATAL ERROR:"),
99               "getload()", "/proc/loadavg", strerror(errno));
100         exit(EX_OSFILE);
101     }
102     fclose(fp);
103 }
104 ?>
105
106 !!! Authors
107
108 Martin Geisler mailto:gimpster@gimpster.com and Carsten Klapp
109 mailto:carstenklapp@users.sourceforge.net.