{"id":21075148,"url":"https://github.com/nutgaard/softbreak","last_synced_at":"2025-03-14T03:40:42.753Z","repository":{"id":65497416,"uuid":"130349629","full_name":"nutgaard/softbreak","owner":"nutgaard","description":"A small rule-based library for inserting soft-hyphen, line-breaks (or similar) into long pieces of text","archived":false,"fork":false,"pushed_at":"2018-04-23T06:06:40.000Z","size":356,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-20T16:02:52.408Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nutgaard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-20T10:50:12.000Z","updated_at":"2018-04-23T06:04:32.000Z","dependencies_parsed_at":"2023-01-26T07:46:30.238Z","dependency_job_id":null,"html_url":"https://github.com/nutgaard/softbreak","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nutgaard%2Fsoftbreak","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nutgaard%2Fsoftbreak/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nutgaard%2Fsoftbreak/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nutgaard%2Fsoftbreak/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nutgaard","download_url":"https://codeload.github.com/nutgaard/softbreak/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243521141,"owners_count":20304183,"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-19T19:19:54.294Z","updated_at":"2025-03-14T03:40:42.723Z","avatar_url":"https://github.com/nutgaard.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Softbreak\n\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![Travis](https://img.shields.io/travis/nutgaard/softbreak.svg)](https://travis-ci.org/nutgaard/softbreak)\n[![codecov](https://codecov.io/gh/nutgaard/softbreak/branch/master/graph/badge.svg)](https://codecov.io/gh/nutgaard/softbreak)\n[![dependencies Status](https://david-dm.org/nutgaard/softbreak/status.svg)](https://david-dm.org/nutgaard/softbreak)\n\n### How it works\nLong words will get a soft-hyphen character (default config unicode 00ad) inserted into it to signal where the word-break can be.\nE.g The word 'strengths' would be converted into 'str­e­n­g­ths', which visually looks the same but actually is 4 characters longer.\n\n### Installation\n```\nnpm install softbreak --save-dev\n```\n\n### Usage \n\n```javascript\nconst config: Config = {\n    insertCharacter: 'A',\n    wordRules: [endRule, startRule],\n    rules: [midRule]\n  };\n\nsoftbreak(config, 'alongwordhere');\nsoftbreak([endRule, startRule], 'alongwordhere');\nsoftbreak('alongwordhere');\n```\n\n`rules` and `wordRules` implement the same `Rule` which takes a single string, and returns a set of indicies where characters should be inserted.\n\n`rules` receive the whole text, where-as `wordRules` receives a single word at the time. Indices from `wordRules` are automatically adjusted by the words original position. So all rules are interchangable between the two.\n\n\n#### Types\nFull documentation of types can be seen [here](https://www.utgaard.xyz/softbreak/),\nor [here](https://github.com/nutgaard/softbreak/blob/master/src/softbreak.ts) if you prefer reading typescript code.\n\n\n### Tips\n\n* Take a look at the original [readme](https://github.com/alexjoverm/typescript-library-starter/blob/master/README.md);\n\n\n## Credits\n\nMade using the awesome [typescript library starter](https://github.com/alexjoverm/typescript-library-starter) \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnutgaard%2Fsoftbreak","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnutgaard%2Fsoftbreak","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnutgaard%2Fsoftbreak/lists"}