fix: accept unordered_list_markers config in InlinesOnlyExtension
The unordered_list_markers option is declared in the shared 'commonmark' config schema by CommonMarkCoreExtension, but InlinesOnlyExtension did not declare it in its own schema for the same 'commonmark' namespace. Setting the option while using InlinesOnlyExtension therefore failed schema validation with 'Unexpected item commonmark unordered_list_markers'. Declare the option in InlinesOnlyExtension using the same definition so it is accepted. InlinesOnlyExtension does not render lists, so this only makes the option valid without changing rendering behaviour. Adds a regression test asserting the option is accepted and rendering still works. Closes #1015
This commit is contained in:
1 parent
44017a3016
commit
a17ed29842
2 files changed
+17
No files matched your search
@@ -30,6 +30,7 @@ final class InlinesOnlyExtension implements ConfigurableExtensionInterface
|
||||
'use_underscore' => Expect::bool(true),
|
||||
'enable_strong' => Expect::bool(true),
|
||||
'enable_em' => Expect::bool(true),
|
||||
'unordered_list_markers' => Expect::listOf('string')->min(1)->default(['*', '+', '-'])->mergeDefaults(false),
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
@@ -64,4 +64,20 @@ final class InlinesOnlyFunctionalTest extends TestCase
|
||||
[$markdown, $html],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* InlinesOnlyExtension reuses the shared 'commonmark' config schema, so the
|
||||
* option must be accepted even though it renders no lists.
|
||||
*
|
||||
* @see https://github.com/thephpleague/commonmark/issues/1015
|
||||
*/
|
||||
public function testUnorderedListMarkersConfigIsAccepted(): void
|
||||
{
|
||||
$environment = new Environment(['commonmark' => ['unordered_list_markers' => ['*']]]);
|
||||
$environment->addExtension(new InlinesOnlyExtension());
|
||||
$converter = new MarkdownConverter($environment);
|
||||
|
||||
$this->assertSame(['*'], $environment->getConfiguration()->get('commonmark/unordered_list_markers'));
|
||||
$this->assertSame('<em>foo</em>', \trim($converter->convert('*foo*')->getContent()));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user