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:
@@ -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';
|
||||
});
|
@@ -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>");
|
||||
});
|
||||
|
Reference in New Issue
Block a user