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