{"id":18915030,"url":"https://github.com/arcanis/mono-layout","last_synced_at":"2025-04-15T08:31:39.886Z","repository":{"id":66016444,"uuid":"76736815","full_name":"arcanis/mono-layout","owner":"arcanis","description":"Fast implementation of a browser-like text layout engine, for Node and browsers","archived":false,"fork":false,"pushed_at":"2025-02-20T10:47:19.000Z","size":843,"stargazers_count":33,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-28T18:55:17.113Z","etag":null,"topics":["browser","cpp","text-formatting"],"latest_commit_sha":null,"homepage":"","language":"C++","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/arcanis.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}},"created_at":"2016-12-17T17:14:52.000Z","updated_at":"2025-02-20T10:47:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"a42e523a-e25b-4a51-aa9d-1f2226578dab","html_url":"https://github.com/arcanis/mono-layout","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arcanis%2Fmono-layout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arcanis%2Fmono-layout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arcanis%2Fmono-layout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arcanis%2Fmono-layout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arcanis","download_url":"https://codeload.github.com/arcanis/mono-layout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249035597,"owners_count":21202120,"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":["browser","cpp","text-formatting"],"created_at":"2024-11-08T10:13:50.472Z","updated_at":"2025-04-15T08:31:39.561Z","avatar_url":"https://github.com/arcanis.png","language":"C++","readme":"# [![Mono-Layout](/logo.png?raw=true)](https://github.com/arcanis/mono-layout)\n\n\u003e Fast implementation of a browser-like text layout engine, for Node and browsers\n\n[![](https://img.shields.io/npm/v/mono-layout.svg)]() [![](https://img.shields.io/npm/l/mono-layout.svg)]()\n\n## Features\n\n  - Soft-wraps any text to the given width\n  - Automatically justifies the text to fit the specified width if requested\n  - Can collapse text on demand (`white-space: pre`, but more configurable)\n  - Keeps an internal state to map between the original and transformed text coordinates\n  - Only updates the part of the text that has changed for better performances\n  - Shipped as NPM package using WebAssembly (portable, even accross browsers)\n  - Also available as a zero-dependencies C++ library\n\nCurrently not implemented:\n\n  - Font width support (all characters are assumed monospaces)\n  - Unicode support (all characters are assumed to be ASCII)\n\n## Installation\n\n```\n$\u003e yarn add mono-layout\n```\n\n## Usage\n\n```js\nconst {TextLayout} = require(`mono-layout/sync`);\nconst faker = require(`faker`);\n\nconst textLayout = new TextLayout();\ntextLayout.setConfiguration({columns: 80, justifyText: true});\ntextLayout.setSource(faker.lorem.paragraphs(10, `\\n\\n`));\n\nconsole.log(textLayout.getTransformedSource());\n```\n\nNote that the library is also available through an asynchronous endpoint (used by default when requiring `mono-layout`). You typically will want to use this endpoint if your code is expected to work within browsers, since they may disallow WebAssembly to be compiled in the main thread. Here's what the code looks like with the asynchronous initialization:\n\n```js\nconst tlPromise = require(`mono-layout/async`);\nconst faker = require(`faker`);\n\ntlPromise.then(({TextLayout}) =\u003e {\n  const textLayout = new TextLayout();\n  textLayout.setConfiguration({columns: 80, justifyText: true});\n  textLayout.setSource(faker.lorem.paragraphs(10, `\\n\\n`));\n\n  console.log(textLayout.getTransformedSource());\n});\n```\n\n## Tests\n\n### Testing the library\n\n```\n$\u003e apt-get install catch\n$\u003e make tests DEBUG=1\n```\n\n### Testing the JS module\n\n```\n$\u003e yarn\n$\u003e node sources/run-tests.js\n```\n\n## License (MIT)\n\n\u003e **Copyright © 2016 Maël Nison**\n\u003e\n\u003e Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\u003e\n\u003e The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\u003e\n\u003e THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farcanis%2Fmono-layout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farcanis%2Fmono-layout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farcanis%2Fmono-layout/lists"}