{"id":19319230,"url":"https://github.com/oramasearch/highlight","last_synced_at":"2025-04-22T17:31:31.053Z","repository":{"id":198489361,"uuid":"700789416","full_name":"oramasearch/highlight","owner":"oramasearch","description":"🖍️ Highlight any text in JavaScript","archived":false,"fork":false,"pushed_at":"2024-11-05T12:27:41.000Z","size":157,"stargazers_count":54,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-05T13:26:44.428Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@orama/highlight","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oramasearch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-05T09:48:40.000Z","updated_at":"2024-11-05T12:27:43.000Z","dependencies_parsed_at":"2023-11-07T16:44:55.964Z","dependency_job_id":"df524c21-3fc0-46c0-bd11-a87ce1b50036","html_url":"https://github.com/oramasearch/highlight","commit_stats":null,"previous_names":["oramasearch/highlight","askorama/highlight"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oramasearch%2Fhighlight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oramasearch%2Fhighlight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oramasearch%2Fhighlight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oramasearch%2Fhighlight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oramasearch","download_url":"https://codeload.github.com/oramasearch/highlight/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223901841,"owners_count":17222258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T01:22:45.935Z","updated_at":"2024-11-10T01:22:46.511Z","avatar_url":"https://github.com/oramasearch.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Highlight\n\n[![Test CI](https://github.com/oramasearch/highlight/actions/workflows/test.yml/badge.svg)](https://github.com/oramasearch/highlight/actions/workflows/test.yml)\n\nOrama Highlight allows you to easily highlight substrings in a given input.\n\n# Installation\n\n```bash\nnpm i @orama/highlight\nbun i @orama/highlight\n```\n\n# Usage\n\n```js\nimport { Highlight } from '@orama/highlight'\n\nconst inputString = 'The quick brown fox jumps over the lazy dog'\nconst toHighlight = 'brown fox jump'\n\nconst highlighter = new Highlight()\nconst highlighted = highlighter.highlight(inputString, toHighlight)\n\nconsole.log(highlighted.positions)\n// [\n//    {\n//      start: 10,\n//      end: 14\n//    }, {\n//      start: 16,\n//      end: 18\n//    }, {\n//      start: 20,\n//      end: 23\n//    }\n//  ]\n\nconsole.log(highlighted.HTML)\n// \"The quick \u003cmark class=\"orama-highlight\"\u003ebrown\u003c/mark\u003e \u003cmark class=\"orama-highlight\"\u003efox\u003c/mark\u003e \u003cmark class=\"orama-highlight\"\u003ejump\u003c/mark\u003es over the lazy dog\"\n\nconsole.log(highlighted.trim(10))\n// \"...uick \u003cmark class=\"orama-highlight\"\u003ebrown\u003c/mark\u003e...\"\n```\n\nYou can always customize the library behavior by passing some options to the class constructor:\n\n```js\nconst highlighted = new Highlight({\n  caseSensitive: true,        // Only highlight words that respect the second parameter's casing. Default is false\n  wholeWords: true,           // Only highlight entire words, no prefixes\n  HTMLTag: 'div',             // Default is \"mark\"\n  CSSClass: 'my-custom-class' // default is 'orama-highlight'\n})\n```\n\n# License\n[Apache 2.0](/LICENSE.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foramasearch%2Fhighlight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foramasearch%2Fhighlight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foramasearch%2Fhighlight/lists"}