-
Notifications
You must be signed in to change notification settings - Fork 70
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
Formatting of search results is poor #331
Comments
it does indeed seems it is fixed but looking at past commits it is unclear what fixed it (I do remember the issue in the past, do not remember recent occurences). and unclear whether or not the forum has been recently deployed. #317 would be useful :) |
https://forum.nim-lang.org/t/7969#50770 seems to be broken: "Couldn't render historic post in #50770" And it cannot be rendered properly in the search results. |
this is related to this (still open) issue: #330 I think there are some cases still not working |
@pietroppeter and @PhilippMDoerner Search the forum for The issue is only present when the code block gets cut off and doesn't have an ending and/or beginning ``` |
I can see the issue in the forum, however, I can't seem to replicate it when I run this locally. I pretty much just copy pasted jack's post above to make a thread out of it, but no matter what I search, this is the kind of stuff I get: This is with the forum compiled under 1.9.1, which shouldn't make a difference here. |
Ohhhhh it's explicitly the comment Now the next question that follows this is: And that is only if the snippet you want to show is near the start or the end of a codeblock. |
@PhilippMDoerner You are correct. This issue would likely be fairly difficult to solve based on the reasons you mentioned. With the current structure of the code, I'm also not sure how to approach it. FTS with the I was curious how Discourse solves this, and it looks like they just strip all formatting and render the plain text: https://discourse.codecombat.com/search?q=penPositions%20%3D. Maybe we could do that as well. |
It seems a very reasonable thing to do indeed. Maybe highlighting (bold?) the search term as they do |
That actually runs into problems for exactly the example we were looking at.
And you have a searchquery of As you can see, there is no to be found anywhere. Now we can of course circumvent that, we can say to just render the text as is. But that means it'll also render the So either we just render plaintext, or we accept that any HTML-strings in the content itself will not be rendered as text. As an additional issue though, I haven't found an easy way in karax so far to retain the whitespacing, so it all looks like the unreadable messy textblobs you see above. |
@PhilippMDoerner If you want to render a search of |
So in your case, you would replace |
When rendering search hits via karax, it is desired to emphasise the search term in the hit that was originally looked for. This requires you to surround the search term with <strong> tags. However, any HTML-text in the search hit will also be rendered as HTML. This is undesired. Thus all HTML is also escaped in the text. The rest is just name refactoring for better clarity. nim-lang#331
When highlighting text with "*" in markdown, it needs space between the hit enshrined by "**" to get boldened. This is not always the case. Therefore we add whitespaces before/after the ** This way we can enforce that it properly gets boldened. nim-lang#331
Sometimes search-results contain the string `## `. They do occur as code comments in code-blocks. If they get recognized, they get turned into headlines. To avoid this, a replace statement was added. nim-lang#331
It does turn out we're overcomplicating things.
Mysteriously that even takes care of the HTML issue |
That fixes the bolded text issue, but now you have more issues because the markdown is parsing |
The alternative is plain-text and hacks that work around making things sometimes bold and sometimes not, we're running into hacks either way. |
Sometimes search-results contain the string `[`. They do occur as generics in code-blocks. If they get recognized, they get turned into links. To avoid this, a replace statement was added. nim-lang#331
But they aren't hacks. HTML has special characters that need to be escaped if you want to display them normally. Replacing I get the formatting will be cleaner in the code samples, but that isn't really an issue when you can just click into the post and read the full code. There is a good reason that Discourse doesn't render text with formatting. It's tricky business and broken text gets rendered like it currently does in the Nim forum. Also, if you start escaping Markdown characters, the formatting in the regular, non-code text will be broken and won't display headers and links correctly. |
Surely this is not a reasonable result for static statement:
The code block is broken, and a random sentence is printed in a huge font while the title's weight is weaker than the author's.
The text was updated successfully, but these errors were encountered: