Skip to content

InlineHTML <center> not treated as HTML correctly #1481

Closed

Description

@ScriptPup

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.

Activity

  1. facelessuser commented on Sep 18, 2024

    @facelessuser
    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>.

  2. waylan commented on Sep 19, 2024

    @waylan
    Member

    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.

  3. squidfunk commented on Jan 31, 2025

    @squidfunk

    @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.

  4. facelessuser commented on Jan 31, 2025

    @facelessuser
    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.

  5. added a commit that references this issue on Jan 31, 2025
    493aaf1
  6. facelessuser commented on Jan 31, 2025

    @facelessuser
    Collaborator

    PR up

  7. waylan commented on Jan 31, 2025

    @waylan
    Member

    @facelessuser summed up my position quite well. As it is deprecated, I could care less if it is broken or not. I personally have no inclination to spend any time on it. The only reason I'm spending the time to make this comment is to clear up my position in general (on any deprecated elements). But, yes, If someone else wants to spend their time on a fix, they are welcome to.

  8. added a commit that references this issue on Jan 31, 2025
    6347c57
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

    needs-decisionA decision needs to be made regarding request.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions