Add class into the li markup which contains checkbox

master 0.0.2
Simon Leblanc 7 years ago
parent 6bf5917da0
commit abd857aafc

@ -10,7 +10,7 @@
class ParsedownCheckbox extends ParsedownExtra
{
const VERSION = '0.0.1';
const VERSION = '0.0.2';
protected function blockListComplete($block)
{
@ -41,9 +41,11 @@ class ParsedownCheckbox extends ParsedownExtra
if ('[ ] ' === $begin_line) {
$block['element']['text'][$iterator_element]['text'][$iterator_text] = '<input type="checkbox" disabled /> '.
substr(trim($block['element']['text'][$iterator_element]['text'][$iterator_text]), 4);
$block['element']['text'][$iterator_element]['attributes'] = ['class' => 'parsedown-task-list parsedown-task-list-open'];
} elseif ('[x] ' === $begin_line) {
$block['element']['text'][$iterator_element]['text'][$iterator_text] = '<input type="checkbox" checked disabled /> '.
substr(trim($block['element']['text'][$iterator_element]['text'][$iterator_text]), 4);
$block['element']['text'][$iterator_element]['attributes'] = ['class' => 'parsedown-task-list parsedown-task-list-close'];
}
}
}

@ -16,12 +16,12 @@ EOF;
$html = <<<EOF
<ul>
<li><input type="checkbox" disabled /> test 1</li>
<li class="parsedown-task-list parsedown-task-list-open"><input type="checkbox" disabled /> test 1</li>
<li>[] test 2</li>
<li><input type="checkbox" checked disabled /> test 3
<li class="parsedown-task-list parsedown-task-list-close"><input type="checkbox" checked disabled /> test 3
<ul>
<li><input type="checkbox" disabled /> test 4</li>
<li><input type="checkbox" checked disabled /> test 5</li>
<li class="parsedown-task-list parsedown-task-list-open"><input type="checkbox" disabled /> test 4</li>
<li class="parsedown-task-list parsedown-task-list-close"><input type="checkbox" checked disabled /> test 5</li>
</ul></li>
<li><a href="https://markdown.org">test</a> 6</li>
<li><a href="https://markdown.org">x</a> test 7</li>

Loading…
Cancel
Save