summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--templates/fileviewer.phtml18
-rw-r--r--templates/index.phtml3
2 files changed, 14 insertions, 7 deletions
diff --git a/templates/fileviewer.phtml b/templates/fileviewer.phtml
index b334b0a..b1df0eb 100644
--- a/templates/fileviewer.phtml
+++ b/templates/fileviewer.phtml
@@ -1,5 +1,4 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
@@ -41,10 +40,19 @@
<tr>
<td align="right" valign="top"><code>
<?php
- //Strip code and first span
+ // Strip code and first span
$hl = highlight_file($file, true);
$code = substr($hl, 36, -15);
- //Split lines
+ // Wrap missing spans
+ $code = preg_replace(
+ array('#([^>])<span#', '#</span>([^<])#'),
+ array('\1</span><span', '</span><span>\1'),
+ $code
+ );
+ if ($code[0] != '<') {
+ $code = '<span>'.$code;
+ }
+ // Split lines
$lines = explode('<br />', $code);
foreach ($lines as $num => $line) {
@@ -67,7 +75,7 @@
echo "<code id='line$num' class='line'>$openSpan$line</code>";
- if (preg_match('#.*(<span[^>]+>)#', $line, $matches)) {
+ if (preg_match('#.*(<span[^>]*>)#', $line, $matches)) {
$openSpan = $matches[1];
}
}
diff --git a/templates/index.phtml b/templates/index.phtml
index fd84a43..de07b6e 100644
--- a/templates/index.phtml
+++ b/templates/index.phtml
@@ -1,5 +1,4 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">