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

Fix #504 : honor the indentation in the MetadataFilter formatting #510

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

pierrotsmnrd
Copy link
Contributor

Fix #504 : honor the indentation in the MetadataFilter formatting

@pierrotsmnrd pierrotsmnrd requested a review from pmeier December 11, 2024 09:30
@pierrotsmnrd pierrotsmnrd changed the base branch from main to corpus-dev December 11, 2024 09:41
self.current_chat["metadata"]["input"]
)
)
.replace("\n", "<br>")
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we able to remove this given that <pre> should honor line breaks?

Copy link
Contributor Author

@pierrotsmnrd pierrotsmnrd Dec 11, 2024

Choose a reason for hiding this comment

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

That's indeed the first thing I have tried, but no.
<pre> does not natively honor line breaks. It can be done with CSS but then the line breaks at the first opportunity, and it doesn't result in a hierarchical result anymore.

)
)
.replace("\n", "<br>")
.replace(" ", "&nbsp;")
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

.replace("\n", "<br>")
We need to put explicit <br> to have line-breaks at the right places, as explained in the other comment.

.replace(" ", "&nbsp;")
We need to replace the whitespaces as explicit non-breakable spaces to show indentation, otherwise it's ignored.

Try removing these lines to see how it behaves.

Copy link
Member

Choose a reason for hiding this comment

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

So do we even need the <pre> tag in that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, to prevent from any forced line-break, and it also renders with a nice monospaced font.

Here are two screenshots comparing both results

  • with <pre>
Capture d’écran 2024-12-11 à 12 10 20
  • without <pre>
Capture d’écran 2024-12-11 à 12 11 10

If you want the non-monospaced font, so no <pre>, I can probably fix the result with CSS.

Copy link
Member

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

Thanks Pierre!

@pmeier pmeier merged commit fdb86b5 into corpus-dev Dec 12, 2024
4 of 11 checks passed
@pmeier pmeier deleted the fix-504 branch December 12, 2024 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix MetadataFilter formatting in chat info side bar
2 participants