switch to default_attributes extension
This commit is contained in:
parent
65460e9852
commit
dcbb974022
27
src/wiki.php
27
src/wiki.php
|
@ -2,13 +2,16 @@
|
|||
|
||||
namespace tildeteam;
|
||||
|
||||
use League\CommonMark\Extension\TableOfContents\TableOfContentsExtension;
|
||||
use Mni\FrontYAML;
|
||||
use League\CommonMark\Environment\Environment;
|
||||
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
|
||||
use League\CommonMark\Extension\CommonMark\Node\Block\BlockQuote;
|
||||
use League\CommonMark\Extension\DefaultAttributes\DefaultAttributesExtension;
|
||||
use League\CommonMark\Extension\HeadingPermalink\HeadingPermalinkExtension;
|
||||
use League\CommonMark\Extension\TableOfContents\TableOfContentsExtension;
|
||||
use League\CommonMark\Extension\Table\Table;
|
||||
use League\CommonMark\Extension\Table\TableExtension;
|
||||
use League\CommonMark\MarkdownConverter;
|
||||
use Mni\FrontYAML;
|
||||
|
||||
class wiki implements FrontYAML\Markdown\MarkdownParser
|
||||
{
|
||||
|
@ -17,23 +20,25 @@ class wiki implements FrontYAML\Markdown\MarkdownParser
|
|||
public function __construct(bool $bootstrap)
|
||||
{
|
||||
$config = [
|
||||
'table' => [
|
||||
'wrap' => [
|
||||
'enabled' => $bootstrap,
|
||||
'tag' => 'div',
|
||||
'attributes' => ['class' => 'table table-striped']
|
||||
]
|
||||
],
|
||||
'heading_permalink' => [
|
||||
'id_prefix' => '',
|
||||
'fragment_prefix' => '',
|
||||
'symbol' => '#',
|
||||
'html_class' => 'text-warning'
|
||||
]
|
||||
'html_class' => 'text-warning',
|
||||
],
|
||||
'default_attributes' => [
|
||||
Table::class => [
|
||||
'class' => $bootstrap ? ['table', 'table-responsive', 'table-hover', 'table-striped'] : [],
|
||||
],
|
||||
BlockQuote::class => [
|
||||
'class' => $bootstrap ? 'blockquote' : '',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$env = new Environment($config);
|
||||
$env->addExtension(new CommonMarkCoreExtension());
|
||||
$env->addExtension(new DefaultAttributesExtension());
|
||||
$env->addExtension(new HeadingPermalinkExtension());
|
||||
$env->addExtension(new TableExtension());
|
||||
$env->addExtension(new TableOfContentsExtension());
|
||||
|
|
|
@ -58,7 +58,7 @@ final class WikiTest extends TestCase
|
|||
| --- | --- | --- | ---|
|
||||
| [breadpunk.club](https://breadpunk.club) | breadpunk.club is a small tilde focused on bread-making and community-building. see the [manifesto](https://breadpunk.club/docs/manifesto/) for more information on our mission. | [signup information here](https://breadpunk.club/join/) | |';
|
||||
$this->assertEquals(
|
||||
'<div class="table table-striped"><table>
|
||||
'<table class="table table-responsive table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>tilde name</th>
|
||||
|
@ -75,7 +75,7 @@ final class WikiTest extends TestCase
|
|||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</table>
|
||||
'
|
||||
,
|
||||
$parser->parse($table)->getContent()
|
||||
|
|
Loading…
Reference in New Issue