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

HTML elements are replaced by hashes #508

Closed
invisibleroads opened this issue Apr 25, 2023 · 5 comments · Fixed by #509
Closed

HTML elements are replaced by hashes #508

invisibleroads opened this issue Apr 25, 2023 · 5 comments · Fixed by #509
Labels

Comments

@invisibleroads
Copy link

Python 3.10.8
markdown2==2.4.8

Code

x = '''
<div><div></div>
</div>
<div></div>
<div></div>
<div></div>

- A
'''
from markdown2 import markdown
print(markdown(x))

Output

<div><div></div>

</div>


md5-516b9f5b6ec51f43a8ff878841e574fa




md5-516b9f5b6ec51f43a8ff878841e574fa




md5-516b9f5b6ec51f43a8ff878841e574fa



<ul>

<p><li>A</li>
</ul></p>
@invisibleroads
Copy link
Author

Current workaround is to make sure that there is a newline after the first starting div tag.

invisibleroads added a commit to crosscompute/crosscompute that referenced this issue Apr 25, 2023
@Crozzers
Copy link
Contributor

This one comes down to the first line having two opening tags and one close tag. The parser doesn't realise that the first tag isn't closed and that is what messes it up.

I've managed to get a patch working but I'll see if I can clean it up a bit before I submit a PR

Crozzers added a commit to Crozzers/python-markdown2 that referenced this issue Apr 26, 2023
Crozzers added a commit to Crozzers/python-markdown2 that referenced this issue Apr 26, 2023
@invisibleroads
Copy link
Author

Regarding the test for the fix, the unordered list at the end is important. The markdown renders correctly if you omit the unordered list.

In [1]: x = '''
   ...: <div><div></div>
   ...: </div>
   ...: <div></div>
   ...: <div></div>
   ...: <div></div>
   ...: 
   ...: - A
   ...: '''
   ...: from markdown2 import markdown
   ...: print(markdown(x))
   ...: 
<div><div></div>

</div>


md5-688f5ae04dff1a2c8b9235b8be711c7e




md5-688f5ae04dff1a2c8b9235b8be711c7e




md5-688f5ae04dff1a2c8b9235b8be711c7e



<ul>

<p><li>A</li>
</ul></p>


In [2]: x = '''
   ...: <div><div></div>
   ...: </div>
   ...: <div></div>
   ...: <div></div>
   ...: <div></div>
   ...: 
   ...: '''
   ...: from markdown2 import markdown
   ...: print(markdown(x))
<div><div></div>

<p></div></p>

<div></div>

<div></div>

<div></div>

@invisibleroads
Copy link
Author

Oh never mind, I see the test has the unordered list at the end. Sorry about that

@Crozzers
Copy link
Contributor

No worries! I had originally omitted it, assuming it was unimportant but realised the mistake

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

Successfully merging a pull request may close this issue.

3 participants