From 3c696e825ec1dc5df2b5e62bc2faaefd08487b6d Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 5 Aug 2021 11:57:39 +0300 Subject: [PATCH 1/6] feat(tests): update tests for shortcodes #562 --- tests/src/flextype/Parsers/ShortcodeTest.php | 18 +++++++++--------- .../Shortcodes/EntriesShortcodeTest.php | 4 ++-- .../Parsers/Shortcodes/RawShortcodeTest.php | 2 +- .../Shortcodes/RegistryShortcodeTest.php | 4 ++-- .../Parsers/Shortcodes/UrlShortcodeTest.php | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/src/flextype/Parsers/ShortcodeTest.php b/tests/src/flextype/Parsers/ShortcodeTest.php index 15d7417b..2d58ee0f 100644 --- a/tests/src/flextype/Parsers/ShortcodeTest.php +++ b/tests/src/flextype/Parsers/ShortcodeTest.php @@ -20,19 +20,19 @@ test('test addEventHandler() method', function () { return 'Barz'; }); parsers()->shortcodes()->addEventHandler(Events::FILTER_SHORTCODES, new FilterRawEventHandler(['barz'])); - $this->assertEquals('Barz', parsers()->shortcodes()->process('[barz]')); + $this->assertEquals('Barz', parsers()->shortcodes()->parse('[barz]')); +}); + +test('test parseText() method', function () { + $this->assertInstanceOf(Thunder\Shortcode\ShortcodeFacade::class, parsers()->shortcodes()->addHandler('bar', static function() { return ''; })); + $this->assertTrue(is_array(parsers()->shortcodes()->parseText('[bar]'))); + $this->assertTrue(is_object(parsers()->shortcodes()->parseText('[bar]')[0])); }); test('test parse() method', function () { - $this->assertInstanceOf(Thunder\Shortcode\ShortcodeFacade::class, parsers()->shortcodes()->addHandler('bar', static function() { return ''; })); - $this->assertTrue(is_array(parsers()->shortcodes()->parse('[bar]'))); - $this->assertTrue(is_object(parsers()->shortcodes()->parse('[bar]')[0])); -}); - -test('test process() method', function () { $this->assertInstanceOf(Thunder\Shortcode\ShortcodeFacade::class, parsers()->shortcodes()->addHandler('zed', static function() { return 'Zed'; })); - $this->assertEquals('Zed', parsers()->shortcodes()->process('[zed]')); - $this->assertEquals('fòôBàřZed', parsers()->shortcodes()->process('fòôBàř[zed]')); + $this->assertEquals('Zed', parsers()->shortcodes()->parse('[zed]')); + $this->assertEquals('fòôBàřZed', parsers()->shortcodes()->parse('fòôBàř[zed]')); }); test('test getCacheID() method', function () { diff --git a/tests/src/flextype/Parsers/Shortcodes/EntriesShortcodeTest.php b/tests/src/flextype/Parsers/Shortcodes/EntriesShortcodeTest.php index 68965801..98f643cb 100644 --- a/tests/src/flextype/Parsers/Shortcodes/EntriesShortcodeTest.php +++ b/tests/src/flextype/Parsers/Shortcodes/EntriesShortcodeTest.php @@ -12,6 +12,6 @@ afterEach(function (): void { test('test entries_fetch shortcode', function () { $this->assertTrue(entries()->create('foo', ['title' => 'Foo'])); - $this->assertEquals('Foo', parsers()->shortcodes()->process('[entries_fetch id="foo" field="title"]')); - $this->assertEquals('Bar', parsers()->shortcodes()->process('[entries_fetch id="foo" field="bar" default="Bar"]')); + $this->assertEquals('Foo', parsers()->shortcodes()->parse('[entries_fetch id="foo" field="title"]')); + $this->assertEquals('Bar', parsers()->shortcodes()->parse('[entries_fetch id="foo" field="bar" default="Bar"]')); }); diff --git a/tests/src/flextype/Parsers/Shortcodes/RawShortcodeTest.php b/tests/src/flextype/Parsers/Shortcodes/RawShortcodeTest.php index 950da38c..ff76c00c 100644 --- a/tests/src/flextype/Parsers/Shortcodes/RawShortcodeTest.php +++ b/tests/src/flextype/Parsers/Shortcodes/RawShortcodeTest.php @@ -13,5 +13,5 @@ afterEach(function (): void { test('test raw shortcode', function () { $this->assertTrue(entries()->create('foo', ['title' => 'Foo'])); $this->assertEquals('[entries_fetch id="foo" field="title"]', - parsers()->shortcodes()->process('[raw][entries_fetch id="foo" field="title"][/raw]')); + parsers()->shortcodes()->parse('[raw][entries_fetch id="foo" field="title"][/raw]')); }); diff --git a/tests/src/flextype/Parsers/Shortcodes/RegistryShortcodeTest.php b/tests/src/flextype/Parsers/Shortcodes/RegistryShortcodeTest.php index 367a6c1e..7734d01c 100644 --- a/tests/src/flextype/Parsers/Shortcodes/RegistryShortcodeTest.php +++ b/tests/src/flextype/Parsers/Shortcodes/RegistryShortcodeTest.php @@ -4,7 +4,7 @@ declare(strict_types=1); test('test registry_get shortcode', function () { $this->assertEquals('Flextype', - parsers()->shortcodes()->process('[registry_get name="flextype.manifest.name"]')); + parsers()->shortcodes()->parse('[registry_get name="flextype.manifest.name"]')); $this->assertEquals('default-value', - parsers()->shortcodes()->process('[registry_get name="item-name" default="default-value"]')); + parsers()->shortcodes()->parse('[registry_get name="item-name" default="default-value"]')); }); diff --git a/tests/src/flextype/Parsers/Shortcodes/UrlShortcodeTest.php b/tests/src/flextype/Parsers/Shortcodes/UrlShortcodeTest.php index 382dbfe0..2cbaf12f 100644 --- a/tests/src/flextype/Parsers/Shortcodes/UrlShortcodeTest.php +++ b/tests/src/flextype/Parsers/Shortcodes/UrlShortcodeTest.php @@ -5,5 +5,5 @@ declare(strict_types=1); test('test registry_get shortcode', function () { registry()->set('flextype.settings.url', 'https://flextype.org'); - $this->assertStringContainsString('https://flextype.org', parsers()->shortcodes()->process('[url]')); + $this->assertStringContainsString('https://flextype.org', parsers()->shortcodes()->parse('[url]')); }); From b8c70d35c3477d99a311e6761dff6b04f7520161 Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 5 Aug 2021 11:58:09 +0300 Subject: [PATCH 2/6] feat(parsers): update codebase for shortcodes #562 --- src/flextype/Entries/Fields/ParsersField.php | 2 +- src/flextype/Parsers/Shortcodes.php | 34 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/flextype/Entries/Fields/ParsersField.php b/src/flextype/Entries/Fields/ParsersField.php index ff096b0b..0b1640f0 100644 --- a/src/flextype/Entries/Fields/ParsersField.php +++ b/src/flextype/Entries/Fields/ParsersField.php @@ -29,7 +29,7 @@ if (registry()->get('flextype.settings.entries.fields.parsers.enabled')) { if ($parserName == 'shortcodes') { if (arrays(entries()->registry()->get('fetch.data'))->has($field)) { entries()->registry()->set('fetch.data.'.$field, - parsers()->shortcodes()->process(entries()->registry()->get('fetch.data.'.$field), $cache)); + parsers()->shortcodes()->parse(entries()->registry()->get('fetch.data.'.$field), $cache)); } } } diff --git a/src/flextype/Parsers/Shortcodes.php b/src/flextype/Parsers/Shortcodes.php index 6d95ae93..12c94c2b 100644 --- a/src/flextype/Parsers/Shortcodes.php +++ b/src/flextype/Parsers/Shortcodes.php @@ -18,12 +18,12 @@ use function strings; final class Shortcodes { /** - * Registry instance + * Shortcodes instance. */ private static ?Shortcodes $instance = null; /** - * Shortcode facade + * Shortcode facade. */ private $shortcodeFacade = null; @@ -44,7 +44,7 @@ final class Shortcodes } /** - * Shortcode construct + * Shortcode construct. */ protected function __construct() { @@ -52,7 +52,7 @@ final class Shortcodes } /** - * Gets the instance via lazy initialization (created on first usage) + * Gets the instance via lazy initialization (created on first usage). */ public static function getInstance(): Shortcodes { @@ -64,7 +64,7 @@ final class Shortcodes } /** - * Shortcode facade + * Shortcode facade. */ public function facade(): ShortcodeFacade { @@ -76,7 +76,7 @@ final class Shortcodes */ public function initShortcodes(): void { - $shortcodes = registry()->get('flextype.settings.parsers.shortcodes'); + $shortcodes = registry()->get('flextype.settings.parsers.shortcodes.shortcodes'); if ( ! isset($shortcodes) || @@ -103,8 +103,8 @@ final class Shortcodes /** * Add shortcode handler. * - * @param string $name Shortcode - * @param callable $handler Handler + * @param string $name Shortcode. + * @param callable $handler Handler. * * @access public */ @@ -116,8 +116,8 @@ final class Shortcodes /** * Add event handler. * - * @param string $name Event - * @param callable $handler Handler + * @param string $name Event. + * @param callable $handler Handler. * * @access public */ @@ -133,20 +133,20 @@ final class Shortcodes * * @access public */ - public function parse(string $input) + public function parseText(string $input) { return $this->facade()->parse($input); } /** - * Processes text and replaces shortcodes. + * Parse and processes text to replaces shortcodes. * * @param string $input A text containing SHORTCODE - * @param bool $cache Cache result data or no. Default is true + * @param bool $cache Cache result data or no. Default is true. * * @access public */ - public function process(string $input, bool $cache = true) + public function parse(string $input, bool $cache = true) { if ($cache === true && registry()->get('flextype.settings.cache.enabled') === true) { $key = $this->getCacheID($input); @@ -165,11 +165,11 @@ final class Shortcodes } /** - * Get Cache ID for shortcode + * Get Cache ID for shortcode. * - * @param string $input Input + * @param string $input Input. * - * @return string Cache ID + * @return string Cache ID. * * @access public */ From 47500c8f28d21098147cc41753b490da1a00e872 Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 5 Aug 2021 13:13:12 +0300 Subject: [PATCH 3/6] feat(parsers): update codebase for shortcodes and markdown #562 --- src/flextype/Parsers/Markdown.php | 135 ++++++++++++++++++ src/flextype/Parsers/Parsers.php | 9 ++ src/flextype/Parsers/Shortcodes.php | 4 +- .../Parsers/Shortcodes/EntriesShortcode.php | 2 +- .../Parsers/Shortcodes/MediaShortcode.php | 2 +- .../Parsers/Shortcodes/RawShortcode.php | 2 +- .../Parsers/Shortcodes/RegistryShortcode.php | 2 +- .../Parsers/Shortcodes/UrlShortcode.php | 2 +- src/flextype/settings.yaml | 53 ++++--- tests/src/flextype/Parsers/MarkdownTest.php | 16 +++ 10 files changed, 203 insertions(+), 24 deletions(-) create mode 100644 src/flextype/Parsers/Markdown.php create mode 100644 tests/src/flextype/Parsers/MarkdownTest.php diff --git a/src/flextype/Parsers/Markdown.php b/src/flextype/Parsers/Markdown.php new file mode 100644 index 00000000..2c713842 --- /dev/null +++ b/src/flextype/Parsers/Markdown.php @@ -0,0 +1,135 @@ +environment = new Environment(registry()->get('flextype.settings.parsers.markdown.commonmark')); + $this->environment->addExtension(new CommonMarkCoreExtension()); + $this->environment->addExtension(new AttributesExtension()); + $this->environment->addExtension(new TableExtension()); + $this->converter = new MarkdownConverter($this->environment); + } + + /** + * Markdown Environment + */ + public function environment(): Environment + { + return $this->environment; + } + + /** + * Markdown Converter + */ + public function converter(): MarkdownConverter + { + return $this->converter; + } + + /** + * Gets the instance via lazy initialization (created on first usage). + */ + public static function getInstance(): Markdown + { + if (static::$instance === null) { + static::$instance = new self(); + } + + return static::$instance; + } + + /** + * Takes a MARKDOWN encoded string and converts it into a PHP variable. + * + * @param string $input A string containing MARKDOWN + * + * @return mixed The MARKDOWN converted to a PHP value + */ + public function parse(string $input) + { + $cache = registry()->get('flextype.settings.parsers.markdown.cache'); + + if ($cache === true && registry()->get('flextype.settings.cache.enabled') === true) { + $key = $this->getCacheID($input); + + if ($dataFromCache = cache()->get($key)) { + return $dataFromCache; + } + + $data = $this->converter()->convertToHtml($input)->getContent(); + cache()->set($key, $data); + + return $data; + } + + return $this->converter()->convertToHtml($input)->getContent(); + } + + /** + * Get Cache ID for markdown. + * + * @param string $input Input. + * + * @return string Cache ID. + * + * @access public + */ + public function getCacheID(string $input): string + { + return strings('markdown' . $input)->hash()->toString(); + } +} \ No newline at end of file diff --git a/src/flextype/Parsers/Parsers.php b/src/flextype/Parsers/Parsers.php index 5a04adbc..64c7ced1 100644 --- a/src/flextype/Parsers/Parsers.php +++ b/src/flextype/Parsers/Parsers.php @@ -11,6 +11,7 @@ namespace Flextype\Parsers; use Atomastic\Macroable\Macroable; use Flextype\Parsers\Shortcodes; +use Flextype\Parsers\Markdown; class Parsers { @@ -23,4 +24,12 @@ class Parsers { return Shortcodes::getInstance(); } + + /** + * Create a Markdown instance. + */ + public function markdown(): Markdown + { + return Markdown::getInstance(); + } } diff --git a/src/flextype/Parsers/Shortcodes.php b/src/flextype/Parsers/Shortcodes.php index 12c94c2b..05158fa1 100644 --- a/src/flextype/Parsers/Shortcodes.php +++ b/src/flextype/Parsers/Shortcodes.php @@ -146,8 +146,10 @@ final class Shortcodes * * @access public */ - public function parse(string $input, bool $cache = true) + public function parse(string $input) { + $cache = registry()->get('flextype.settings.parsers.shortcodes.cache'); + if ($cache === true && registry()->get('flextype.settings.cache.enabled') === true) { $key = $this->getCacheID($input); diff --git a/src/flextype/Parsers/Shortcodes/EntriesShortcode.php b/src/flextype/Parsers/Shortcodes/EntriesShortcode.php index d755ee0b..02dcdd3e 100644 --- a/src/flextype/Parsers/Shortcodes/EntriesShortcode.php +++ b/src/flextype/Parsers/Shortcodes/EntriesShortcode.php @@ -12,7 +12,7 @@ namespace Flextype\Parsers\Shortcodes; use Thunder\Shortcode\Shortcode\ShortcodeInterface; // Shortcode: [entries_fetch id="entry-id" field="field-name" default="default-value"] -if (registry()->get('flextype.settings.parsers.shortcodes.entries.enabled')) { +if (registry()->get('flextype.settings.parsers.shortcodes.shortcodes.entries.enabled')) { parsers()->shortcodes()->addHandler('entries_fetch', static function (ShortcodeInterface $s) { return arrays(entries()->fetch($s->getParameter('id')))->get($s->getParameter('field'), $s->getParameter('default')); }); diff --git a/src/flextype/Parsers/Shortcodes/MediaShortcode.php b/src/flextype/Parsers/Shortcodes/MediaShortcode.php index 69038f68..26bbde31 100644 --- a/src/flextype/Parsers/Shortcodes/MediaShortcode.php +++ b/src/flextype/Parsers/Shortcodes/MediaShortcode.php @@ -12,7 +12,7 @@ namespace Flextype\Parsers\Shortcodes; use Thunder\Shortcode\Shortcode\ShortcodeInterface; // Shortcode: [media_files_fetch id="media-id" field="field-name" default="default-value"] -if (registry()->get('flextype.settings.parsers.shortcodes.media.enabled')) { +if (registry()->get('flextype.settings.parsers.shortcodes.shortcodes.media.enabled')) { parsers()->shortcodes()->addHandler('media_files_fetch', static function (ShortcodeInterface $s) { return arrays(flextype('media')->files()->fetch($s->getParameter('id')))->get($s->getParameter('field'), $s->getParameter('default')); }); diff --git a/src/flextype/Parsers/Shortcodes/RawShortcode.php b/src/flextype/Parsers/Shortcodes/RawShortcode.php index c343c493..47c114ec 100644 --- a/src/flextype/Parsers/Shortcodes/RawShortcode.php +++ b/src/flextype/Parsers/Shortcodes/RawShortcode.php @@ -14,7 +14,7 @@ use Thunder\Shortcode\Events; use Thunder\Shortcode\Shortcode\ShortcodeInterface; // Shortcode: [raw] -if (registry()->get('flextype.settings.parsers.shortcodes.raw.enabled')) { +if (registry()->get('flextype.settings.parsers.shortcodes.shortcodes.raw.enabled')) { parsers()->shortcodes()->addHandler('raw', static function (ShortcodeInterface $s) { return $s->getContent(); }); diff --git a/src/flextype/Parsers/Shortcodes/RegistryShortcode.php b/src/flextype/Parsers/Shortcodes/RegistryShortcode.php index 1afe00f6..88d66861 100644 --- a/src/flextype/Parsers/Shortcodes/RegistryShortcode.php +++ b/src/flextype/Parsers/Shortcodes/RegistryShortcode.php @@ -12,7 +12,7 @@ namespace Flextype\Parsers\Shortcodes; use Thunder\Shortcode\Shortcode\ShortcodeInterface; // Shortcode: [registry_get name="item-name" default="default-value"] -if (registry()->get('flextype.settings.parsers.shortcodes.registry.enabled')) { +if (registry()->get('flextype.settings.parsers.shortcodes.shortcodes.registry.enabled')) { parsers()->shortcodes()->addHandler('registry_get', static function (ShortcodeInterface $s) { return registry()->get($s->getParameter('name'), $s->getParameter('default')); }); diff --git a/src/flextype/Parsers/Shortcodes/UrlShortcode.php b/src/flextype/Parsers/Shortcodes/UrlShortcode.php index 366696dc..f8341c3d 100644 --- a/src/flextype/Parsers/Shortcodes/UrlShortcode.php +++ b/src/flextype/Parsers/Shortcodes/UrlShortcode.php @@ -13,7 +13,7 @@ use Slim\Http\Environment; use Slim\Http\Uri; // Shortcode: [url] -if (registry()->get('flextype.settings.parsers.shortcodes.url.enabled')) { +if (registry()->get('flextype.settings.parsers.shortcodes.shortcodes.url.enabled')) { parsers()->shortcodes()->addHandler('url', static function () { if (registry()->has('flextype.settings.url') && registry()->get('flextype.settings.url') !== '') { return registry()->get('flextype.settings.url'); diff --git a/src/flextype/settings.yaml b/src/flextype/settings.yaml index a465438f..8c86e946 100644 --- a/src/flextype/settings.yaml +++ b/src/flextype/settings.yaml @@ -417,26 +417,43 @@ serializers: # Parsers # -# Shortcode -# -# - shortcodes: Flextype Shortcodes to load. parsers: + markdown: + cache: true + commonmark: + renderer: + block_separator: "\n" + inner_separator: "\n" + soft_break: "\n" + commonmark: + enable_em: true + enable_strong: true + use_asterisk: true + use_underscore: true + unordered_list_markers: ['-', '*', '+'] + html_input: 'allow' + allow_unsafe_links: false + max_nesting_level: 9223372036854775807 + slug_normalizer: + max_length: 255 shortcodes: - media: - path: "/src/flextype/Parsers/Shortcodes/MediaShortcode.php" - enabled: true - entries: - path: "/src/flextype/Parsers/Shortcodes/EntriesShortcode.php" - enabled: true - raw: - path: "/src/flextype/Parsers/Shortcodes/RawShortcode.php" - enabled: true - registry: - path: "/src/flextype/Parsers/Shortcodes/RegistryShortcode.php" - enabled: true - url: - path: "/src/flextype/Parsers/Shortcodes/UrlShortcode.php" - enabled: true + cache: true + shortcodes: + media: + path: "/src/flextype/Parsers/Shortcodes/MediaShortcode.php" + enabled: true + entries: + path: "/src/flextype/Parsers/Shortcodes/EntriesShortcode.php" + enabled: true + raw: + path: "/src/flextype/Parsers/Shortcodes/RawShortcode.php" + enabled: true + registry: + path: "/src/flextype/Parsers/Shortcodes/RegistryShortcode.php" + enabled: true + url: + path: "/src/flextype/Parsers/Shortcodes/UrlShortcode.php" + enabled: true # CORS # diff --git a/tests/src/flextype/Parsers/MarkdownTest.php b/tests/src/flextype/Parsers/MarkdownTest.php new file mode 100644 index 00000000..e79ece90 --- /dev/null +++ b/tests/src/flextype/Parsers/MarkdownTest.php @@ -0,0 +1,16 @@ +assertInstanceOf(Flextype\Parsers\Markdown::class, parsers()->markdown()->getInstance()); +}); + +test('test parse() method', function () { + $this->assertEquals('

