diff --git a/src/Controllers/LogController.php b/src/Controllers/LogController.php
index cf50fc26..31d9d0a4 100644
--- a/src/Controllers/LogController.php
+++ b/src/Controllers/LogController.php
@@ -57,7 +57,7 @@ class LogController
unset($line);
$lines = join(PHP_EOL, $lines);
- $lines = TextHelper::parseMarkdown($lines);
+ $lines = TextHelper::parseMarkdown($lines, true);
$lines = trim($lines);
$this->context->transport->filter = $filter;
diff --git a/src/CustomMarkdown.php b/src/CustomMarkdown.php
index ca180f1d..b7970a17 100644
--- a/src/CustomMarkdown.php
+++ b/src/CustomMarkdown.php
@@ -1,8 +1,11 @@
simple = $simple;
$this->no_markup = true;
$this->block_gamut += ['doSpoilers' => 71];
$this->span_gamut += ['doSearchPermalinks' => 72];
@@ -24,6 +27,35 @@ class CustomMarkdown extends \Michelf\Markdown
parent::__construct();
}
+ protected function formParagraphs($text)
+ {
+ if ($this->simple)
+ {
+ $text = preg_replace('/\A\n+|\n+\z/', '', $text);
+ $grafs = preg_split('/\n{2,}/', $text, -1, PREG_SPLIT_NO_EMPTY);
+ foreach ($grafs as $key => $value)
+ {
+ if (!preg_match('/^B\x1A[0-9]+B$/', $value))
+ {
+ $value = $this->runSpanGamut($value);
+ $grafs[$key] = $this->unhash($value);
+ }
+ else
+ {
+ $grafs[$key] = $this->html_hashes[$value];
+ }
+ }
+ return implode("\n\n", $grafs);
+ }
+ return parent::formParagraphs($text);
+ }
+
+ public static function simpleTransform($text)
+ {
+ $parser = new self(true);
+ return $parser->transform($text);
+ }
+
protected function doAutoLinks2($text)
{
$text = preg_replace_callback('{(?<\s]+)}i', [&$this, '_doAutoLinks_url_callback'], $text);
@@ -51,7 +83,7 @@ class CustomMarkdown extends \Michelf\Markdown
{
return preg_replace_callback('{(~~|---)([^~]+)\1}', function($x)
{
- return $this->hashPart('') . $x[2] . $this->hashPart('');
+ return $this->hashPart('' . $x[2] . '');
}, $text);
}
@@ -64,33 +96,37 @@ class CustomMarkdown extends \Michelf\Markdown
protected function doPosts($text)
{
- return preg_replace_callback('/(?:(? '_post_']);
+ return preg_replace_callback('/(?:(?hashPart('') . $x[0] . $this->hashPart('');
+ return $this->hashPart('' . $x[0] . '');
}, $text);
}
protected function doTags($text)
{
- return preg_replace_callback('/(?:(? '_query_']);
+ return preg_replace_callback('/(?:(?hashPart('') . $x[0] . $this->hashPart('');
+ return $this->hashPart('' . $x[0] . '');
}, $text);
}
protected function doUsers($text)
{
- return preg_replace_callback('/(?:(? '_name_']);
+ return preg_replace_callback('/(?:(?hashPart('') . $x[0] . $this->hashPart('');
+ return $this->hashPart('' . $x[0] . '');
}, $text);
}
protected function doSearchPermalinks($text)
{
- return preg_replace_callback('{\[search\]((?:[^\[]|\[(?!\/?search\]))+)\[\/search\]}is', function($x)
+ $link = \Chibi\UrlHelper::route('post', 'list', ['query' => '_query_']);
+ return preg_replace_callback('{\[search\]((?:[^\[]|\[(?!\/?search\]))+)\[\/search\]}is', function($x) use ($link)
{
- return $this->hashPart('') . $x[1] . $this->hashPart('');
+ return $this->hashPart('' . $x[1] . '');
}, $text);
}
}
diff --git a/src/Helpers/TextHelper.php b/src/Helpers/TextHelper.php
index a4af237f..2a453523 100644
--- a/src/Helpers/TextHelper.php
+++ b/src/Helpers/TextHelper.php
@@ -168,12 +168,12 @@ class TextHelper
return json_encode($obj, JSON_UNESCAPED_UNICODE);
}
- public static function parseMarkdown($text, $inline = false)
+ public static function parseMarkdown($text, $simple = false)
{
- $output = CustomMarkdown::defaultTransform($text);
- if ($inline)
- $output = preg_replace('{?p>}', '', $output);
- return $output;
+ if ($simple)
+ return CustomMarkdown::simpleTransform($text);
+ else
+ return CustomMarkdown::defaultTransform($text);
}
public static function reprPost($post)