{"action":"opened","issue":{"url":"https://api.github.com/repos/HealthCatalyst/Fabric.Cashmere/issues/578","repository_url":"https://api.github.com/repos/HealthCatalyst/Fabric.Cashmere","labels_url":"https://api.github.com/repos/HealthCatalyst/Fabric.Cashmere/issues/578/labels{/name}","comments_url":"https://api.github.com/repos/HealthCatalyst/Fabric.Cashmere/issues/578/comments","events_url":"https://api.github.com/repos/HealthCatalyst/Fabric.Cashmere/issues/578/events","html_url":"https://github.com/HealthCatalyst/Fabric.Cashmere/issues/578","id":374159404,"node_id":"MDU6SXNzdWUzNzQxNTk0MDQ=","number":578,"title":"Add Highlight Pipe to Cashmere","user":{"login":"joeskeen","id":12286274,"node_id":"MDQ6VXNlcjEyMjg2Mjc0","avatar_url":"https://avatars1.githubusercontent.com/u/12286274?v=4","gravatar_id":"","url":"https://api.github.com/users/joeskeen","html_url":"https://github.com/joeskeen","followers_url":"https://api.github.com/users/joeskeen/followers","following_url":"https://api.github.com/users/joeskeen/following{/other_user}","gists_url":"https://api.github.com/users/joeskeen/gists{/gist_id}","starred_url":"https://api.github.com/users/joeskeen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joeskeen/subscriptions","organizations_url":"https://api.github.com/users/joeskeen/orgs","repos_url":"https://api.github.com/users/joeskeen/repos","events_url":"https://api.github.com/users/joeskeen/events{/privacy}","received_events_url":"https://api.github.com/users/joeskeen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-25T22:34:51Z","updated_at":"2018-10-25T22:34:51Z","closed_at":null,"author_association":"COLLABORATOR","body":"**Describe the problem this feature request is solving**\r\nIt's a common use case in apps to have a search or filter function, and it is nice to highlight the search term within the results.  Both of the apps I'm working on at HC have a Highlight pipe, and I'm sure other apps do as well.  Fixing bugs (especially security bugs like the one I found today) is hard to communicate and duplicate in disparate implementations.  Making this a standard-issue pipe in Cashmere would be really great!\r\n\r\n**Describe the solution you'd like**\r\nThe `HighlightPipe` would take plain text (which shouldn't contain HTML) and a search term to highlight.  The pipe then searches the provided text for the search term and wraps each match with a span marked with the special highlight class.  The result would be HTML-formatted text.\r\n\r\n** If any, which components will have to change, and how **\r\n\r\n*   No components would have to change, and no breaking changes to the API, this would be completely additive.\r\n\r\n**Additional thoughts**\r\n\r\n1. We already have one pipe in Cashmere, the Ellipsis pipe.  But it isn't referenced in the documentation anywhere.  We probably should create a new section for pipes in the documentation, with interactive examples.\r\n2. Here is the spec for the Highlight pipe we use in Atlas, that I would propose we add to Cashmere:\r\n    ```\r\n    HighlightPipe\r\n        when text and search contain no HTML\r\n        when search term doesn't match casing with the text\r\n            should still find the search term in the text and wrap the match with a highlight span\r\n        when search term is found in the string\r\n        should wrap the match with a highlight span\r\n        when search term is multiple words\r\n            if those multiple words are not adjacent in the text\r\n                should wrap each matching word from the search in its own highlight span\r\n            should wrap each adjacent word in the match with its own highlight span\r\n        when search term is found multiple times in the string\r\n            should wrap all matches with highlight spans\r\n        when search term is a partial word found in the string\r\n            should wrap the match with a highlight span\r\n        when search term is `undefined`\r\n            should return the input string\r\n        when search term is not found in the string\r\n            should return the input string\r\n        when text contains HTML\r\n            should highlight matches on the escaped HTML\r\n        when the search term contains HTML\r\n            should highlight matches on the escaped HTML\r\n        when the search term is blank\r\n            should still escape the HTML in the text\r\n        when text is `undefined`\r\n            should return the empty string\r\n        when both search term and text are `undefined`\r\n            should return the empty string\r\n    ```\r\n"}}
{"actor":{"display_login":"joeskeen"}}