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

InlineHTML <center> not treated as HTML correctly #1481

Open
ScriptPup opened this issue Sep 18, 2024 · 5 comments · May be fixed by #1506
Open

InlineHTML <center> not treated as HTML correctly #1481

ScriptPup opened this issue Sep 18, 2024 · 5 comments · May be fixed by #1506
Labels
needs-decision A decision needs to be made regarding request.

Comments

@ScriptPup
Copy link

If <center> has tags nested underneath it, the <center> tag is surrounded by <p> tags, breaking the HTML.

from markdown import markdown
text = """# My Header

<center>
Test
</center>

<center>
<div>Something</div>
</center>

<div>
Test div
</div>

<div>
<p>Some paragraph</p>
</div>

<div>
<article>Some paragraph</article>
</div>

Something else
"""
print(markdown(text))

Results in:

image

It seems like

works correctly, so not 100% why the difference.

@facelessuser
Copy link
Collaborator

<center> should be treated as a block element (not wrapped in <p>). It's currently being treated as an inline element. It should also be noted that <center> is also a deprecated element that should not be used. With that said, since it is being used, maybe we should update the block element list to account for <center>.

@waylan
Copy link
Member

waylan commented Sep 19, 2024

Our behavior matches exactly the reference implementation (markdown.pl). Specifically, we treat <center> as an inline tag because the reference implementation does. As the tag is deprecated, I'm inclined to not make any changes.

@waylan waylan added the needs-decision A decision needs to be made regarding request. label Sep 19, 2024
@squidfunk
Copy link

@waylan treating center as inline is definitely a bug in the reference implementation. Yes, the tag is deprecated, but browsers will support it forever. Am I reading this correctly, that you're not considering fixing bugs that are present in the reference implementation for the sake of keeping compatibility with the reference implementation?

I'm asking, because the documentation of Python Markdown states the following goal:

Maintain a Python library (with an optional CLI wrapper) suited to use in web server environments (never raise an exception, never write to stdout, etc.) as an implementation of the markdown parser that follows the syntax rules and the behavior of the original (markdown.pl) implementation as reasonably as possible (see differences for a few exceptions).

IMHO, fixing this bug is definitely a reasonable request. Please know that I don't want to start a huge discussion – it is your project, and I absolutely respect that! I'm just interested what your long-term goal with this project is.

@facelessuser
Copy link
Collaborator

As the tag is deprecated, I'm inclined to not make any changes.

I think it was simply a statement of 1) giving reasons as to why it is the way it is and 2) that since it is deprecated, people should be moving away and the thought was that there is not much value in changing it. With that said, it was also marked with needs-decision, essentially leaving the door a little open.

I don't think it was the end of the conversation, but little movement was made on this issue as there was no real pushback. I can put up a PR, it's a trivial change.

facelessuser added a commit to facelessuser/markdown that referenced this issue Jan 31, 2025
@facelessuser facelessuser linked a pull request Jan 31, 2025 that will close this issue
@facelessuser
Copy link
Collaborator

PR up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-decision A decision needs to be made regarding request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants