diff options
author | Abdullah Diab <[email protected]> | 2017-07-29 20:52:45 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2017-08-02 00:33:37 +0200 |
commit | 481924b34d23b0ce435778cce7bce77571b22f9d (patch) | |
tree | 63788a8e1c8b69ce01d4887239b06118ba3af3c7 /helpers/content.go | |
parent | 09907d36af586c5b29389312f2ecc2962c06313c (diff) | |
download | hugo-481924b34d23b0ce435778cce7bce77571b22f9d.tar.gz hugo-481924b34d23b0ce435778cce7bce77571b22f9d.zip |
helpers: Fix broken TaskList in Markdown
As per the referenced issue, if the task list in Markdown has
nothing before it, it will be rendered wrongly:
```
---
title: "My First Post"
date: 2017-07-29T20:21:57+02:00
draft: true
---
* [ ] TaskList
```
is rendered as:
```
<ul> class="task-list"
<li><input type="checkbox" disabled class="task-list-item"> TaskList</li>
</ul>
```
The problem lies in the `List` function of `HugoHTMLRenderer`, it had
a hardocded index of `4` for the first `>` of the list, it is used to
insert the class into the text before the closing bracket, but that
hardcoded index is only right when there is a newline before the
opening bracket, which is the case when there is anything in the
document before the task list, but if there is nothing, then there is
no newline, and the correct index of the first `>` will be `3`.
To fix that we're changing the hardcoded index to be dynamic by using
`bytes.Index` to find it properly. We're also adding a test case to
make sure this is tested against.
Fixes #3710
Diffstat (limited to 'helpers/content.go')
0 files changed, 0 insertions, 0 deletions