Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove spaces after quotes #3078

Merged
merged 5 commits into from
Apr 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/Libraries/BBCodeFromDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ public function parseProfile($text)

public function parseQuote($text)
{
$text = preg_replace("#\[quote=&quot;([^:]+)&quot;:{$this->uid}\]#", '<h4>\\1 wrote:</h4><blockquote>', $text);
$text = str_replace("[quote:{$this->uid}]", '<blockquote>', $text);
$text = str_replace("[/quote:{$this->uid}]", '</blockquote>', $text);
$text = preg_replace("#\[quote=&quot;([^:]+)&quot;:{$this->uid}\]\s*#", '<h4>\\1 wrote:</h4><blockquote>', $text);
$text = preg_replace("#\[quote:{$this->uid}\]\s*#", '<blockquote>', $text);
$text = preg_replace("#\s*\[/quote:{$this->uid}\]\s*#", '</blockquote>', $text);

return $text;
}
Expand Down
1 change: 1 addition & 0 deletions resources/assets/less/bbcode.less
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

blockquote {
font-size: inherit;
padding-right: 0;
}

img {
Expand Down
1 change: 1 addition & 0 deletions resources/assets/less/bem/forum-post.less
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
flex: none;

padding: 20px 30px;
overflow: hidden;

&--edit-bar {
background-color: @gray-lighter;
Expand Down
8 changes: 5 additions & 3 deletions tests/Libraries/BBCodeForDBTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ public function testAll()
$path = __DIR__.'/bbcode_examples';

foreach (glob("{$path}/*.base.txt") as $baseFilePath) {
$dbFilePath = preg_replace("/\.base\.txt$/", '.db.txt', $baseFilePath);
$dbFilePath = preg_replace('/\.base\.txt$/', '.db.txt', $baseFilePath);
$text->text = trim(file_get_contents($baseFilePath));
$referenceDbOutput = trim(file_get_contents($dbFilePath));

$this->assertSame($referenceDbOutput, $text->generate());
$output = $this->normalizeHTML($text->generate());
$referenceOutput = $this->normalizeHTML(file_get_contents($dbFilePath));

$this->assertSame($referenceOutput, $output);
}
}
}
13 changes: 5 additions & 8 deletions tests/Libraries/BBCodeFromDBTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,13 @@ public function testAll()
$path = __DIR__.'/bbcode_examples';

foreach (glob("{$path}/*.db.txt") as $dbFilePath) {
$htmlFilePath = preg_replace("/\.db\.txt$/", '.html', $dbFilePath);
$htmlFilePath = preg_replace('/\.db\.txt$/', '.html', $dbFilePath);
$text->text = trim(file_get_contents($dbFilePath));
$referenceHtmlOutput = $this->wrapDiv(str_replace("\n", '', trim(file_get_contents($htmlFilePath))));

$this->assertSame($referenceHtmlOutput, $text->toHTML());
}
}
$output = $this->normalizeHTML($text->toHTML());
$referenceOutput = $this->normalizeHTML("<div class='bbcode'>".file_get_contents($htmlFilePath).'</div>');

private function wrapDiv($text)
{
return "<div class='bbcode'>{$text}</div>";
$this->assertSame($referenceOutput, $output);
}
}
}
11 changes: 11 additions & 0 deletions tests/Libraries/bbcode_examples/quote_newline.base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[quote]
Here is a quote.
[/quote]

Some text goes here.

[quote="some poster"]
And another quote with title.
[/quote]

And here is some other text.
11 changes: 11 additions & 0 deletions tests/Libraries/bbcode_examples/quote_newline.db.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[quote:1]
Here is a quote.
[/quote:1]

Some text goes here.

[quote=&quot;some poster&quot;:1]
And another quote with title.
[/quote:1]

And here is some other text.
12 changes: 12 additions & 0 deletions tests/Libraries/bbcode_examples/quote_newline.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<blockquote>
Here is a quote.
</blockquote>

Some text goes here.<br />
<br />
<h4>some poster wrote:</h4>
<blockquote>
And another quote with title.
</blockquote>

And here is some other text.
5 changes: 5 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,9 @@ protected function invokeProperty($obj, string $name)

return $property->getValue($obj);
}

protected function normalizeHTML($html)
{
return str_replace("\n", '', preg_replace("/>\s*</s", '><', trim($html)));
}
}