New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not render task-list when it's the first token #3710

Closed
oodavid opened this Issue Jul 17, 2017 · 1 comment

Comments

Projects
None yet
3 participants
@oodavid
Contributor

oodavid commented Jul 17, 2017

The following page:

---
title: "Test"
date: 2017-07-17T12:07:51+01:00
draft: false
---

* [ ] TaskList

Outputs the following HTML

<ul> class="task-list"
<li><input type="checkbox" disabled class="task-list-item"> TaskList</li>
</ul>

Which renders like this

Task List


Steps to fix - add any leading content before the task-list

---
title: "Test"
date: 2017-07-17T12:07:51+01:00
draft: false
---

leading content

* [ ] TaskList

@bep bep changed the title from Bug > Markdown > Won't render task-list when it's the first token to Does not render task-list when it's the first token Jul 17, 2017

@bep bep added the Bug label Jul 17, 2017

@bep bep added this to the v0.26 milestone Jul 17, 2017

danieka added a commit to danieka/hugo that referenced this issue Jul 29, 2017

mpcabd added a commit to mpcabd/hugo that referenced this issue Jul 29, 2017

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
@mpcabd

This comment has been minimized.

Show comment
Hide comment
@mpcabd

mpcabd Jul 29, 2017

Contributor

Oh I just noticed @danieka's pull-request, I saw the issue yesterday and just managed to test it and work on it, please take whatever solution you like 😄

Contributor

mpcabd commented Jul 29, 2017

Oh I just noticed @danieka's pull-request, I saw the issue yesterday and just managed to test it and work on it, please take whatever solution you like 😄

@bep bep closed this in #3750 Aug 1, 2017

bep added a commit that referenced this issue Aug 1, 2017

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment