1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-06 13:16:45 +02:00

feat(shortcodes): add ability to use textile directive with textile

This commit is contained in:
Awilum
2022-05-27 18:08:46 +03:00
parent c74dab9c61
commit f3247c618c
2 changed files with 20 additions and 5 deletions

View File

@@ -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';
});

View File

@@ -2,7 +2,17 @@
declare(strict_types=1);
test('[textile] shortcode', function () {
$this->assertEquals("<p><b>Foo</b></p>",
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("<p><b>Foo</b></p>", parsers()->shortcodes()->parse('(textile)**Foo**(/textile)'));
expect(entries()->create('textile', ['test' => '(textile) **Foo**']))->toBeTrue();
expect(entries()->fetch('textile')['test'])->toBe("<p> <b>Foo</b></p>");
});