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

A little fault in README and the python doc string: some unnecessary and extra </li> may occur. #72

Open
njuaplusplus opened this issue Oct 4, 2015 · 1 comment

Comments

@njuaplusplus
Copy link

Here are the codes in your instrcution:

{% for comment in comment_list|fill_tree|annotate_tree %}
    {% ifchanged comment.parent_id %}{% else %}</li>{% endifchanged %}
    {% if not comment.open and not comment.close %}</li>{% endif %}
    {% if comment.open %}<ul>{% endif %}

    <li id="c{{ comment.id }}">
        ...
    {% for close in comment.close %}</li></ul>{% endfor %}
{% endfor %}

The 2nd line may have some faults.
If the comment.parent_id remains None, the ifchanged condition is False,
and it will output an </li>.
But if the comment is the root comment, that is, the comment is not a reply to an existing comment,
its parent_id is None.
Hence, there may be unnecessary </li> between the root comments.
As the browser is smart enough, it will removed the unmatched </li>,
so we may not be aware of this kind of bug.

However, if we use <div><div> instead of <ul><li>,
then the unnecessary </div> will mismatch other <div>.

So, I think the solution is to double check the comment.parent_id:

{% ifchanged comment.parent_id %}
{% else %}
    {% if comment.parent_id %}
    </li>
    {% endif %}
{% endifchanged %}
@njuaplusplus
Copy link
Author

It is a bit like the issue #53
However it's not fixed completely by issue #54

Maybe we call the Case 3:

Case 3

Follow these steps:

  1. Post a comment.
  2. Post the 2nd comment. NOT a reply to the first comment.
  3. Post the 3rd comment. NOT a reply to the first comment.

Here is the tree:

  • Comment 1
  • Comment 2
  • Comment 3

Here is the HTML output (cleaned up):

<ul>
    <li>
        Comment 1
    </li>
</ul>
<ul>
    <li>
        Comment 2
    </li>
</ul>
</li><!-- This one -->
<ul>
    <li>
        Comment 3
    </li>
</ul>

Because when processing the comment 3 in the forloop,
its parent_id is same as comment 2 (None),
and it will emit a </li>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant