-
Notifications
You must be signed in to change notification settings - Fork 116
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
HTML entities in search results #24
Comments
I guess the fix is to change |
For now I have fixed this for myself by monkeypatching the JS bundle, so you will not see the issue on my site as I described above. (I was keen to get it working!) |
Ah, yep good spot. I'll get that released for you this week. |
I have a similar issue but I'm not sure if it's 100% the same. |
Hi @wgroeneveld — yes that looks like the same issue, but I'll make sure to test it directly before the next release. |
Hi @fanf2 and @wgroeneveld 👋 Fixes for HTML entities have been released in Pagefind v0.5.0 🎉 |
Awesome thanks! |
I still have this happen in Pagefind 1.0.3. |
For example, using this markup: <h2 data-pagefind-meta="title"><span class="title">Faster "shuffle"</span></h2> |
Ah, my mistake, I did regress this in 1.0. We need to avoid rendering some things as HTML (for example, on MDN where pages are titled I'll get this re-fixed up for the next release — sorry about that. (The indexing bug has not been introduced, just the display bug) |
In the meantime, PagefindUI's processResult hook could be used to normalize the titles before display. |
This seems to work, there might be a more elegant way to unescape: new PagefindUI({
element: "#search",
showSubResults: true,
resetStyles: false,
processResult: function (result) {
var title = new DOMParser().parseFromString(result.meta.title, "text/html");
result.meta.title = title.documentElement.textContent;
return result;
}
}); |
I was about to write a larger note about how I cannot reproduce this, but it only seems to apply if you're using a custom (example: searching That processResult looks fine to me! At least as a temporary stop-gap 🙂 |
Thank you so much for the quick response, and this pagefind thing is awesome. ❤️ |
I have a prototype search feature for my website using pagefind, https://dotat.at/search.html. It's nice and whizzy, and it fits in well with my Rust static site generator. Thanks for making pagefind!
The only significant problem is that HTML entities in page titles are escaped, so my results page displays them like
Entities in page bodies are not escaped, so if you search (for example) for nbsp, you get a lot of highlighted spaces in the results. This is probably a bug but it isn't a showstopper for me.
The text was updated successfully, but these errors were encountered: