Skip to content

Commit

Permalink
add code tag wrapper for code body
Browse files Browse the repository at this point in the history
  • Loading branch information
Gemorroj committed Jan 14, 2014
1 parent 4d30643 commit bb60b4a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Tests/Xbbcode/Tag/CodeTest.php
Expand Up @@ -8,7 +8,7 @@ class CodeTest extends \PHPUnit_Framework_TestCase
public function testTag()
{
$text = 'test [code]xBBCode[/code].';
$result = 'test <div class="bb_code"><div class="bb_code_header"><span class="bb_code_lang">Text</span></div>xBBCode</div>.';
$result = 'test <div class="bb_code"><div class="bb_code_header"><span class="bb_code_lang">Text</span></div><code class="bb_code">xBBCode</code></div>.';

$xbbcode = new Xbbcode();
$xbbcode->parse($text);
Expand All @@ -18,7 +18,7 @@ public function testTag()
public function testTagPhp()
{
$text = 'test [php]echo "xBBCode";[/php].';
$result = 'test <div class="bb_code"><div class="bb_code_header"><span class="bb_code_lang">PHP</span></div><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;xBBCode&quot;</span><span style="color: #339933;">;</span></div>.';
$result = 'test <div class="bb_code"><div class="bb_code_header"><span class="bb_code_lang">PHP</span></div><code class="bb_code"><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;xBBCode&quot;</span><span style="color: #339933;">;</span></code></div>.';

$xbbcode = new Xbbcode();
$xbbcode->parse($text);
Expand All @@ -28,7 +28,7 @@ public function testTagPhp()
public function testTagPhpKeywords()
{
$text = 'test [php]function_exists("function_exists");[/php].';
$result = 'test <div class="bb_code"><div class="bb_code_header"><span class="bb_code_lang">PHP</span></div><a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;function_exists&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div>.';
$result = 'test <div class="bb_code"><div class="bb_code_header"><span class="bb_code_lang">PHP</span></div><code class="bb_code"><a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;function_exists&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></code></div>.';

$xbbcode = new Xbbcode();
$xbbcode->setKeywordLinks(true);
Expand Down
4 changes: 2 additions & 2 deletions Tests/Xbbcode/XbbcodeTest.php
Expand Up @@ -20,9 +20,9 @@ public function testBase()

$result = '<br />
Это <strong class="bb">пример</strong> работы парсера <a class="bb" href="https://github.com/Gemorroj/xBBCode">xBBCode</a>.<br />
<div class="bb_code"><div class="bb_code_header"><span class="bb_code_lang">PHP</span></div><span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Hello github!&quot;</span><span style="color: #339933;">;</span><br />
<div class="bb_code"><div class="bb_code_header"><span class="bb_code_lang">PHP</span></div><code class="bb_code"><span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Hello github!&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;github&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;world&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp;</div><br />
&nbsp;</code></div><br />
ссылка <a href="http://github.com/Gemorroj/xBBCode" target="_blank">http://github.com/Gemorroj/xBBCode</a><br />
картинка <img class="bb" src="https://0.gravatar.com/avatar/ee4c19dc191da0b322d7cfbb29ae36dc" alt="" /><br />
<img src="/resources/images/smiles/2.gif" alt="Well" /><br />
Expand Down
2 changes: 1 addition & 1 deletion src/Xbbcode/Tag/Code.php
Expand Up @@ -220,6 +220,6 @@ public function __toString()
$this->setExtra();
$this->setLinks();

return '<div class="bb_code">' . $this->getHeader() . $this->geshi->parse_code() . $this->getFooter() . '</div>';
return '<div class="bb_code">' . $this->getHeader() . '<code class="bb_code">' . $this->geshi->parse_code() . '</code>' . $this->getFooter() . '</div>';
}
}

0 comments on commit bb60b4a

Please sign in to comment.