mirror of
https://github.com/flextype/flextype.git
synced 2025-08-06 13:16:45 +02:00
feat(shortcodes): add ability to use markdown directive with markdown
shortcode
This commit is contained in:
@@ -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';
|
||||
});
|
@@ -2,7 +2,17 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
test('[markdown] shortcode', function () {
|
||||
$this->assertEquals("<p><strong>Foo</strong></p>\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("<p><strong>Foo</strong></p>\n", parsers()->shortcodes()->parse('(markdown)**Foo**(/markdown)'));
|
||||
|
||||
expect(entries()->create('md', ['test' => '(markdown) **Foo**']))->toBeTrue();
|
||||
expect(entries()->fetch('md')['test'])->toBe("<p> <strong>Foo</strong></p>");
|
||||
});
|
||||
|
Reference in New Issue
Block a user