diff options
author | Jeremy Dorn <jeremy@jeremydorn.com> | 2013-03-31 15:29:24 -0700 |
---|---|---|
committer | Jeremy Dorn <jeremy@jeremydorn.com> | 2013-03-31 15:29:24 -0700 |
commit | e38ea8a0cbd943ac78014d07f42441cd51d537db (patch) | |
tree | 7d720d5c4bff7fa5197202dd606ca74e23f8b351 | |
parent | 4ca0c1b7e6501ec3404c07675372cf6076d8628b (diff) | |
download | sql-formatter-e38ea8a0cbd943ac78014d07f42441cd51d537db.zip sql-formatter-e38ea8a0cbd943ac78014d07f42441cd51d537db.tar.gz sql-formatter-e38ea8a0cbd943ac78014d07f42441cd51d537db.tar.bz2 |
Improving block comment formatting. Fixes #37
-rw-r--r-- | lib/SqlFormatter.php | 4 | ||||
-rw-r--r-- | tests/format-highlight.html | 2 | ||||
-rw-r--r-- | tests/format.html | 2 |
3 files changed, 5 insertions, 3 deletions
diff --git a/lib/SqlFormatter.php b/lib/SqlFormatter.php index c96a3a1..678a483 100644 --- a/lib/SqlFormatter.php +++ b/lib/SqlFormatter.php @@ -408,7 +408,9 @@ class SqlFormatter // Display comments directly where they appear in the source if ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_COMMENT || $token[self::TOKEN_TYPE] === self::TOKEN_TYPE_BLOCK_COMMENT) { if ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_BLOCK_COMMENT) { - $return .= "\n" . str_repeat($tab,$indent_level); + $indent = str_repeat($tab,$indent_level); + $return .= "\n" . $indent; + $highlighted = str_replace("\n","\n".$indent,$highlighted); } $return .= $highlighted; diff --git a/tests/format-highlight.html b/tests/format-highlight.html index 095f770..15908b1 100644 --- a/tests/format-highlight.html +++ b/tests/format-highlight.html @@ -738,7 +738,7 @@ <span style="color: #333;">MyTable</span> <span style="color: #aaa;"># One final comment</span> <span style="color: #aaa;">/* This is a block comment -*/</span> + */</span> <span style="font-weight:bold;">WHERE</span> <span style="color: green;">1</span> <span >=</span> <span style="color: green;">2</span><span >;</span></pre> diff --git a/tests/format.html b/tests/format.html index 19212c6..6c88c75 100644 --- a/tests/format.html +++ b/tests/format.html @@ -738,7 +738,7 @@ FROM MyTable # One final comment /* This is a block comment -*/ + */ WHERE 1 = 2; |