diff --git a/src/flextype/core/Parsers/Shortcodes/MarkdownShortcode.php b/src/flextype/core/Parsers/Shortcodes/MarkdownShortcode.php index fa4b27fc..83267429 100644 --- a/src/flextype/core/Parsers/Shortcodes/MarkdownShortcode.php +++ b/src/flextype/core/Parsers/Shortcodes/MarkdownShortcode.php @@ -21,10 +21,15 @@ use function parsers; // Shortcode: markdown // Usage: (markdown) markdown text here (/markdown) +// (markdown) markdown text here parsers()->shortcodes()->addHandler('markdown', static function (ShortcodeInterface $s) { if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.markdown.enabled')) { return ''; } - return parsers()->markdown()->parse(parsers()->shortcodes()->parse($s->getContent())); + if ($s->getContent() != null) { + return parsers()->markdown()->parse(parsers()->shortcodes()->parse($s->getContent())); + } + + return '@markdown'; }); \ No newline at end of file diff --git a/tests/src/flextype/core/Parsers/Shortcodes/MarkdownShortcodeTest.php b/tests/src/flextype/core/Parsers/Shortcodes/MarkdownShortcodeTest.php index d9b46303..f299046d 100644 --- a/tests/src/flextype/core/Parsers/Shortcodes/MarkdownShortcodeTest.php +++ b/tests/src/flextype/core/Parsers/Shortcodes/MarkdownShortcodeTest.php @@ -2,7 +2,17 @@ declare(strict_types=1); -test('[markdown] shortcode', function () { - $this->assertEquals("

Foo

\n", - parsers()->shortcodes()->parse('(markdown)**Foo**(/markdown)')); +beforeEach(function() { + filesystem()->directory(PATH['project'] . '/entries')->ensureExists(0755, true); +}); + +afterEach(function () { + filesystem()->directory(PATH['project'] . '/entries')->delete(); +}); + +test('markdown shortcode', function () { + $this->assertEquals("

Foo

\n", parsers()->shortcodes()->parse('(markdown)**Foo**(/markdown)')); + + expect(entries()->create('md', ['test' => '(markdown) **Foo**']))->toBeTrue(); + expect(entries()->fetch('md')['test'])->toBe("

Foo

"); });