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