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

join newlines with spaces in Html.__format__ #3882

Merged
merged 3 commits into from
Feb 22, 2025

Conversation

enricozb
Copy link
Contributor

📝 Summary

Fixes a bug in Html.__format__ when the provided html text has newlines inside an html tag.

🔍 Description of Changes

Previously, newlines were effectively removed when formatting an Html object. This breaks in cases where html tags are split across multiple lines. For example,

Html("""
  <div
    style="..."
  ></div>
""")

📋 Checklist

  • I have read the contributor guidelines.
  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • I have added tests for the changes made.
  • I have run the code and verified that it works as expected.

📜 Reviewers

@akshayka OR @mscolnick

Previously, newlines were effectively removed when formatting an Html
object. This breaks in cases where html tags are split across multiple
lines. For example,
Html("""
  <div
    style="..."
  ></div>
""")
Copy link

vercel bot commented Feb 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marimo-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 22, 2025 9:30pm
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 22, 2025 9:30pm

Copy link

github-actions bot commented Feb 22, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@enricozb
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@enricozb
Copy link
Contributor Author

recheck

@mscolnick
Copy link
Contributor

thank you! ill follow up with some tests

@mscolnick
Copy link
Contributor

actually, i'm not sure if this will create other issues. cc @akshayka who has more context on this

@mscolnick
Copy link
Contributor

mscolnick commented Feb 22, 2025

This is definitely a bug, and your fix does fix this. Example notebook here

But i wonder if we should just not be stripping newlines, because it could also lose info, such as new lines help display something. Maybe a better solution is that we don't override __format__

@mscolnick
Copy link
Contributor

i added a few more test cases to show off the current behaviour

Comment on lines 136 to 138
return " ".join(
[line.strip() for line in self.text.split("\n")]
).strip()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i would personally strip before splitting rather than stripping after joining

Copy link
Contributor

@mscolnick mscolnick Feb 22, 2025

Choose a reason for hiding this comment

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

👍 will do

Copy link

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.11.9-dev6

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 this pull request may close these issues.

2 participants