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