From 05c8ae8860e0270f89e969a78518df0881c5cd57 Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Sun, 3 Jun 2012 22:34:39 +0200 Subject: [PATCH] html encoding fixed in comments + better layout for code display --- lib/helper/MarkdownHelper.php | 7 +++---- web/css/less/_comment.less | 10 +++++++++- web/css/main.css | 12 +++++++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lib/helper/MarkdownHelper.php b/lib/helper/MarkdownHelper.php index e280637..fd0ac97 100644 --- a/lib/helper/MarkdownHelper.php +++ b/lib/helper/MarkdownHelper.php @@ -76,7 +76,8 @@ function Markdown($text) { $text = preg_replace($pattern, '[$1]($1)', $text); # Generate line breaks (2 spaces are no more needed) - $text = preg_replace('/\s*\n/', "\n\r", $text); + $text = preg_replace('/\r/', '', $text); + $text = preg_replace('/\n/', " \n", $text); # Transform text using parser. return $parser->transform($text); @@ -1125,7 +1126,6 @@ function _doCodeBlocks_callback($matches) { $codeblock = $matches[1]; $codeblock = $this->outdent($codeblock); - $codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES); # trim leading newlines and trailing newlines $codeblock = preg_replace('/\A\n+|\n+\z/', '', $codeblock); @@ -1139,7 +1139,7 @@ function makeCodeSpan($code) { # # Create a code span markup for $code. Called from handleSpanToken. # - $code = htmlspecialchars(trim($code), ENT_NOQUOTES); + $code = trim($code); return $this->hashPart("$code"); } @@ -2688,7 +2688,6 @@ function doFencedCodeBlocks($text) { } function _doFencedCodeBlocks_callback($matches) { $codeblock = $matches[2]; - $codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES); $codeblock = preg_replace_callback('/^\n+/', array(&$this, '_doFencedCodeBlocks_newlines'), $codeblock); $codeblock = "
$codeblock
"; diff --git a/web/css/less/_comment.less b/web/css/less/_comment.less index f7026d5..b23f2b4 100644 --- a/web/css/less/_comment.less +++ b/web/css/less/_comment.less @@ -94,11 +94,19 @@ list-style-type: decimal; } } + pre { + background-color: @lighterGrey; + .radius(5px); + color: @darkGrey; + font-family: monospace; + margin: 8px 5px; + padding: 8px; + } code { background-color: @lighterGrey; color: @darkGrey; font-family: monospace; - padding: 0 3px; + padding: 2px 3px; } em { color: @grey; diff --git a/web/css/main.css b/web/css/main.css index c4938e0..b40430e 100755 --- a/web/css/main.css +++ b/web/css/main.css @@ -388,11 +388,21 @@ list-style-position:inside; list-style-type:decimal; } +.comment_bloc .comment .comment_body pre, .comments_holder .comment .comment_body pre { + background-color:#eeeeee; + border-radius:5px; + -webkit-border-radius:5px; + -moz-border-radius:5px; + color:#333333; + font-family:monospace; + margin:8px 5px; + padding:8px; +} .comment_bloc .comment .comment_body code, .comments_holder .comment .comment_body code { background-color:#eeeeee; color:#333333; font-family:monospace; - padding:0 3px; + padding:2px 3px; } .comment_bloc .comment .comment_body em, .comments_holder .comment .comment_body em { color:#666666;