Bold

', trim(parsers()->markdown()->parse('**Bold**'))); +}); + +test('test getCacheID() method', function () { + $this->assertNotEquals(parsers()->markdown()->getCacheID('**Bold**'), + parsers()->markdown()->getCacheID('**Bold Text**')); +}); From d56a10dc9ff0c13c16b33709c51018fb9dbe869c Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 5 Aug 2021 13:15:46 +0300 Subject: [PATCH 4/6] feat(parsers): update parser field for entries #562 --- src/flextype/Entries/Fields/ParsersField.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/flextype/Entries/Fields/ParsersField.php b/src/flextype/Entries/Fields/ParsersField.php index 0b1640f0..9c6d895a 100644 --- a/src/flextype/Entries/Fields/ParsersField.php +++ b/src/flextype/Entries/Fields/ParsersField.php @@ -19,13 +19,20 @@ if (registry()->get('flextype.settings.entries.fields.parsers.enabled')) { if (entries()->registry()->get('fetch.data.parsers') != null) { foreach (entries()->registry()->get('fetch.data.parsers') as $parserName => $parserData) { - if (in_array($parserName, ['shortcodes'])) { + if (in_array($parserName, ['shortcodes', 'markdown'])) { if (entries()->registry()->get('fetch.data.parsers.'.$parserName.'.enabled') === true) { if (entries()->registry()->get('fetch.data.parsers.'.$parserName.'.fields') != null) { if (is_array(entries()->registry()->get('fetch.data.parsers.'.$parserName.'.fields'))) { foreach (entries()->registry()->get('fetch.data.parsers.'.$parserName.'.fields') as $field) { if (! in_array($field, registry()->get('flextype.settings.entries.fields'))) { + if ($parserName == 'markdown') { + if (arrays(entries()->registry()->get('fetch.data'))->has($field)) { + entries()->registry()->set('fetch.data.'.$field, + parsers()->markdown()->parse(entries()->registry()->get('fetch.data.'.$field), $cache)); + } + } + if ($parserName == 'shortcodes') { if (arrays(entries()->registry()->get('fetch.data'))->has($field)) { entries()->registry()->set('fetch.data.'.$field, From d2e03c4a9f28c46b8cdcf6c3e1b73f242952fd0d Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 5 Aug 2021 13:24:36 +0300 Subject: [PATCH 5/6] feat(parsers): update settings #562 --- src/flextype/settings.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/flextype/settings.yaml b/src/flextype/settings.yaml index 8c86e946..3981585d 100644 --- a/src/flextype/settings.yaml +++ b/src/flextype/settings.yaml @@ -417,6 +417,19 @@ serializers: # Parsers # +# markdown.cache: Cache result data or no. Default is true. +# markdown.commonmark.renderer.block_separator: String to use for separating renderer block elements. +# markdown.commonmark.renderer.inner_separator: String to use for separating inner block contents. +# markdown.commonmark.renderer.soft_break: String to use for rendering soft breaks. +# markdown.commonmark.commonmark.enable_em: Disable parsing by setting to false; enable with true (default: true) +# markdown.commonmark.commonmark.enable_strong: Disable parsing by setting to false; enable with true (default: true) +# markdown.commonmark.commonmark.use_asterisk: Disable parsing of * for emphasis by setting to false; enable with true (default: true) +# markdown.commonmark.commonmark.use_underscore: Disable parsing of _ for emphasis by setting to false; enable with true (default: true) +# markdown.commonmark.commonmark.unordered_list_markers: Array of characters that can be used to indicate a bulleted list. +# markdown.commonmark.html_input: `strip` all HTML (equivalent to 'safe' => true). `allow` all HTML input as-is (default value; equivalent to `‘safe’ => false) `escape` Escape all HTML. +# markdown.commonmark.allow_unsafe_links: Remove risky link and image URLs by setting this to false (default: true). +# markdown.commonmark.max_nesting_level: The maximum nesting level for blocks (default: PHP_INT_MAX). Setting this to a positive integer can help protect against long parse times and/or segfaults if blocks are too deeply-nested. +# markdown.commonmark.slug_normalizer.max_length: Limits the size of generated slugs (defaults to 255 characters) parsers: markdown: cache: true From 0d11e008487dc66fbc400794c651606b6ba2b757 Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 5 Aug 2021 13:24:55 +0300 Subject: [PATCH 6/6] feat(composer): add league/commonmark #562 --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cee1f9cf..b0ba0435 100755 --- a/composer.json +++ b/composer.json @@ -57,7 +57,8 @@ "php-di/php-di": "^6.3.4", "php-di/slim-bridge": "^3.1.1", "middlewares/whoops": "^2.0", - "nette/neon": "^3.2" + "nette/neon": "^3.2", + "league/commonmark": "^2.0" }, "suggest": { "ext-zend-opcache": "Recommended for better performance",