mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-12-14 15:13:37 +08:00
29 lines
659 B
PHP
29 lines
659 B
PHP
<?php
|
|
|
|
namespace BookStack\Entities\Tools\Markdown;
|
|
|
|
use League\HTMLToMarkdown\Converter\ConverterInterface;
|
|
use League\HTMLToMarkdown\ElementInterface;
|
|
|
|
class CheckboxConverter implements ConverterInterface
|
|
{
|
|
public function convert(ElementInterface $element): string
|
|
{
|
|
if (strtolower($element->getAttribute('type')) === 'checkbox') {
|
|
$isChecked = $element->getAttribute('checked') === 'checked';
|
|
|
|
return $isChecked ? ' [x] ' : ' [ ] ';
|
|
}
|
|
|
|
return $element->getValue();
|
|
}
|
|
|
|
/**
|
|
* @return string[]
|
|
*/
|
|
public function getSupportedTags(): array
|
|
{
|
|
return ['input'];
|
|
}
|
|
}
|