mirror of
https://github.com/flextype/flextype.git
synced 2025-08-08 06:06:45 +02:00
feat(shortcodes): add [textile]
shortcode
This commit is contained in:
29
src/flextype/core/Parsers/Shortcodes/TextileShortcode.php
Normal file
29
src/flextype/core/Parsers/Shortcodes/TextileShortcode.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
|
||||
* and with the full functionality of a traditional CMS!
|
||||
*
|
||||
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
|
||||
*
|
||||
* Licensed under The MIT License.
|
||||
*
|
||||
* For full copyright and license information, please see the LICENSE
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*/
|
||||
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
use function parsers;
|
||||
|
||||
// Shortcode: [textile] textile text here [/textile]
|
||||
parsers()->shortcodes()->addHandler('textile', static function (ShortcodeInterface $s) {
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.textile.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return parsers()->textile()->parse($s->getContent());
|
||||
});
|
@@ -578,6 +578,9 @@ parsers:
|
||||
raw:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Parsers/Shortcodes/RawShortcode.php"
|
||||
textile:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Parsers/Shortcodes/TextileShortcode.php"
|
||||
markdown:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Parsers/Shortcodes/MarkdownShortcode.php"
|
||||
|
3
tests/fixtures/settings/settings.yaml
vendored
3
tests/fixtures/settings/settings.yaml
vendored
@@ -565,6 +565,9 @@ parsers:
|
||||
raw:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Parsers/Shortcodes/RawShortcode.php"
|
||||
textile:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Parsers/Shortcodes/TextileShortcode.php"
|
||||
markdown:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Parsers/Shortcodes/MarkdownShortcode.php"
|
||||
|
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
test('[textile] shortcode', function () {
|
||||
$this->assertEquals("<p><b>Foo</b></p>",
|
||||
parsers()->shortcodes()->parse('[textile]**Foo**[/textile]'));
|
||||
});
|
Reference in New Issue
Block a user