{"id":23701147,"url":"https://github.com/ehanlin/text-decorator","last_synced_at":"2025-10-18T19:15:52.508Z","repository":{"id":145358350,"uuid":"57948690","full_name":"eHanlin/text-decorator","owner":"eHanlin","description":"Be able to help to modify texts.","archived":false,"fork":false,"pushed_at":"2023-06-17T08:28:19.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-30T13:16:02.343Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eHanlin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2016-05-03T07:06:25.000Z","updated_at":"2023-06-16T09:31:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"e23019ea-b645-4acf-b710-e1e9cc557dd5","html_url":"https://github.com/eHanlin/text-decorator","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eHanlin%2Ftext-decorator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eHanlin%2Ftext-decorator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eHanlin%2Ftext-decorator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eHanlin%2Ftext-decorator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eHanlin","download_url":"https://codeload.github.com/eHanlin/text-decorator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239776621,"owners_count":19695143,"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-12-30T09:32:17.884Z","updated_at":"2025-10-18T19:15:47.472Z","avatar_url":"https://github.com/eHanlin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"text-decorator\n=======================================================\n\n[![Build Status](https://travis-ci.org/eHanlin/text-decorator.svg?branch=master)](https://travis-ci.org/eHanlin/text-decorator)\n\nThe project is able to help to modify texts.\n\n## Install\n\n```sh\nnpm install text-decorator\n```\n\n## Usage\n\n```js\nvar textDecorator = require('text-decorator');\n\nvar decorateBold = function( text ) { \n  return `**${text}**`;\n};\n\nvar result = textDecorator.decorate('This is a dog.', ['dog'], decorateBold);\n\n//print 'This is a **dog**.'\nconsole.log(result.text);\n\n//print ['dog']\nconsole.log(result.matches);\n```\n\nFollow this if you need ignore some words.\n\n```js\nvar result = textDecorator.decorate('這是一個裝飾者，不是飾者。', ['飾者'], decorateBold, {ignoreTexts:['裝飾者']});\n\n//print '這是一個裝飾者，不是**飾者**。'\nconsole.log(result.text);\n```\n\n## API\n\n#### textDecorator.decorate(text, keywords, replace)\n\nTo match keywords then replace.\n\n| name              | type    | required |description                                            |\n|-------------------|---------|--------- |-------------------------------------------------------|\n|text               |string   |    *     |The text will be replaced.                             |\n|keywords           |string[] |    *     |The keywords will be matched.                          |\n|replace            |function |    *     |To replace text content by matched.                    |\n|opts               |object   |          |This is optional value.                                |\n|opts.ignoreTexts   |string[] |          |To ignore some words for mapping                       |\n\n## Test\n\n```sh\nnpm run test\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehanlin%2Ftext-decorator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fehanlin%2Ftext-decorator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehanlin%2Ftext-decorator/lists"}