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

bug/feature html tags wrapped in paragraph tags #575

Closed
clach04 opened this issue Apr 9, 2024 · 4 comments · Fixed by #576
Closed

bug/feature html tags wrapped in paragraph tags #575

clach04 opened this issue Apr 9, 2024 · 4 comments · Fixed by #576

Comments

@clach04
Copy link
Contributor

clach04 commented Apr 9, 2024

Describe the bug

html tags are being wrapped in <p> in a similar fashion to https://daringfireball.net/projects/markdown/

To Reproduce

problem.md

<html>

<!-- Comment please ignore -->

<!-- Multi
line Comment 
please ignore -->


<body>
content here

 <img src="some_img.jpg" alt="there is supposed to be an image here" width="500" height="600"> 

Now some bullets:

  * one
  * two

</body>


</html>

Output

NOTE html, body, and img tags:

<p><html></p>

<!-- Comment please ignore -->

<!-- Multi
line Comment 
please ignore -->

<p><body>
content here</p>

<p><img src="some_img.jpg" alt="there is supposed to be an image here" width="500" height="600"> </p>

<p>Now some bullets:</p>

<ul>
<li>one</li>
<li>two</li>
</ul>

<p></body></p>

<p></html></p>

Expected behavior

I'm seeking clarity on this from project readme in

This (markdown2) is a fast and complete Python implementation of Markdown. It

It
was written to closely match the behaviour of the original Perl-implemented
Markdown.pl.

I was NOT expecting to see <p> tags around html, body. I have a larger example where it adds them around comments AND style tags.

Debug info
Version of library being used:

__version_info__ = (2, 4, 14)

Any extras being used: NONE

Additional context

Other implementations generate what I consider sane html BUT differ from Daring Fireball 2004 Perl version (which is known to have odd issues).

I've not attempted to debug. Curious what thoughts are on this. Thanks!

@nicholasserra
Copy link
Collaborator

Looks like you left most of the default text in this issue. So not sure what issue you're seeing. Maybe close and reopen with clearer info.

@clach04
Copy link
Contributor Author

clach04 commented Apr 9, 2024

@nicholasserra looks like I missed off indentation in the first markdown snippet. Corrected. Hopefully that's more clear now.

@clach04 clach04 changed the title bug/feature html tags wrapped in paragraphs bug/feature html tags wrapped in paragraph tags Apr 9, 2024
@clach04
Copy link
Contributor Author

clach04 commented Apr 13, 2024

@nicholasserra I can't reopen this. Did you mean I should open a new issue?

@nicholasserra nicholasserra reopened this Apr 14, 2024
Crozzers added a commit to Crozzers/python-markdown2 that referenced this issue Apr 20, 2024
@Crozzers
Copy link
Contributor

I've opened a PR to fix this.

A side effect of the fix is that it won't automatically process the contents of the HTML tags as markdown. It will assume it's HTML and stop there. To get around this you'll need to use the markdown-in-html extra.

Adding markdown="1" to the html and body tag and enabling the extra should do the trick

text = '''
<html markdown="1">
...
<body markdown="1">
...
* one
* two
</body>
</html>
'''
markdown2.markdown(text, extras=['markdown-in-html'])

nicholasserra added a commit that referenced this issue Apr 22, 2024
Fix `html`, `head` and `body` tags being wrapped in `<p>` tags (#575)
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

Successfully merging a pull request may close this issue.

3 participants