{"id":26883829,"url":"https://github.com/jiro4989/alignment","last_synced_at":"2025-05-08T17:01:50.398Z","repository":{"id":47903137,"uuid":"189177401","full_name":"jiro4989/alignment","owner":"jiro4989","description":"alignment is a library to align strings.","archived":false,"fork":false,"pushed_at":"2021-08-12T00:42:26.000Z","size":92,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T17:51:23.402Z","etag":null,"topics":["align","library","nim","text"],"latest_commit_sha":null,"homepage":"https://jiro4989.github.io/alignment/alignment.html","language":"Nim","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/jiro4989.png","metadata":{"files":{"readme":"README.adoc","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":"2019-05-29T07:51:53.000Z","updated_at":"2023-01-29T23:30:16.000Z","dependencies_parsed_at":"2022-08-26T04:43:58.567Z","dependency_job_id":null,"html_url":"https://github.com/jiro4989/alignment","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/jiro4989%2Falignment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiro4989%2Falignment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiro4989%2Falignment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiro4989%2Falignment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jiro4989","download_url":"https://codeload.github.com/jiro4989/alignment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253112071,"owners_count":21856070,"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":["align","library","nim","text"],"created_at":"2025-03-31T17:37:22.114Z","updated_at":"2025-05-08T17:01:50.271Z","avatar_url":"https://github.com/jiro4989.png","language":"Nim","funding_links":[],"categories":[],"sub_categories":[],"readme":":toc: left\n:sectnums:\n\n= alignment\n\nimage:https://travis-ci.org/jiro4989/alignment.svg?branch=master[\"Build Status\", link=\"https://travis-ci.org/jiro4989/alignment\"]\n\nalignment is a library to align strings.\nThe procedures consider multibyte strings (ex: あいうえお, 漢字).\n\n== Overview\n\nThe goal of this library is resolving texts out of alignment.\n\nA text will be out of alignment in terminal if you are padding with `strutils.align`.\nThis problem is occured by containing multibyte string.\n\nSee below.\n\n[source,nim]\n----\ndoAssert \"a\".len == 1\ndoAssert \"あ\".len == 3\n----\n\nThis example shows that length of \"a\" is 1 and length of \"あ\" is 3.\n`len` procedure returns a byte length, not count of characters.\nSimilarly, `strutils.alignLeft` is padding by byte length.\n\nSee below a example that a text is out of alignment.\n\n[source,nim]\n----\nimport strutils\n\ndoAssert \"a\".alignLeft(5) == \"a    \"\ndoAssert \"あ\".alignLeft(5) == \"あ  \"\ndoAssert \"a\".alignLeft(5).len == 5\ndoAssert \"あ\".alignLeft(5).len == 5\n----\n\n[source,nim]\n----\nimport unicode\n\ndoAssert align(\"A\", 4) == \"   A\"\ndoAssert align(\"あ\", 4) == \"   あ\"\n----\n\nA byte length equals, but texts look width doesn't equal.\nThis will be a problem when draw ruled lines on the terminal.\n\nThis library is resolving one.\nAbout usage of library, see usage section.\n\n== Development\n\nnim -v\n\n  Nim Compiler Version 0.19.6 [Linux: amd64]\n  Compiled at 2019-05-10\n  Copyright (c) 2006-2018 by Andreas Rumpf\n\n  git hash: c6f601d48ec81e0d6e052ba0d19a195b55cc68f2\n  active boot switches: -d:release\n\nnimble -v\n\n  nimble v0.9.0 compiled at 2018-10-27 18:10:03\n  git hash: couldn't determine git hash\n\n\n== Usage\n\n[source,nim]\n----\nimport alignment\n\nlet s = @[\"abcde\", \"あいうえお\", \"ABC\", \"あ\", \"123456789\"]\nlet aligned = s.alignCenter\ndoAssert aligned[0] == \"  abcde   \"\ndoAssert aligned[1] == \"あいうえお\"\ndoAssert aligned[2] == \"   ABC    \"\ndoAssert aligned[3] == \"    あ    \"\ndoAssert aligned[4] == \"123456789 \"\n\nfor line in aligned:\n  echo \"| \", line, \" |\"\n\n## Output:\n## |   abcde    |\n## | あいうえお |\n## |    ABC     |\n## |     あ     |\n## | 123456789  |\n----\n\n== Install\n\n[source,bash]\nnimble install alignment\n\n== License\n\nMIT\n\n== Document\n\n* https://jiro4989.github.io/alignment/alignment.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiro4989%2Falignment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiro4989%2Falignment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiro4989%2Falignment/lists"}