Skip to content

Commit ec62038

Browse files
[right] bbcode alignment
1 parent c48b111 commit ec62038

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

app/Libraries/BBCodeForDB.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ public function parseAudio($text)
6262
/**
6363
* Handles:
6464
* - Centre (centre).
65+
* - Right (right).
6566
*/
6667
public function parseBlockSimple($text)
6768
{
68-
foreach (['centre'] as $tag) {
69+
foreach (['centre', 'right'] as $tag) {
6970
$text = preg_replace(
7071
"#\[{$tag}](.*?)\[/{$tag}\]#s",
7172
"[{$tag}:{$this->uid}]\\1[/{$tag}:{$this->uid}]",

app/Libraries/BBCodeFromDB.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ public function parseCentre($text)
9191
return $text;
9292
}
9393

94+
public function parseRight($text)
95+
{
96+
$text = str_replace("[right:{$this->uid}]", "<div class='right'>", $text);
97+
$text = str_replace("[/right:{$this->uid}]", '</div>', $text);
98+
99+
return $text;
100+
}
101+
94102
public function parseCode($text)
95103
{
96104
return preg_replace(
@@ -372,6 +380,7 @@ public function toHTML()
372380
$text = $this->parseAudio($text);
373381
$text = $this->parseBold($text);
374382
$text = $this->parseCentre($text);
383+
$text = $this->parseRight($text);
375384
$text = $this->parseInlineCode($text);
376385
$text = $this->parseColour($text);
377386
$text = $this->parseEmail($text);

resources/css/bbcode.less

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,24 @@
9292
font-size: inherit;
9393
}
9494

95+
.right {
96+
text-align: right;
97+
98+
img,
99+
iframe,
100+
audio,
101+
video,
102+
.js-audio--player,
103+
.imagemap {
104+
margin-left: auto;
105+
margin-right: 0;
106+
}
107+
108+
.bbcode-spoilerbox {
109+
display: inline-block;
110+
}
111+
}
112+
95113
.unordered {
96114
list-style-type: disc;
97115
}

0 commit comments

Comments
 (0)