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

Allow newline between various tags #2313

Merged
merged 17 commits into from Feb 8, 2018
Merged
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 16 additions & 5 deletions app/Libraries/BBCodeForDB.php
Expand Up @@ -97,7 +97,7 @@ function ($m) {
public function parseColour($text)
{
return preg_replace(
",\[(color=(?:#[[:xdigit:]]{6}|[[:alpha:]]+))\](.*?)\[(/color)\],",
",\[(color=(?:#[[:xdigit:]]{6}|[[:alpha:]]+))\](.*?)\[(/color)\],s",
"[\\1:{$this->uid}]\\2[\\3:{$this->uid}]",
$text
);
Expand Down Expand Up @@ -140,13 +140,12 @@ public function parseImage($text)
* - Italic (i)
* - Strike (strike, s)
* - Underline (u)
* - Heading (heading)
*/
public function parseInlineSimple($text)
{
foreach (['b', 'i', 'strike', 's', 'u', 'heading'] as $tag) {
foreach (['b', 'i', 'strike', 's', 'u'] as $tag) {
$text = preg_replace(
"#\[{$tag}](.*?)\[/{$tag}\]#",
"#\[{$tag}](.*?)\[/{$tag}\]#s",
"[{$tag}:{$this->uid}]\\1[/{$tag}:{$this->uid}]",
$text
);
Expand All @@ -155,6 +154,17 @@ public function parseInlineSimple($text)
return $text;
}

public function parseHeading($text)

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

{
$text = preg_replace(
"#\[heading](.*?)\[/heading\]#",
"[heading:{$this->uid}]\\1[/heading:{$this->uid}]",
$text
);

return $text;
}

public function parseLinks($text)
{
$spaces = ["(^|\s)", "((?:\.|\))?(?:$|\s|\n|\r))"];
Expand Down Expand Up @@ -239,7 +249,7 @@ public function parseQuote($text)
public function parseSize($text)
{
return preg_replace(
"#\[(size=(?:\d+))\](.+?)\[(/size)\]#",
"#\[(size=(?:\d+))\](.*?)\[(/size)\]#s",
"[\\1:{$this->uid}]\\2[\\3:{$this->uid}]",
$text
);
Expand Down Expand Up @@ -318,6 +328,7 @@ public function generate()
$text = $this->parseBlockSimple($text);
$text = $this->parseImage($text);
$text = $this->parseInlineSimple($text);
$text = $this->parseHeading($text);
$text = $this->parseAudio($text);
$text = $this->parseEmail($text);
$text = $this->parseUrl($text);
Expand Down