Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
16 changes: 8 additions & 8 deletions app/Libraries/BBCodeForDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ public function parseAudio($text)
*/
public function parseBlockSimple($text)
{
foreach (['centre'] as $tag) {
$text = preg_replace(
"#\[{$tag}](.*?)\[/{$tag}\]#s",
"[{$tag}:{$this->uid}]\\1[/{$tag}:{$this->uid}]",
$text
);
}
foreach (['centre', 'right'] as $tag) {
$text = preg_replace(
"#\[{$tag}](.*?)\[/{$tag}\]#s",
"[{$tag}:{$this->uid}]\\1[/{$tag}:{$this->uid}]",
$text
);
}

return $text;
return $text;
}

public function parseBox($text)
Expand Down
15 changes: 12 additions & 3 deletions app/Libraries/BBCodeFromDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,19 @@ public function parseBoxHelperSuffix()

public function parseCentre($text)
{
$text = str_replace("[centre:{$this->uid}]", '<center>', $text);
$text = str_replace("[/centre:{$this->uid}]", '</center>', $text);
$text = str_replace("[centre:{$this->uid}]", "<div class='bbcode--centre'>", $text);
$text = str_replace("[/centre:{$this->uid}]", '</div>', $text);

return $text;
}

public function parseRight($text)
{
$text = str_replace("[right:{$this->uid}]", "<div class='bbcode--right'>", $text);
$text = str_replace("[/right:{$this->uid}]", '</div>', $text);

return $text;
}

public function parseCode($text)
{
Expand Down Expand Up @@ -372,6 +380,7 @@ public function toHTML()
$text = $this->parseAudio($text);
$text = $this->parseBold($text);
$text = $this->parseCentre($text);
$text = $this->parseRight($text);
$text = $this->parseInlineCode($text);
$text = $this->parseColour($text);
$text = $this->parseEmail($text);
Expand Down Expand Up @@ -433,7 +442,7 @@ public static function removeBBCodeTags($text)
// Don't care if too many characters are stripped;
// just don't want tags to go into index because they mess up the highlighting.

static $pattern = '#\[/?(\*|\*:m|audio|b|box|color|spoilerbox|centre|code|email|heading|i|img|list|list:o|list:u|notice|profile|quote|s|strike|u|spoiler|size|url|youtube)(=.*?(?=:))?(:[a-zA-Z0-9]{1,5})?\]#';
static $pattern = '#\[/?(\*|\*:m|audio|b|box|color|spoilerbox|centre|right|code|email|heading|i|img|list|list:o|list:u|notice|profile|quote|s|strike|u|spoiler|size|url|youtube)(=.*?(?=:))?(:[a-zA-Z0-9]{1,5})?\]#';

return preg_replace($pattern, '', $text);
}
Expand Down
35 changes: 35 additions & 0 deletions resources/css/bbcode.less
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,41 @@
font-style: normal;
font-weight: bold;
}
// centre, right blocks
&--centre {
text-align: center;
}

&--right {
text-align: right;
}

// same as below
&--centre img,
&--centre iframe,
&--centre .imagemap,
&--centre .js-spoilerbox,
&--centre .bbcode-spoilerbox {
display: block;
margin-left: auto;
margin-right: auto;
}

// this seems unnecessary , but is a good precaution
&--right img,
&--right iframe,
&--right .imagemap,
&--right .js-spoilerbox,
&--right .bbcode-spoilerbox {
display: block;
margin-left: auto;
margin-right: 0;
}
&--centre .imagemap,
&--right .imagemap {
width: fit-content;
max-width: 100%;
}

// heading tag
h2 {
Expand Down