diff --git a/src/flextype/core/Parsers/Shortcodes/TextileShortcode.php b/src/flextype/core/Parsers/Shortcodes/TextileShortcode.php index 815c7aee..22b5b720 100644 --- a/src/flextype/core/Parsers/Shortcodes/TextileShortcode.php +++ b/src/flextype/core/Parsers/Shortcodes/TextileShortcode.php @@ -20,11 +20,16 @@ use Thunder\Shortcode\Shortcode\ShortcodeInterface; use function parsers; // Shortcode: textile -// Usage: (textile) textile text here (/textile) +// Usage: (textile) markdown text here (/textile) +// (textile) markdown text here parsers()->shortcodes()->addHandler('textile', static function (ShortcodeInterface $s) { if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.textile.enabled')) { return ''; } - return parsers()->textile()->parse(parsers()->shortcodes()->parse($s->getContent())); + if ($s->getContent() != null) { + return parsers()->textile()->parse(parsers()->shortcodes()->parse($s->getContent())); + } + + return '@textile'; }); \ No newline at end of file diff --git a/tests/src/flextype/core/Parsers/Shortcodes/TextileShortcodeTest.php b/tests/src/flextype/core/Parsers/Shortcodes/TextileShortcodeTest.php index b56ce6d3..e481f4ae 100644 --- a/tests/src/flextype/core/Parsers/Shortcodes/TextileShortcodeTest.php +++ b/tests/src/flextype/core/Parsers/Shortcodes/TextileShortcodeTest.php @@ -2,7 +2,17 @@ declare(strict_types=1); -test('[textile] shortcode', function () { - $this->assertEquals("

Foo

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

Foo

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

Foo

"); });