diff options
author | Alpha <ngcoder@live.com> | 2015-11-19 14:23:51 -0500 |
---|---|---|
committer | Alpha <ngcoder@live.com> | 2015-11-19 14:23:51 -0500 |
commit | 2f6aa56949c910ad5e09c78b4f09c3d9d9e74b3e (patch) | |
tree | fa90d30a6be264af1230ae2133fd336225600404 | |
parent | a74facec06094cdfb7c4c81a0f0daea00bc94b84 (diff) | |
download | webgrind-2f6aa56949c910ad5e09c78b4f09c3d9d9e74b3e.zip webgrind-2f6aa56949c910ad5e09c78b4f09c3d9d9e74b3e.tar.gz webgrind-2f6aa56949c910ad5e09c78b4f09c3d9d9e74b3e.tar.bz2 |
Fix fileviewer for mixed PHP/HTML
-rw-r--r-- | templates/fileviewer.phtml | 18 | ||||
-rw-r--r-- | templates/index.phtml | 3 |
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"> |