2022-03-22 10:56:51 -04:00
|
|
|
<?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';
|
2022-03-23 08:02:01 -04:00
|
|
|
|
2022-03-22 10:56:51 -04:00
|
|
|
return $isChecked ? ' [x] ' : ' [ ] ';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $element->getValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string[]
|
|
|
|
*/
|
|
|
|
public function getSupportedTags(): array
|
|
|
|
{
|
|
|
|
return ['input'];
|
|
|
|
}
|
2022-03-23 08:02:01 -04:00
|
|
|
}
|