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

Adjust md_in_html "markdown" blocks to process content consistently #1503

Merged
merged 18 commits into from
Jan 28, 2025

Conversation

facelessuser
Copy link
Collaborator

@facelessuser facelessuser commented Jan 24, 2025

Ensure md_in_html processes content inside a "markdown" block the same way content is processed outside of a "markdown" block.

  • Flatten the HTML content into placeholders so that the parser will treat the "markdown" block content in the same way it does when md_in_html is not enabled. The placeholders are expanded once the parser reaches them in a linear fashion. This allows extensions to deal with HTML content and consume it the same way it deals with them with them when the content is not nested under a "markdown" block.

  • Instead of content being processed in dummy tags, content is now processed under the real parent allowing extensions to have better context to make better decisions.

Additionally, fix some issues with tags and inline code.

Also, fix some issues with one-liner block tags, e.g. <tag><tag>...

Resolves #1502
Resolves #1075
Resolves #1074

Ensure `md_in_html` processes content inside a "markdown" block the same
way content is processed outside of a "markdown" block.

- Flatten the HTML content into placeholders so that the parser will
  treat the "markdown" block content in the same way it does when
  `md_in_html` is not enabled. The placeholders are expanded once the
  parser reaches them in a linear fashion. This allows extensions to
  deal with HTML content and consume it the same way it deals with them
  with them when the content is not nested under a "markdown" block.

- Instead of content being processed in dummy tags, content is now
  processed under the real parent allowing extensions to have better
  context to make better decisions.
@facelessuser
Copy link
Collaborator Author

I'll update changelog once I know if this change would like to be considered as a a bug or a feature. More importantly, I need to make sure this change is generally desired.

@facelessuser facelessuser marked this pull request as ready for review January 24, 2025 14:41
@facelessuser
Copy link
Collaborator Author

I think this is ready for review now.

@facelessuser
Copy link
Collaborator Author

I decided to just add the change as a "fix" for now in the changelog. It fixes surprising behaviors and doesn't change any existing, tested functionality. If we wish to reclassify it, I can on request.

@facelessuser facelessuser marked this pull request as draft January 25, 2025 08:17
@facelessuser
Copy link
Collaborator Author

I'm actually going to leave this in draft a little longer to test some more corner cases.

@facelessuser
Copy link
Collaborator Author

I think I'll be able to fix #1075 while I'm in here, or at the very least improve results. I'm going to add more tests as I validate cases that are not covered in tests.

@facelessuser
Copy link
Collaborator Author

I've also fixed some issues with #1074. Working in the HTML parser isn't my idea of fun, so I just wanted to resolve the issues while I'm deep in the code as I'm unlikely to jump into it for a while.

Again, existing tests are still passing and in addition, new tests check for the new inline block tag behavior.

These changes really make md_in_html feel more natural and they bring back probably some lost functionality from before the HTML parser rewrite.

I think I'm almost done validating edge cases and such.

@facelessuser facelessuser marked this pull request as ready for review January 25, 2025 19:25
@facelessuser
Copy link
Collaborator Author

@waylan I think I've done all I can do on this. Whenever you get a chance, please take a look, give it a try, and let me know what you think. If there are some cases you think I'm missing, or you see some things you don't like, let me know.

@waylan
Copy link
Member

waylan commented Jan 27, 2025

I do not have the bandwidth to review this at this time and don't know when I will. @facelessuser I trust you to proceed as you see fit.

@facelessuser
Copy link
Collaborator Author

facelessuser commented Jan 27, 2025

@waylan Thanks for letting me know. It seems you are generally not against the idea of what I've proposed, so with that in mind, I will spend some time going over it once again with a critical eye and merge if nothing is found. I'm more than happy to support any surprises post-release.

@facelessuser
Copy link
Collaborator Author

@waylan I'll need either a review approval or permissions to override review when merging if I am to proceed.

Copy link
Member

@waylan waylan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't actually reviewed this, but am approving so that @facelessuser can move forward as he sees fit.

@facelessuser facelessuser merged commit f2ae4e4 into Python-Markdown:master Jan 28, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants