Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Some elements turning into None in html output with md_in_html #1049

Closed

Description

@greenape
import markdown
md = markdown.Markdown(extensions=["markdown.extensions.md_in_html"])
test = """
<div class="output_area" markdown="1">
<table>
<thead><tr>
<th style="text-align:right"></th>
<th style="text-align:right">time</th>
<th style="text-align:right">amplitude</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right">0</td>
<td style="text-align:right">0</td>
<td style="text-align:right">0</td>
</tr>
</tbody>
</table>
</div>
"""
print(md.convert(test))

Which gives me -

<div class="output_area">
<table>
<thead>None<tr>
<th style="text-align:right">None</th>
<th style="text-align:right">time</th>
<th style="text-align:right">amplitude</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right">0</td>
<td style="text-align:right">0</td>
<td style="text-align:right">0</td>
</tr>
</tbody>
</table>
</div>

Rather than

<div class="output_area">
<table>
<thead><tr>
<th style="text-align:right"></th>
<th style="text-align:right">time</th>
<th style="text-align:right">amplitude</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right">0</td>
<td style="text-align:right">0</td>
<td style="text-align:right">0</td>
</tr>
</tbody>
</table>
</div>

Which is what I'm expecting - note the extra None before the <tr> in <thead> and in the first header.

Activity

  1. facelessuser commented on Oct 21, 2020

    @facelessuser
    Collaborator

    Yup, looks like another bug in the new HTML parser, unfortunately. Looks like we need a None check somewhere before inserting some text content.

  2. added
    bug
    confirmed
    extension
    on Oct 21, 2020
  3. facelessuser commented on Oct 21, 2020

    @facelessuser
    Collaborator

    I think I may have a fix.

  4. waylan commented on Oct 21, 2020

    @waylan
    Member

    Here is a simpler case:

    <div markdown="1">
    <div></div>
    </div>
    

    Note that the text content of the second <div> is empty. Presumably, Element.text is None rather than an empty string as it should be. We should probably just address this in the serializer to avoid None in any output.

  5. waylan commented on Oct 21, 2020

    @waylan
    Member

    @facelessuser if you have a fix, go for it. Although we should probably do something with the serializer as well.

  6. facelessuser commented on Oct 21, 2020

    @facelessuser
    Collaborator

    @waylan I'm not sure what you mean in regards to the serializer.

  7. added a commit that references this issue on Oct 21, 2020
    08b1dd8
  8. facelessuser commented on Oct 21, 2020

    @facelessuser
    Collaborator

    I've created pull #1050. We can discuss additional changes there if more than what I'm doing needs to be addressed.

  9. waylan commented on Oct 21, 2020

    @waylan
    Member

    @waylan I'm not sure what you mean in regards to the serializer.

    My thinking was that there could be any number of other situations in which the text of an Element is None. We should never render that as None. However, I have since looked at the serializer and see that every call to write(text) is nested within a if text check, so the serializer already accounts for this.

    It would seem that the issue is isolated to parsing the content of an Element as Markdown, which your fix addresses. So nevermind.

  10. added a commit that references this issue on Oct 21, 2020
    2a883a2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugconfirmedextension

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions