Details
Description
VuFind has some legacy highlighting code that doesn't actually do anything. We should clean things up and make highlighting a functional, configurable option. Some key steps/notes:
1.) There is no reason to attempt to do highlighting via PHP. We should rely on Solr (and Summon) to do this for us.
2.) We need to be careful about entity encoding. We should use highlighting tokens rather than inline HTML -- this way we can first encode HTML entities in a string and then replace the highlighting tokens with appropriate HTML.
3.) We need to be careful about string cropping -- existing code has some spots where highlighting is combined with string truncation to set a limit on string length. This will need to be revised so that we can truncate strings without creating mismatched HTML tags!
4.) We need to be careful about highlighting tags in search URLs -- for example, we currently use the same string to display author names AND generate author search links. If there are highlighting tags in the Solr response, we need to strip these out of the author name before building a search URL.
5.) Highlighting is achieved with a CSS class, but this class is not currently defined in any of the CSS files. We should define highlighting behavior (probably just font-weight: bold;) and then disable highlighting by default in the config files. This will maintain current behavior while allowing users to turn on highlighting without being forced to edit CSS files.
1.) There is no reason to attempt to do highlighting via PHP. We should rely on Solr (and Summon) to do this for us.
2.) We need to be careful about entity encoding. We should use highlighting tokens rather than inline HTML -- this way we can first encode HTML entities in a string and then replace the highlighting tokens with appropriate HTML.
3.) We need to be careful about string cropping -- existing code has some spots where highlighting is combined with string truncation to set a limit on string length. This will need to be revised so that we can truncate strings without creating mismatched HTML tags!
4.) We need to be careful about highlighting tags in search URLs -- for example, we currently use the same string to display author names AND generate author search links. If there are highlighting tags in the Solr response, we need to strip these out of the author name before building a search URL.
5.) Highlighting is achieved with a CSS class, but this class is not currently defined in any of the CSS files. We should define highlighting behavior (probably just font-weight: bold;) and then disable highlighting by default in the config files. This will maintain current behavior while allowing users to turn on highlighting without being forced to edit CSS files.