From 40a86b41c762f9e7ad3d05c1e37929c2ab1cd1ba Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 23 Aug 2014 22:22:34 +1200 Subject: [PATCH] fix code white-space --- rebuild.php | 33 ++++++++++++++++----------------- static/style.css | 1 + 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/rebuild.php b/rebuild.php index 8a0a019..deb4da7 100644 --- a/rebuild.php +++ b/rebuild.php @@ -97,23 +97,6 @@ function hesc($sz) { function text2html($sz) { - $sectionFmt = function($sz) { - $base = hesc($sz); - - $base = preg_replace('~^=+(.+)=+~m', '\\1', $base); - $base = preg_replace('~(https?://[^ \\r\\n\\t]+)~i', '\\1', $base); - - $btparts = explode('`', $base); - if (count($btparts) > 1 && (count($btparts) % 2)) { - for ($i = 1, $e = count($btparts); $i < $e; $i += 2) { - $btparts[$i] = ''.$btparts[$i].''; - } - $base = implode('', $btparts); - } - - return nl2br($base); - }; - $identity = function($sz) { return $sz; }; @@ -138,6 +121,22 @@ function text2html($sz) { return implode($join, $ret); }; + $sectionFmt = function($sz) use($oddEven, $identity) { + $base = hesc($sz); + + $base = preg_replace('~^=+(.+)=+~m', '\\1', $base); + $base = preg_replace('~(https?://[^ \\r\\n\\t]+)~i', '\\1', $base); + + $btparts = explode('`', $base); + if (count($btparts) > 1 && (count($btparts) % 2)) { + for ($i = 1, $e = count($btparts); $i < $e; $i += 2) { + $btparts[$i] = ''.$btparts[$i].''; + } + } + + return $oddEven($btparts, $identity, 'nl2br'); + }; + $htmlSections = $splitInside('', '', $sz); return $oddEven($htmlSections, $identity, $sectionFmt); } diff --git a/static/style.css b/static/style.css index fb04430..55c69cd 100644 --- a/static/style.css +++ b/static/style.css @@ -26,6 +26,7 @@ h1,h2,h3 { .code { background: #F8F8F8; font-family:Consolas,monospace; + white-space:pre; } /* */