Skip to content
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 · 2 comments · Fixed by #3750
Closed

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

oodavid opened this issue Jul 17, 2017 · 2 comments · Fixed by #3750
Milestone

Comments

@oodavid
Copy link
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 Bug > Markdown > Won't render task-list when it's the first token 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 pushed 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
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 gohugoio#3710
@mpcabd
Copy link
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 as completed in #3750 Aug 1, 2017
bep pushed a commit that referenced this issue Aug 1, 2017
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
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants