-
Notifications
You must be signed in to change notification settings - Fork 309
content: Handle <hr> horizontal lines #603
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
content: Handle <hr> horizontal lines #603
Conversation
5a9ba2b
to
f6f3503
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks mostly good! Some small comments, below.
Also, let's add a some test for the new ThematicBreak
widget, in test/widgets/content_test.dart. One shortcut to doing that is testContentSmoke
, but unfortunately it won't help us here—it requires ContentExample.expectedText
to be non-null, and these "thematic break" lines don't come with any text to check. 🙂 But there are some tests in that file in the same situation, and they end up being pretty simple. For example, the smoke tests for MessageImageEmoji
.
f6f3503
to
ec95eb3
Compare
Thanks @chrisbobbe! I have restructured the code accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Khader-1, and thanks @chrisbobbe for the review!
A few more comments below, mainly on the tests.
Please also update the screenshot at the top of the PR for the current revision (since I believe you've adjusted the layout). That'll help for getting feedback on the visual result.
d5e07e6
to
36391f8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the revision! Comments below.
test/model/content_test.dart
Outdated
static const thematicBreaks = ContentExample( | ||
'parse thematic break (<hr>) in block context', | ||
'a\n---\nb', | ||
'<p>a</p><hr><p>b</p>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, is this the HTML the server outputs for this input? I'd have guessed there'd be some newlines in there, like between </p>
and <hr>
, based on how some other examples in this file look.
Would you link in the PR description to a test message on chat.zulip.org that demonstrates this example? (That's probably something we should start making a practice of, for better reproducibility. Or perhaps even put the link into the source code.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the oversight. I adjusted the output for readability purposes, which resulted in a cleaner HTML string. However, I understand the importance of maintaining accuracy for testing purposes. Moving forward, I'll ensure the test output aligns precisely with the server's actual output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the link to the message in the latest version of the test:
https://chat.zulip.org/#narrow/stream/7-test-here/topic/content.3A.20Handle.20Thematic.20Breaks/near/1774718
Do you suggest having it in ContentExample
as an nullable field? or just a comment will do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks. Yeah, readability is important, but for these tests their job is to make sure we're successfully parsing whatever the server sends us, with all its quirks and sometimes messes — so the top priority is for the data to represent those authentically.
For now let's just add the link in a comment, like this:
static const thematicBreaks = ContentExample(
'parse thematic break (<hr>) in block context',
// https://chat.zulip.org/#narrow/stream/7-test-here/near/1774718
'a\n---\nb',
'<p>a</p>\n<hr>\n<p>b</p>',
Then I'll file a separate issue for filling that in for the existing examples, adding it as a field, and also adding some automated validation of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #617.
36391f8
to
736cd84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the revision! Two wording nits below, and I replied above about the URL. I'll make those three tweaks and merge.
test/model/content_test.dart
Outdated
@@ -521,6 +521,16 @@ class ContentExample { | |||
blockUnimplemented('more text'), | |||
]]), | |||
]); | |||
|
|||
static const thematicBreaks = ContentExample( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: there's only one of these, so singular:
static const thematicBreaks = ContentExample( | |
static const thematicBreak = ContentExample( |
test/model/content_test.dart
Outdated
@@ -521,6 +521,16 @@ class ContentExample { | |||
blockUnimplemented('more text'), | |||
]]), | |||
]); | |||
|
|||
static const thematicBreaks = ContentExample( | |||
'parse thematic break (<hr>) in block context', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "in block context" is redundant because that's the only way <hr>
can appear:
'parse thematic break (<hr>) in block context', | |
'parse thematic break (<hr>)', |
(there's a phrase like that for the test that produces LineBreakNode
, but that's to contrast it with the "inside a paragraph" version that produces LineBreakInlineNode
)
736cd84
to
a7d97d5
Compare
Final Result:
Fixes: #353