mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Render task list item inside label for correct accessibility
Fixes #3303
This commit is contained in:
parent
0abdeeef67
commit
c8257f8b72
2 changed files with 8 additions and 6 deletions
|
@ -50,10 +50,12 @@ func (r *HugoHTMLRenderer) ListItem(out *bytes.Buffer, text []byte, flags int) {
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case bytes.HasPrefix(text, []byte("[ ] ")):
|
case bytes.HasPrefix(text, []byte("[ ] ")):
|
||||||
text = append([]byte(`<input type="checkbox" disabled class="task-list-item">`), text[3:]...)
|
text = append([]byte(`<label><input type="checkbox" disabled class="task-list-item">`), text[3:]...)
|
||||||
|
text = append(text, []byte(`</label>`)...)
|
||||||
|
|
||||||
case bytes.HasPrefix(text, []byte("[x] ")) || bytes.HasPrefix(text, []byte("[X] ")):
|
case bytes.HasPrefix(text, []byte("[x] ")) || bytes.HasPrefix(text, []byte("[X] ")):
|
||||||
text = append([]byte(`<input type="checkbox" checked disabled class="task-list-item">`), text[3:]...)
|
text = append([]byte(`<label><input type="checkbox" checked disabled class="task-list-item">`), text[3:]...)
|
||||||
|
text = append(text, []byte(`</label>`)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Renderer.ListItem(out, text, flags)
|
r.Renderer.ListItem(out, text, flags)
|
||||||
|
|
|
@ -108,9 +108,9 @@ END
|
||||||
`, true, `<p>TODO:</p>
|
`, true, `<p>TODO:</p>
|
||||||
|
|
||||||
<ul class="task-list">
|
<ul class="task-list">
|
||||||
<li><input type="checkbox" checked disabled class="task-list-item"> On1</li>
|
<li><label><input type="checkbox" checked disabled class="task-list-item"> On1</label></li>
|
||||||
<li><input type="checkbox" checked disabled class="task-list-item"> On2</li>
|
<li><label><input type="checkbox" checked disabled class="task-list-item"> On2</label></li>
|
||||||
<li><input type="checkbox" disabled class="task-list-item"> Off</li>
|
<li><label><input type="checkbox" disabled class="task-list-item"> Off</label></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>END</p>
|
<p>END</p>
|
||||||
|
@ -122,7 +122,7 @@ END
|
||||||
{`* [ ] Off
|
{`* [ ] Off
|
||||||
|
|
||||||
END`, true, `<ul class="task-list">
|
END`, true, `<ul class="task-list">
|
||||||
<li><input type="checkbox" disabled class="task-list-item"> Off</li>
|
<li><label><input type="checkbox" disabled class="task-list-item"> Off</label></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>END</p>
|
<p>END</p>
|
||||||
|
|
Loading…
Reference in a new issue