X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=doc%2Fhighlight.php;h=750261bd81b2f3493f1870ce7d8a1e1594b80260;hb=78ed1f631cf0a88feefe0f5f705a60dfbe1141d0;hp=b8afda17d179795d63d76e55b7bae30bbdfce0be;hpb=172e482d9aa27d7866d7a38fea8be90182480b79;p=plcapi.git
diff --git a/doc/highlight.php b/doc/highlight.php
index b8afda1..750261b 100644
--- a/doc/highlight.php
+++ b/doc/highlight.php
@@ -1,46 +1,43 @@
';
- $endtag = '';
+ $starttag = '
';
+ $endtag = '
';
+
+ $content = file_get_contents($file);
+ $last = 0;
+ $out = '';
+ while (($start = strpos($content, $starttag, $last)) !== false) {
+ $end = strpos($content, $endtag, $start);
+ $code = substr($content, $start + strlen($starttag), $end - $start - strlen($starttag));
+ if ($code[strlen($code) - 1] == "\n") {
+ $code = substr($code, 0, -1);
+ }
+
+ $code = str_replace(array('>', '<'), array('>', '<'), $code);
+ $code = highlight_string('<?php
', '', $code);
- $content = file_get_contents($file);
- $last = 0;
- $out = '';
- while(($start = strpos($content, $starttag, $last)) !== false)
- {
- $end = strpos($content, $endtag, $start);
- $code = substr($content, $start+strlen($starttag), $end-$start-strlen($starttag));
- if ($code[strlen($code)-1] == "\n") {
- $code = substr($code, 0, -1);
+ $out = $out . substr($content, $last, $start + strlen($starttag) - $last) . $code . $endtag;
+ $last = $end + strlen($endtag);
}
-//var_dump($code);
- $code = str_replace(array('>', '<'), array('>', '<'), $code);
- $code = highlight_string('<?php
', '', $code);
-//echo($code);
- $out = $out . substr($content, $last, $start+strlen($starttag)-$last) . $code . $endtag;
- $last = $end+strlen($endtag);
- }
- $out .= substr($content, $last, strlen($content));
- return $out;
+ $out .= substr($content, $last, strlen($content));
+
+ return $out;
}
$dir = $argv[1];
$files = scandir($dir);
-foreach($files as $file)
-{
- if (substr($file, -5, 5) == '.html')
- {
- $out = highlight($dir.'/'.$file);
- file_put_contents($dir.'/'.$file, $out);
+foreach ($files as $file) {
+ if (substr($file, -5, 5) == '.html') {
+ $out = highlight($dir . '/' . $file);
+ file_put_contents($dir . '/' . $file, $out);
}
}